[vlc-commits] commit: ML: Use a lock for ml_Create (Srikanth Raju )

git at videolan.org git at videolan.org
Sat Jul 3 20:22:19 CEST 2010


vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Sun Jul  4 00:09:01 2010 +0530| [e339d116d18123afcd30e3c7f6ec176c84d160e7] | committer: Srikanth Raju 

ML: Use a lock for ml_Create

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

 src/libvlc.c             |    2 ++
 src/libvlc.h             |    1 +
 src/misc/media_library.c |    2 ++
 3 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index 4a1250e..094d2c8 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -229,6 +229,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
 #endif
 
     /* Initialize mutexes */
+    vlc_mutex_init( &priv->ml_lock );
     vlc_mutex_init( &priv->timer_lock );
     vlc_ExitInit( &priv->exit );
 
@@ -1060,6 +1061,7 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
     /* Destroy mutexes */
     vlc_ExitDestroy( &priv->exit );
     vlc_mutex_destroy( &priv->timer_lock );
+    vlc_mutex_destroy( &priv->ml_lock );
 
 #ifndef NDEBUG /* Hack to dump leaked objects tree */
     if( vlc_internals( p_libvlc )->i_refcount > 1 )
diff --git a/src/libvlc.h b/src/libvlc.h
index 48205b1..69996de 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -215,6 +215,7 @@ typedef struct libvlc_priv_t
     module_t          *p_memcpy_module;  ///< Fast memcpy plugin used
     playlist_t        *p_playlist; ///< the playlist singleton
     media_library_t   *p_ml;    ///< the ML singleton
+    vlc_mutex_t       ml_lock; ///< Mutex for ML creation
     vlm_t             *p_vlm;  ///< the VLM singleton (or NULL)
     vlc_object_t      *p_dialog_provider; ///< dialog provider
     httpd_t           *p_httpd; ///< HTTP daemon (src/network/httpd.c)
diff --git a/src/misc/media_library.c b/src/misc/media_library.c
index 1223ad1..18f2299 100644
--- a/src/misc/media_library.c
+++ b/src/misc/media_library.c
@@ -111,6 +111,7 @@ media_library_t *ml_Create( vlc_object_t *p_this, char *psz_name )
 media_library_t* ml_Hold( vlc_object_t* p_this )
 {
     media_library_t* p_ml;
+    vlc_mutex_lock( &( libvlc_priv( p_this->p_libvlc )->ml_lock ) );
     p_ml = libvlc_priv (p_this->p_libvlc)->p_ml;
     assert( VLC_OBJECT( p_ml ) != p_this );
     if( p_ml == NULL &&
@@ -122,6 +123,7 @@ media_library_t* ml_Hold( vlc_object_t* p_this )
     }
     if( p_ml )
         vlc_object_hold( p_ml );
+    vlc_mutex_unlock( &( libvlc_priv( p_this->p_libvlc )->ml_lock ) );
     return p_ml;
 }
 



More information about the vlc-commits mailing list