[vlc-commits] video_filters: use spin locks whenever possible

Rémi Duraffort git at videolan.org
Sun Mar 4 20:28:07 CET 2012


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Feb  5 23:27:19 2012 +0100| [4cd5c5d329a9164503d6f9113ffd4ceb1b372d29] | committer: Rémi Duraffort

video_filters: use spin locks whenever possible

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

 modules/video_filter/colorthres.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/modules/video_filter/colorthres.c b/modules/video_filter/colorthres.c
index d57e677..ca37545 100644
--- a/modules/video_filter/colorthres.c
+++ b/modules/video_filter/colorthres.c
@@ -101,7 +101,7 @@ struct filter_sys_t
     int i_simthres;
     int i_satthres;
     int i_color;
-    vlc_mutex_t lock;
+    vlc_spinlock_t lock;
 };
 
 /*****************************************************************************
@@ -149,7 +149,7 @@ static int Create( vlc_object_t *p_this )
     p_sys->i_satthres = var_CreateGetIntegerCommand( p_filter,
                                                      CFG_PREFIX "saturationthres" );
 
-    vlc_mutex_init( &p_sys->lock );
+    vlc_spin_init( &p_sys->lock );
 
     var_AddCallback( p_filter, CFG_PREFIX "color", FilterCallback, NULL );
     var_AddCallback( p_filter, CFG_PREFIX "similaritythres", FilterCallback, NULL );
@@ -171,7 +171,7 @@ static void Destroy( vlc_object_t *p_this )
     var_DelCallback( p_filter, CFG_PREFIX "similaritythres", FilterCallback, NULL );
     var_DelCallback( p_filter, CFG_PREFIX "saturationthres", FilterCallback, NULL );
 
-    vlc_mutex_destroy( &p_filter->p_sys->lock );
+    vlc_spin_destroy( &p_filter->p_sys->lock );
     free( p_filter->p_sys );
 }
 
@@ -213,11 +213,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     picture_t *p_outpic;
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    vlc_mutex_lock( &p_sys->lock );
+    vlc_spin_lock( &p_sys->lock );
     int i_simthres = p_sys->i_simthres;
     int i_satthres = p_sys->i_satthres;
     int i_color = p_sys->i_color;
-    vlc_mutex_unlock( &p_sys->lock );
+    vlc_spin_unlock( &p_sys->lock );
 
     if( !p_pic ) return NULL;
 
@@ -272,11 +272,11 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
     picture_t *p_outpic;
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    vlc_mutex_lock( &p_sys->lock );
+    vlc_spin_lock( &p_sys->lock );
     int i_simthres = p_sys->i_simthres;
     int i_satthres = p_sys->i_satthres;
     int i_color = p_sys->i_color;
-    vlc_mutex_unlock( &p_sys->lock );
+    vlc_spin_unlock( &p_sys->lock );
 
     if( !p_pic ) return NULL;
 
@@ -342,21 +342,21 @@ static int FilterCallback ( vlc_object_t *p_this, char const *psz_var,
 
     if( !strcmp( psz_var, CFG_PREFIX "color" ) )
     {
-        vlc_mutex_lock( &p_sys->lock );
+        vlc_spin_lock( &p_sys->lock );
         p_sys->i_color = newval.i_int;
-        vlc_mutex_unlock( &p_sys->lock );
+        vlc_spin_unlock( &p_sys->lock );
     }
     else if( !strcmp( psz_var, CFG_PREFIX "similaritythres" ) )
     {
-        vlc_mutex_lock( &p_sys->lock );
+        vlc_spin_lock( &p_sys->lock );
         p_sys->i_simthres = newval.i_int;
-        vlc_mutex_unlock( &p_sys->lock );
+        vlc_spin_unlock( &p_sys->lock );
     }
     else /* CFG_PREFIX "saturationthres" */
     {
-        vlc_mutex_lock( &p_sys->lock );
+        vlc_spin_lock( &p_sys->lock );
         p_sys->i_satthres = newval.i_int;
-        vlc_mutex_unlock( &p_sys->lock );
+        vlc_spin_unlock( &p_sys->lock );
     }
 
     return VLC_SUCCESS;



More information about the vlc-commits mailing list