w32thread: call ResetEvent() in pthread_cond_broadcast().
authorSergey Radionov <rsatom@gmail.com>
Fri, 23 Dec 2011 03:37:48 +0000 (10:37 +0700)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 3 Jan 2012 21:26:47 +0000 (22:26 +0100)
Also add "volatile" to broadcast flag (since it is used from
multiple threads).

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 01eb9805f37835e20501134ae26e379140fe3239)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/w32pthreads.h

index 3cdbc2c..70b84cf 100644 (file)
@@ -120,7 +120,7 @@ typedef struct {
     volatile int waiter_count;
     HANDLE semaphore;
     HANDLE waiters_done;
-    int is_broadcast;
+    volatile int is_broadcast;
 } win32_cond_t;
 
 static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
@@ -187,6 +187,7 @@ static void pthread_cond_broadcast(pthread_cond_t *cond)
         ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
         pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
         WaitForSingleObject(win32_cond->waiters_done, INFINITE);
+        ResetEvent(win32_cond->waiters_done);
         win32_cond->is_broadcast = 0;
     } else
         pthread_mutex_unlock(&win32_cond->mtx_waiter_count);