[vlc-commits] visual: use mutexes
Edward Wang
git at videolan.org
Tue Sep 18 18:38:15 CEST 2012
vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Sep 15 12:13:08 2012 -0400| [a86dbb3b8535139cd40ec263b9dfb1be25f38ec7] | committer: Jean-Baptiste Kempf
visual: use mutexes
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a86dbb3b8535139cd40ec263b9dfb1be25f38ec7
---
modules/visualization/visual/visual.c | 10 +++++++++-
modules/visualization/visual/visual.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 1659682..a5e3b53 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -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 );
}
diff --git a/modules/visualization/visual/visual.h b/modules/visualization/visual/visual.h
index 50edbfc..8b79c7c 100644
--- a/modules/visualization/visual/visual.h
+++ b/modules/visualization/visual/visual.h
@@ -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;
More information about the vlc-commits
mailing list