[FFmpeg-devel] [PATCH] concurrency errors in libstagefright decoder

Michael Zucchi notzed at gmail.com
Thu Mar 28 12:36:37 CET 2013


On 28/03/13 19:45, Clément Bœsch wrote:
> On Thu, Mar 28, 2013 at 04:07:20PM +1030, Michael Zucchi wrote:
>>
>> Hi,
>>
>> This adds a mutex around the buffer memory operations as they are
>> performed in different threads.  It isn't required for those after the
>> thread.join() for obvious reasons.
>>
>> Regards
>>  !Z
>>
> 
>> diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp
>> index a6fd1b9..c42db5f 100644
>> --- a/libavcodec/libstagefright.cpp
>> +++ b/libavcodec/libstagefright.cpp
>> @@ -66,6 +66,7 @@ struct StagefrightContext {
>>      sp<MediaSource> *source;
>>      List<Frame*> *in_queue, *out_queue;
>>      pthread_mutex_t in_mutex, out_mutex;
>> +    pthread_mutex_t codec_mutex;
>>      pthread_cond_t condition;
>>      pthread_t decode_thread_id;
>>  
>> @@ -185,7 +186,11 @@ void* decode_thread(void *arg)
>>                  buffer->release();
>>                  goto push_frame;
>>              }
>> -            ret = ff_get_buffer(avctx, frame->vframe);
>> +
>> +            pthread_mutex_lock(&s->codec_mutex);
>> +            ret = avctx->get_buffer(avctx, frame->vframe);
> 
> Why the switch from ff_get_buffer() to the internal call?
> 

Oops, just a forward-porting mistake.


More information about the ffmpeg-devel mailing list