]> git.sesse.net Git - vlc/commitdiff
visual: use mutexes
authorEdward Wang <edward.c.wang@compdigitec.com>
Sat, 15 Sep 2012 16:13:08 +0000 (12:13 -0400)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 18 Sep 2012 16:37:53 +0000 (18:37 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/visualization/visual/visual.c
modules/visualization/visual/visual.h

index 1659682245c9f100c8b19fe42c2e8837050c4020..a5e3b53d55ed74f554d9ffebdbf8c73bbb9e7094 100644 (file)
@@ -197,6 +197,7 @@ static int Open( vlc_object_t *p_this )
     if( (p_sys->i_height % 2 ) != 0 ) p_sys->i_height--;
     if( (p_sys->i_width % 2 )  != 0 ) p_sys->i_width--;
 
+    vlc_mutex_init( &p_sys->lock );
     p_sys->b_close = false;
     p_sys->i_effect = 0;
     p_sys->effect   = NULL;
@@ -325,7 +326,10 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
     /* First, get a new picture */
     do
     {
-        if( p_sys->b_close )
+        vlc_mutex_lock( &p_sys->lock );
+        bool close = p_sys->b_close;
+        vlc_mutex_unlock( &p_sys->lock );
+        if( close )
             return NULL;
         msleep( VOUT_OUTMEM_SLEEP );
     }
@@ -364,7 +368,9 @@ static void Close( vlc_object_t *p_this )
     filter_t * p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
+    vlc_mutex_lock( &p_sys->lock );
     p_sys->b_close = true;
+    vlc_mutex_unlock( &p_sys->lock );
 
     if( p_filter->p_sys->p_vout )
     {
@@ -399,4 +405,6 @@ static void Close( vlc_object_t *p_this )
 
     free( p_sys->effect );
     free( p_filter->p_sys );
+
+    vlc_mutex_destroy( &p_sys->lock );
 }
index 50edbfc182fc8cf5fb7e846b31fe8b625af2e9c2..8b79c7c49ed0e4c880335de65d93f35cf3cafd83 100644 (file)
@@ -64,6 +64,7 @@ typedef struct
 struct filter_sys_t
 {
     vout_thread_t*  p_vout;
+    vlc_mutex_t     lock;
     bool            b_close;
 
     int             i_width;