[FFmpeg-devel] [PATCH 4/4] avcodec/mediacodecenc: add async mode support

Anton Khirnov anton at khirnov.net
Wed Nov 27 11:42:44 EET 2024


Quoting Zhao Zhili (2024-11-27 08:42:34)
> > 
> >> +
> >> +    ff_mutex_unlock(&s->input_mutex);
> >> +    ff_cond_signal(&s->input_cond);
> > 
> > This looks wrong - you should signal while holding the mutex, otherwise
> > the consumer may miss the signal. Same for the other two signalling
> > sites.
> 
> How? The Linux Programming Interface 30.2.2:
> 
> We conclude with one final observation about the use of pthread_cond_signal()
> (and pthread_cond_broadcast()). In the producer code shown earlier, we called
> pthread_mutex_unlock(), and then called pthread_cond_signal(); that is, we first unlocked
> the mutex associated with the shared variable, and then signaled the corresponding
> condition variable. We could have reversed these two steps; SUSv3 permits them to
> be done in either order.

Okay, I guess it's not a problem. Ignore the comment then.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list