[vlc-devel] [PATCH] visual: remove depreciated vlc_object_alive
Edward Wang
edward.c.wang at compdigitec.com
Sun May 27 18:10:44 CEST 2012
---
modules/visualization/visual/visual.c | 19 +++++++++++++++----
modules/visualization/visual/visual.h | 4 +++-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index a91faa7..8c43bb2 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -198,6 +198,8 @@ 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;
@@ -323,13 +325,16 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
picture_t *p_outpic;
/* First, get a new picture */
- while( ( p_outpic = vout_GetPicture( p_sys->p_vout ) ) == NULL)
- { /* XXX: This looks like a bad idea. Don't run to me for sympathy if it
- * dead locks... */
- if( !vlc_object_alive (p_sys->p_vout) )
+ do
+ {
+ 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 );
}
+ while( ( p_outpic = vout_GetPicture( p_sys->p_vout ) ) == NULL);
/* Blank the picture */
for( int i = 0 ; i < p_outpic->i_planes ; i++ )
@@ -364,6 +369,10 @@ 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 )
{
aout_filter_RequestVout( p_filter, p_filter->p_sys->p_vout, 0 );
@@ -397,4 +406,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 d065db0..8b79c7c 100644
--- a/modules/visualization/visual/visual.h
+++ b/modules/visualization/visual/visual.h
@@ -63,7 +63,9 @@ typedef struct
*****************************************************************************/
struct filter_sys_t
{
- vout_thread_t *p_vout;
+ vout_thread_t* p_vout;
+ vlc_mutex_t lock;
+ bool b_close;
int i_width;
int i_height;
--
1.7.5.4
More information about the vlc-devel
mailing list