Commit 59712f39 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Gradient: callback thread-safety

parent 7df37bef
...@@ -108,6 +108,7 @@ static const char *const ppsz_filter_options[] = { ...@@ -108,6 +108,7 @@ static const char *const ppsz_filter_options[] = {
*****************************************************************************/ *****************************************************************************/
struct filter_sys_t struct filter_sys_t
{ {
vlc_mutex_t lock;
int i_mode; int i_mode;
/* For the gradient mode */ /* For the gradient mode */
...@@ -189,6 +190,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -189,6 +190,7 @@ static int Create( vlc_object_t *p_this )
p_filter->p_sys->b_cartoon = p_filter->p_sys->b_cartoon =
var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "cartoon" ); var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "cartoon" );
vlc_mutex_init( &p_filter->p_sys->lock );
var_AddCallback( p_filter, FILTER_PREFIX "mode", var_AddCallback( p_filter, FILTER_PREFIX "mode",
GradientCallback, p_filter->p_sys ); GradientCallback, p_filter->p_sys );
var_AddCallback( p_filter, FILTER_PREFIX "type", var_AddCallback( p_filter, FILTER_PREFIX "type",
...@@ -211,13 +213,22 @@ static int Create( vlc_object_t *p_this ) ...@@ -211,13 +213,22 @@ static int Create( vlc_object_t *p_this )
static void Destroy( vlc_object_t *p_this ) static void Destroy( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_filter->p_sys->p_buf32 );
free( p_filter->p_sys->p_buf32_bis ); var_DelCallback( p_filter, FILTER_PREFIX "mode",
free( p_filter->p_sys->p_buf8 ); GradientCallback, p_sys );
free( p_filter->p_sys->p_pre_hough ); var_DelCallback( p_filter, FILTER_PREFIX "type",
GradientCallback, p_sys );
free( p_filter->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 ) ...@@ -240,6 +251,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return NULL; return NULL;
} }
vlc_mutex_lock( &p_filter->p_sys->lock );
switch( p_filter->p_sys->i_mode ) switch( p_filter->p_sys->i_mode )
{ {
case EDGE: case EDGE:
...@@ -257,6 +269,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -257,6 +269,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
default: default:
break; break;
} }
vlc_mutex_unlock( &p_filter->p_sys->lock );
return CopyInfoAndRelease( p_outpic, p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
} }
...@@ -757,6 +770,8 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var, ...@@ -757,6 +770,8 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var,
{ {
VLC_UNUSED(oldval); VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data; 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( psz_var, FILTER_PREFIX "mode" ) )
{ {
if( !strcmp( newval.psz_string, "gradient" ) ) if( !strcmp( newval.psz_string, "gradient" ) )
...@@ -785,5 +800,7 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var, ...@@ -785,5 +800,7 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var,
{ {
p_sys->b_cartoon = newval.b_bool; p_sys->b_cartoon = newval.b_bool;
} }
vlc_mutex_unlock( &p_sys->lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment