[FFmpeg-cvslog] threads: fix a potential race spotted by helgrind.

Clément Bœsch git at videolan.org
Thu Jul 19 19:15:36 CEST 2012


ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Thu Jul 19 19:08:31 2012 +0200| [55ed91c8565a3c562d2982e1cd5e66df06c6c190] | committer: Clément Bœsch

threads: fix a potential race spotted by helgrind.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55ed91c8565a3c562d2982e1cd5e66df06c6c190
---

 libavcodec/pthread.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 7f2ea09..597aeba 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -975,9 +975,9 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
         avctx->get_buffer == avcodec_default_get_buffer) {
         err = avctx->get_buffer(avctx, f);
     } else {
+        pthread_mutex_lock(&p->progress_mutex);
         p->requested_frame = f;
         p->state = STATE_GET_BUFFER;
-        pthread_mutex_lock(&p->progress_mutex);
         pthread_cond_broadcast(&p->progress_cond);
 
         while (p->state != STATE_SETTING_UP)



More information about the ffmpeg-cvslog mailing list