githubのコードからのfolk
Revision | 8e1255d542133cf6b378190d947254ca9df3347d (tree) |
---|---|
Time | 2010-10-03 04:11:09 |
Author | jstebbins <jstebbins@b64f...> |
Commiter | jstebbins |
fix ffmpeg locking issue
ffmpeg complained "insufficient thread locking around avcodec_open/close()".
This was caused by encavcodec.c calling avcodec_open at the same time as
stream.c called av_find_stream_info. av_find_stream_info has a side effect
of calling avcodec_open, so we must lock around this call as well.
git-svn-id: svn://localhost/HandBrake/trunk@3563 b64f7644-9d1e-0410-96f1-a4d463321fa5
@@ -82,6 +82,15 @@ int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec) | ||
82 | 82 | return ret; |
83 | 83 | } |
84 | 84 | |
85 | +int hb_av_find_stream_info(AVFormatContext *ic) | |
86 | +{ | |
87 | + int ret; | |
88 | + hb_lock( hb_avcodec_lock ); | |
89 | + ret = av_find_stream_info( ic ); | |
90 | + hb_unlock( hb_avcodec_lock ); | |
91 | + return ret; | |
92 | +} | |
93 | + | |
85 | 94 | int hb_avcodec_close(AVCodecContext *avctx) |
86 | 95 | { |
87 | 96 | int ret; |
@@ -9,4 +9,5 @@ | ||
9 | 9 | void hb_avcodec_init(void); |
10 | 10 | int hb_avcodec_open( AVCodecContext *, struct AVCodec * ); |
11 | 11 | int hb_avcodec_close( AVCodecContext * ); |
12 | +int hb_av_find_stream_info(AVFormatContext *ic); | |
12 | 13 | int hb_ff_layout_xlat(int64_t ff_layout, int channels); |
@@ -2909,7 +2909,7 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title ) | ||
2909 | 2909 | { |
2910 | 2910 | return 0; |
2911 | 2911 | } |
2912 | - if ( av_find_stream_info( ic ) < 0 ) | |
2912 | + if ( hb_av_find_stream_info( ic ) < 0 ) | |
2913 | 2913 | goto fail; |
2914 | 2914 | |
2915 | 2915 | stream->ffmpeg_ic = ic; |