[Mlt-devel] avformat locking
Brought to you by:
ddennedy,
lilo_booter
From: Brian M. <pez...@ya...> - 2012-01-18 05:06:28
|
Hi Dan, I've been using Kdenlive and MLT both from git head and I've been trying to track down why Kdenlive keeps crashing when I import multiple clips. The crash always occurs after libav has spit out the message: "insufficient thread locking around avcodec_open/close()" So I had a look at the avformat module in MLT and noticed that MLT uses a manual mutex lock around all avformat open/close calls. Upon inspection of the code, I didn't see any problems with the mutexes. The open/close calls seem to be protected. But on a whim, I tried using the libav builtin av_lockmgr_register() function. Oddly enough, the crashing stopped. Here is a patch for your consideration: https://github.com/pez4brian/mlt/commit/16fc54ab5e7f529bc814585a1e7d75d736c0a759 To me the advantages of the patch are: 1) It cleans up the code by removing many lines of lock/unlock calls. 2) It should be more extensible if the locking requirements for libav change in the future, it would be reasonable to expect that the built-in locking will always work properly. The disadvantage may be: * It appears that MLT may have also been protecting some private member variables besides just the open/close functions. I'm sure you have the background context on that. Anyway, could you please comment on the suitability of the patch for MLT? If it is not suitable, I can continue to try to figure out exactly what is causing my problem (I see others appear to be having a similar problem[1][2]). In the mean time, I'll keep testing to make sure that the patch really does solve the problem. Thanks, ~Brian [1] http://www.kdenlive.org/forum/rendering-aborted-h264-0x7f1ef800d5e0-insufficient-thread-locking-around-avcodecopenclose [2] http://kdenlive.org/mantis/view.php?id=2481 |