[vlc-devel] commit: Gradient: callback thread-safety ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed May 20 18:53:54 CEST 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 19 20:21:04 2009 +0300| [59712f39c38e799807beee0db4e366ef5f8914e4] | committer: Rémi Denis-Courmont
Gradient: callback thread-safety
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=59712f39c38e799807beee0db4e366ef5f8914e4
---
modules/video_filter/gradient.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/modules/video_filter/gradient.c b/modules/video_filter/gradient.c
index c875bd1..948cb4a 100644
--- a/modules/video_filter/gradient.c
+++ b/modules/video_filter/gradient.c
@@ -108,6 +108,7 @@ static const char *const ppsz_filter_options[] = {
*****************************************************************************/
struct filter_sys_t
{
+ vlc_mutex_t lock;
int i_mode;
/* For the gradient mode */
@@ -189,6 +190,7 @@ static int Create( vlc_object_t *p_this )
p_filter->p_sys->b_cartoon =
var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "cartoon" );
+ vlc_mutex_init( &p_filter->p_sys->lock );
var_AddCallback( p_filter, FILTER_PREFIX "mode",
GradientCallback, p_filter->p_sys );
var_AddCallback( p_filter, FILTER_PREFIX "type",
@@ -211,13 +213,22 @@ static int Create( vlc_object_t *p_this )
static void Destroy( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
-
- free( p_filter->p_sys->p_buf32 );
- free( p_filter->p_sys->p_buf32_bis );
- free( p_filter->p_sys->p_buf8 );
- free( p_filter->p_sys->p_pre_hough );
-
- free( p_filter->p_sys );
+ filter_sys_t *p_sys = p_filter->p_sys;
+
+ var_DelCallback( p_filter, FILTER_PREFIX "mode",
+ GradientCallback, p_sys );
+ var_DelCallback( p_filter, FILTER_PREFIX "type",
+ GradientCallback, p_sys );
+ var_DelCallback( p_filter, FILTER_PREFIX "cartoon",
+ GradientCallback, p_sys );
+ vlc_mutex_destroy( &p_sys->lock );
+
+ free( p_sys->p_buf32 );
+ free( p_sys->p_buf32_bis );
+ free( p_sys->p_buf8 );
+ free( p_sys->p_pre_hough );
+
+ free( p_sys );
}
/*****************************************************************************
@@ -240,6 +251,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return NULL;
}
+ vlc_mutex_lock( &p_filter->p_sys->lock );
switch( p_filter->p_sys->i_mode )
{
case EDGE:
@@ -257,6 +269,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
default:
break;
}
+ vlc_mutex_unlock( &p_filter->p_sys->lock );
return CopyInfoAndRelease( p_outpic, p_pic );
}
@@ -757,6 +770,8 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var,
{
VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data;
+
+ vlc_mutex_lock( &p_sys->lock );
if( !strcmp( psz_var, FILTER_PREFIX "mode" ) )
{
if( !strcmp( newval.psz_string, "gradient" ) )
@@ -785,5 +800,7 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var,
{
p_sys->b_cartoon = newval.b_bool;
}
+ vlc_mutex_unlock( &p_sys->lock );
+
return VLC_SUCCESS;
}
More information about the vlc-devel
mailing list