Commit e339d116 authored by Srikanth Raju's avatar Srikanth Raju

ML: Use a lock for ml_Create

parent c78c2b56
...@@ -229,6 +229,7 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -229,6 +229,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
#endif #endif
/* Initialize mutexes */ /* Initialize mutexes */
vlc_mutex_init( &priv->ml_lock );
vlc_mutex_init( &priv->timer_lock ); vlc_mutex_init( &priv->timer_lock );
vlc_ExitInit( &priv->exit ); vlc_ExitInit( &priv->exit );
...@@ -1060,6 +1061,7 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc ) ...@@ -1060,6 +1061,7 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
/* Destroy mutexes */ /* Destroy mutexes */
vlc_ExitDestroy( &priv->exit ); vlc_ExitDestroy( &priv->exit );
vlc_mutex_destroy( &priv->timer_lock ); vlc_mutex_destroy( &priv->timer_lock );
vlc_mutex_destroy( &priv->ml_lock );
#ifndef NDEBUG /* Hack to dump leaked objects tree */ #ifndef NDEBUG /* Hack to dump leaked objects tree */
if( vlc_internals( p_libvlc )->i_refcount > 1 ) if( vlc_internals( p_libvlc )->i_refcount > 1 )
......
...@@ -215,6 +215,7 @@ typedef struct libvlc_priv_t ...@@ -215,6 +215,7 @@ typedef struct libvlc_priv_t
module_t *p_memcpy_module; ///< Fast memcpy plugin used module_t *p_memcpy_module; ///< Fast memcpy plugin used
playlist_t *p_playlist; ///< the playlist singleton playlist_t *p_playlist; ///< the playlist singleton
media_library_t *p_ml; ///< the ML 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) vlm_t *p_vlm; ///< the VLM singleton (or NULL)
vlc_object_t *p_dialog_provider; ///< dialog provider vlc_object_t *p_dialog_provider; ///< dialog provider
httpd_t *p_httpd; ///< HTTP daemon (src/network/httpd.c) httpd_t *p_httpd; ///< HTTP daemon (src/network/httpd.c)
......
...@@ -111,6 +111,7 @@ media_library_t *ml_Create( vlc_object_t *p_this, char *psz_name ) ...@@ -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* ml_Hold( vlc_object_t* p_this )
{ {
media_library_t* p_ml; 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; p_ml = libvlc_priv (p_this->p_libvlc)->p_ml;
assert( VLC_OBJECT( p_ml ) != p_this ); assert( VLC_OBJECT( p_ml ) != p_this );
if( p_ml == NULL && if( p_ml == NULL &&
...@@ -122,6 +123,7 @@ media_library_t* ml_Hold( vlc_object_t* p_this ) ...@@ -122,6 +123,7 @@ media_library_t* ml_Hold( vlc_object_t* p_this )
} }
if( p_ml ) if( p_ml )
vlc_object_hold( p_ml ); vlc_object_hold( p_ml );
vlc_mutex_unlock( &( libvlc_priv( p_this->p_libvlc )->ml_lock ) );
return p_ml; return p_ml;
} }
......
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