From 03fc36954474c52114868fd4378f2cdc9a2a79e4 Mon Sep 17 00:00:00 2001
From: Francois Cartegnie <fcvlcdev@free.fr>
Date: Thu, 19 Jul 2012 13:34:31 +0200
Subject: [PATCH] ml: Ensure list lock is initiliazed when watch thread starts.

Some crashes occurs on start when processing the first append loop
at the unlock level.
---
 modules/media_library/ml_watch.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/media_library/ml_watch.c b/modules/media_library/ml_watch.c
index 960bccf6d8c5..4a7da5911560 100644
--- a/modules/media_library/ml_watch.c
+++ b/modules/media_library/ml_watch.c
@@ -93,6 +93,11 @@ int watch_Init( media_library_t *p_ml )
     vlc_cond_init( &p_wt->cond );
     vlc_mutex_init( &p_wt->lock );
 
+    /* Initialise item append queue */
+    vlc_mutex_init( &p_wt->item_append_queue_lock );
+    p_wt->item_append_queue = NULL;
+    p_wt->item_append_queue_count = 0;
+
     if( vlc_clone( &p_wt->thread, watch_Thread, p_wt, VLC_THREAD_PRIORITY_LOW ) )
     {
         msg_Dbg( p_ml, "unable to launch the auto-updating thread" );
@@ -111,11 +116,6 @@ int watch_Init( media_library_t *p_ml )
     var_AddCallback( p_pl, "playlist-item-append", watch_PlaylistItemAppend, p_ml );
     var_AddCallback( p_pl, "playlist-item-deleted", watch_PlaylistItemDeleted, p_ml );
 
-    /* Initialise item append queue */
-    vlc_mutex_init( &p_wt->item_append_queue_lock );
-    p_wt->item_append_queue = NULL;
-    p_wt->item_append_queue_count = 0;
-
     return VLC_SUCCESS;
 }
 
-- 
GitLab