]> git.sesse.net Git - vlc/blobdiff - src/playlist/playlist.c
* src/playlist/playlist.c: fixed deadlock in playlist.
[vlc] / src / playlist / playlist.c
index 6648c1aac3346caad60dd9b61e3eceec6924b137..e5c15c1118428607ea97ab4e7a2f7842fe711ede 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.c : Playlist management functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: playlist.c,v 1.18 2002/11/12 21:20:36 gbazin Exp $
+ * $Id: playlist.c,v 1.23 2002/11/21 15:51:57 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -203,7 +203,7 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos )
         /* XXX: what if the item is still in use? */
         free( p_playlist->pp_items[i_pos] );
 
-        if( i_pos < p_playlist->i_index )
+        if( i_pos <= p_playlist->i_index )
         {
             p_playlist->i_index--;
         }
@@ -305,10 +305,6 @@ static void RunThread ( playlist_t *p_playlist )
                  * in input_DestroyThread() for some time. */
                 vlc_mutex_unlock( &p_playlist->object_lock );
 
-                /* Check for autodeletion */
-                if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
-                    playlist_Delete( p_playlist, p_playlist->i_index );
-
                 /* Destroy input */
                 input_DestroyThread( p_input );
                 vlc_object_destroy( p_input );
@@ -323,6 +319,14 @@ static void RunThread ( playlist_t *p_playlist )
             else if( p_playlist->p_input->b_error
                       || p_playlist->p_input->b_eof )
             {
+                /* Check for autodeletion */
+                if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
+                {
+                    vlc_mutex_unlock( &p_playlist->object_lock );
+                    playlist_Delete( p_playlist, p_playlist->i_index );
+                    vlc_mutex_lock( &p_playlist->object_lock );
+                }
+
                 /* Select the next playlist item */
                 SkipItem( p_playlist, 1 );
 
@@ -414,7 +418,7 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
     /* Increment */
     if( b_random )
     {
-        srand( mdate() );
+        srand( (unsigned int)mdate() );
 
         /* Simple random stuff - we cheat a bit to minimize the chances to
          * get the same index again. */