]> git.sesse.net Git - vlc/commitdiff
Signal the playlist BEFORE unlocking it.
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Sep 2007 14:29:59 +0000 (14:29 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Sep 2007 14:29:59 +0000 (14:29 +0000)
One should never signal a condition without the corresponding lock:
 "if predictable scheduling behavior is required, then that mutex shall
  be locked    by    the    thread   calling   pthread_cond_broadcast()
  or pthread_cond_signal()." -- POSIX

This only fixes the most obvious cases. There might be others.

src/playlist/control.c
src/playlist/engine.c

index c0a89c2a10d9b28b07fb1d65cd598dc8cc269f51..6b487123bd4c02677aecfbfdfb88b12fd4b6bc7f 100644 (file)
@@ -184,8 +184,8 @@ int playlist_PreparseEnqueue( playlist_t *p_playlist,
                  p_playlist->p_preparse->i_waiting,
                  p_playlist->p_preparse->i_waiting,
                  p_item );
-    vlc_mutex_unlock( &p_playlist->p_preparse->object_lock );
     vlc_cond_signal( &p_playlist->p_preparse->object_wait );
+    vlc_mutex_unlock( &p_playlist->p_preparse->object_lock );
     return VLC_SUCCESS;
 }
 
@@ -218,8 +218,8 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist,
     INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
                  p_playlist->p_fetcher->i_waiting,
                  i, p );
-    vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
     vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
+    vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
     return VLC_SUCCESS;
 }
 
index 1c9d8f40fd83a70fbe83684362d13b9f7bcfc024..5fc7d04ca9dbb9cfb1fcdf69550a6296cade49a1 100644 (file)
@@ -544,8 +544,8 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
                 INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
                              p_playlist->p_fetcher->i_waiting,
                              p_playlist->p_fetcher->i_waiting, p);
-                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
                 vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
+                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
             }
             /* We already have all needed meta, but we need art right now */
             else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
@@ -559,8 +559,8 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
                 INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
                              p_playlist->p_fetcher->i_waiting,
                              p_playlist->p_fetcher->i_waiting, p);
-                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
                 vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
+                vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
             }
             else
             {