[vlc-commits] Convert mosaic to global mutex

Rémi Denis-Courmont git at videolan.org
Thu Jul 21 16:50:59 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 21 17:23:07 2011 +0300| [e4b0862ff236c2a97b6c9bcf7c5459b380c1b712] | committer: Rémi Denis-Courmont

Convert mosaic to global mutex

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 include/vlc_threads.h              |    1 +
 modules/stream_out/mosaic_bridge.c |   17 ++++++-----------
 modules/video_filter/mosaic.c      |   13 ++++---------
 src/misc/threads.c                 |    1 +
 4 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 8fa2cf0..f5c0475 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -480,6 +480,7 @@ enum {
    VLC_AVCODEC_MUTEX = 0,
    VLC_GCRYPT_MUTEX,
    VLC_XLIB_MUTEX,
+   VLC_MOSAIC_MUTEX,
    /* Insert new entry HERE */
    VLC_MAX_MUTEX
 };
diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index 9c807b1..266f608 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -49,7 +49,6 @@
 struct sout_stream_sys_t
 {
     bridged_es_t *p_es;
-    vlc_mutex_t *p_lock;
 
     decoder_t       *p_decoder;
     image_handler_t *p_image; /* filter for resizing */
@@ -192,10 +191,6 @@ static int Open( vlc_object_t *p_this )
     p_stream->p_sys = p_sys;
     p_sys->b_inited = false;
 
-    var_Create( p_libvlc, "mosaic-lock", VLC_VAR_MUTEX );
-    var_Get( p_libvlc, "mosaic-lock", &val );
-    p_sys->p_lock = val.p_address;
-
     p_sys->psz_id = var_CreateGetString( p_stream, CFG_PREFIX "id" );
 
     p_sys->i_height =
@@ -347,7 +342,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     }
 
     p_sys->b_inited = true;
-    vlc_mutex_lock( p_sys->p_lock );
+    vlc_global_lock( VLC_MOSAIC_MUTEX );
 
     p_bridge = GetBridge( p_stream );
     if ( p_bridge == NULL )
@@ -391,7 +386,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     p_es->pp_last = &p_es->p_picture;
     p_es->b_empty = false;
 
-    vlc_mutex_unlock( p_sys->p_lock );
+    vlc_global_unlock( VLC_MOSAIC_MUTEX );
 
     if ( p_sys->i_height || p_sys->i_width )
     {
@@ -458,7 +453,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
     if( p_sys->p_vf2 )
         filter_chain_Delete( p_sys->p_vf2 );
 
-    vlc_mutex_lock( p_sys->p_lock );
+    vlc_global_lock( VLC_MOSAIC_MUTEX );
 
     p_bridge = GetBridge( p_stream );
     p_es = p_sys->p_es;
@@ -490,7 +485,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
         var_Destroy( p_libvlc, "mosaic-struct" );
     }
 
-    vlc_mutex_unlock( p_sys->p_lock );
+    vlc_global_unlock( VLC_MOSAIC_MUTEX );
 
     if ( p_sys->p_image )
     {
@@ -510,13 +505,13 @@ static void PushPicture( sout_stream_t *p_stream, picture_t *p_picture )
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     bridged_es_t *p_es = p_sys->p_es;
 
-    vlc_mutex_lock( p_sys->p_lock );
+    vlc_global_lock( VLC_MOSAIC_MUTEX );
 
     *p_es->pp_last = p_picture;
     p_picture->p_next = NULL;
     p_es->pp_last = &p_picture->p_next;
 
-    vlc_mutex_unlock( p_sys->p_lock );
+    vlc_global_unlock( VLC_MOSAIC_MUTEX );
 }
 
 static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c
index edce685..9b0ff06 100644
--- a/modules/video_filter/mosaic.c
+++ b/modules/video_filter/mosaic.c
@@ -58,7 +58,6 @@ static int MosaicCallback   ( vlc_object_t *, char const *, vlc_value_t,
 struct filter_sys_t
 {
     vlc_mutex_t lock;         /* Internal filter lock */
-    vlc_mutex_t *p_lock;      /* Pointer to mosaic bridge lock */
 
     image_handler_t *p_image;
 
@@ -299,10 +298,6 @@ static int CreateFilter( vlc_object_t *p_this )
     vlc_mutex_init( &p_sys->lock );
     vlc_mutex_lock( &p_sys->lock );
 
-    var_Create( p_libvlc, "mosaic-lock", VLC_VAR_MUTEX );
-    var_Get( p_libvlc, "mosaic-lock", &val );
-    p_sys->p_lock = val.p_address;
-
     config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                        p_filter->p_cfg );
 
@@ -466,12 +461,12 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     p_spu->b_absolute = false;
 
     vlc_mutex_lock( &p_sys->lock );
-    vlc_mutex_lock( p_sys->p_lock );
+    vlc_global_lock( VLC_MOSAIC_MUTEX );
 
     p_bridge = GetBridge( p_filter );
     if ( p_bridge == NULL )
     {
-        vlc_mutex_unlock( p_sys->p_lock );
+        vlc_global_unlock( VLC_MOSAIC_MUTEX );
         vlc_mutex_unlock( &p_sys->lock );
         return p_spu;
     }
@@ -657,7 +652,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         {
             msg_Err( p_filter, "cannot allocate SPU region" );
             p_filter->pf_sub_buffer_del( p_filter, p_spu );
-            vlc_mutex_unlock( p_sys->p_lock );
+            vlc_global_unlock( VLC_MOSAIC_MUTEX );
             vlc_mutex_unlock( &p_sys->lock );
             return p_spu;
         }
@@ -725,7 +720,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         p_region_prev = p_region;
     }
 
-    vlc_mutex_unlock( p_sys->p_lock );
+    vlc_global_unlock( VLC_MOSAIC_MUTEX );
     vlc_mutex_unlock( &p_sys->lock );
 
     return p_spu;
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 9b3d5c1..72dad94 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -40,6 +40,7 @@ void vlc_global_mutex (unsigned n, bool acquire)
         VLC_STATIC_MUTEX,
         VLC_STATIC_MUTEX,
         VLC_STATIC_MUTEX,
+        VLC_STATIC_MUTEX,
     };
     assert (n < (sizeof (locks) / sizeof (locks[0])));
     vlc_mutex_t *lock = locks + n;



More information about the vlc-commits mailing list