Commit 1e5e931c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Motion blur: callback thread safety

parent a8595578
......@@ -80,6 +80,7 @@ static const char *const ppsz_filter_options[] = {
*****************************************************************************/
struct filter_sys_t
{
vlc_spinlock_t lock;
int i_factor;
uint8_t **pp_planes;
......@@ -105,6 +106,7 @@ static int Create( vlc_object_t *p_this )
p_filter->p_sys->i_factor =
var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "factor" );
vlc_spin_init( &p_filter->p_sys->lock );
var_AddCallback( p_filter, FILTER_PREFIX "factor",
MotionBlurCallback, p_filter->p_sys );
......@@ -121,6 +123,10 @@ static void Destroy( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
var_DelCallback( p_filter, FILTER_PREFIX "factor",
MotionBlurCallback, p_filter->p_sys );
vlc_spin_destroy( &p_filter->p_sys->lock );
while( p_filter->p_sys->i_planes-- )
free( p_filter->p_sys->pp_planes[p_filter->p_sys->i_planes] );
free( p_filter->p_sys->pp_planes );
......@@ -220,7 +226,12 @@ static int MotionBlurCallback( vlc_object_t *p_this, char const *psz_var,
{
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
filter_sys_t *p_sys = (filter_sys_t *)p_data;
if( !strcmp( psz_var, FILTER_PREFIX "factor" ) )
{
vlc_spin_lock( &p_sys->lock );
p_sys->i_factor = __MIN( 127, __MAX( 1, newval.i_int ) );
vlc_spin_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