[vlc-devel] commit: Motion blur: callback thread safety ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue May 19 19:59:18 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Tue May 19 20:40:11 2009 +0300| [1e5e931cf78ca9eda6f7216037b74ea7f2cda3aa] | committer: Rémi Denis-Courmont 

Motion blur: callback thread safety

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e5e931cf78ca9eda6f7216037b74ea7f2cda3aa
---

 modules/video_filter/motionblur.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/modules/video_filter/motionblur.c b/modules/video_filter/motionblur.c
index 40c7044..e975efc 100644
--- a/modules/video_filter/motionblur.c
+++ b/modules/video_filter/motionblur.c
@@ -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;
 }




More information about the vlc-devel mailing list