Commit 57eefa00 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Erase: actual thread-safety

parent 8c1c227d
...@@ -169,12 +169,11 @@ static int Create( vlc_object_t *p_this ) ...@@ -169,12 +169,11 @@ static int Create( vlc_object_t *p_this )
p_sys->i_x = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "x" ); p_sys->i_x = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "x" );
p_sys->i_y = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "y" ); p_sys->i_y = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "y" );
vlc_mutex_init( &p_sys->lock );
var_AddCallback( p_filter, CFG_PREFIX "x", EraseCallback, p_sys ); var_AddCallback( p_filter, CFG_PREFIX "x", EraseCallback, p_sys );
var_AddCallback( p_filter, CFG_PREFIX "y", EraseCallback, p_sys ); var_AddCallback( p_filter, CFG_PREFIX "y", EraseCallback, p_sys );
var_AddCallback( p_filter, CFG_PREFIX "mask", EraseCallback, p_sys ); var_AddCallback( p_filter, CFG_PREFIX "mask", EraseCallback, p_sys );
vlc_mutex_init( &p_sys->lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -188,6 +187,9 @@ static void Destroy( vlc_object_t *p_this ) ...@@ -188,6 +187,9 @@ static void Destroy( vlc_object_t *p_this )
if( p_sys->p_mask ) if( p_sys->p_mask )
picture_Release( p_sys->p_mask ); picture_Release( p_sys->p_mask );
var_DelCallback( p_filter, CFG_PREFIX "x", EraseCallback, p_sys );
var_DelCallback( p_filter, CFG_PREFIX "y", EraseCallback, p_sys );
var_DelCallback( p_filter, CFG_PREFIX "mask", EraseCallback, p_sys );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
free( p_filter->p_sys ); free( p_filter->p_sys );
...@@ -223,13 +225,12 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic, ...@@ -223,13 +225,12 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
{ {
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
int i_plane; vlc_mutex_lock( &p_sys->lock );
const int i_mask_pitch = p_sys->p_mask->A_PITCH; const int i_mask_pitch = p_sys->p_mask->A_PITCH;
const int i_mask_visible_pitch = p_sys->p_mask->p[A_PLANE].i_visible_pitch; const int i_mask_visible_pitch = p_sys->p_mask->p[A_PLANE].i_visible_pitch;
const int i_mask_visible_lines = p_sys->p_mask->p[A_PLANE].i_visible_lines; const int i_mask_visible_lines = p_sys->p_mask->p[A_PLANE].i_visible_lines;
for( i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ ) for( int i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ )
{ {
const int i_pitch = p_inpic->p[i_plane].i_pitch; const int i_pitch = p_inpic->p[i_plane].i_pitch;
const int i_2pitch = i_pitch<<1; const int i_2pitch = i_pitch<<1;
...@@ -240,9 +241,8 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic, ...@@ -240,9 +241,8 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
uint8_t *p_inpix = p_inpic->p[i_plane].p_pixels; uint8_t *p_inpix = p_inpic->p[i_plane].p_pixels;
uint8_t *p_outpix = p_outpic->p[i_plane].p_pixels; uint8_t *p_outpix = p_outpic->p[i_plane].p_pixels;
uint8_t *p_mask = p_sys->p_mask->A_PIXELS; uint8_t *p_mask = p_sys->p_mask->A_PIXELS;
int i_x = p_sys->i_x, i_y = p_sys->i_y;
int i_x = p_sys->i_x,
i_y = p_sys->i_y;
int x, y; int x, y;
int i_height = i_mask_visible_lines; int i_height = i_mask_visible_lines;
int i_width = i_mask_visible_pitch; int i_width = i_mask_visible_pitch;
...@@ -394,6 +394,7 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic, ...@@ -394,6 +394,7 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
} }
} }
} }
vlc_mutex_unlock( &p_sys->lock );
} }
static int EraseCallback( vlc_object_t *p_this, char const *psz_var, static int EraseCallback( vlc_object_t *p_this, char const *psz_var,
......
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