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[] = {
*****************************************************************************/
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;
}
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