]> git.sesse.net Git - vlc/blobdiff - src/playlist/thread.c
Improved debug messages
[vlc] / src / playlist / thread.c
index b0d9be2c4aa8bebe43a9a2a06681de77a02d470a..4bce33eea5599305f28bacbf2b1cf3c644237d46 100644 (file)
@@ -64,7 +64,7 @@ void playlist_Activate( playlist_t *p_playlist )
     {
         msg_Err( p_playlist, "cannot spawn playlist thread" );
     }
-    msg_Dbg( p_playlist, "Activated" );
+    msg_Dbg( p_playlist, "playlist threads correctly activated" );
 }
 
 void playlist_Deactivate( playlist_t *p_playlist )
@@ -84,7 +84,10 @@ void playlist_Deactivate( playlist_t *p_playlist )
 
     /* release input resources */
     if( p_sys->p_input_resource )
-        input_resource_Delete( p_sys->p_input_resource );
+    {
+        input_resource_Terminate( p_sys->p_input_resource );
+        input_resource_Release( p_sys->p_input_resource );
+    }
     p_sys->p_input_resource = NULL;
 
     if( var_InheritBool( p_playlist, "media-library" ) )
@@ -192,7 +195,7 @@ static void ResetCurrentlyPlaying( playlist_t *p_playlist,
         /* Shuffle the array */
         for( unsigned j = p_playlist->current.i_size - 1; j > 0; j-- )
         {
-            unsigned i = ((unsigned)vlc_mrand48()) % (j+1); /* between 0 and j */
+            unsigned i = vlc_lrand48() % (j+1); /* between 0 and j */
             playlist_item_t *p_tmp;
             /* swap the two items */
             p_tmp = ARRAY_VAL(p_playlist->current, i);
@@ -230,6 +233,8 @@ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
 
     assert( p_sys->p_input == NULL );
 
+    if( !p_sys->p_input_resource )
+        p_sys->p_input_resource = input_resource_New( VLC_OBJECT( p_playlist ) );
     input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource );
     if( p_input_thread )
     {
@@ -245,8 +250,6 @@ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
         }
     }
 
-    p_sys->p_input_resource = NULL;
-
     char *psz_uri = input_item_GetURI( p_item->p_input );
     if( psz_uri && ( !strncmp( psz_uri, "directory:", 10 ) ||
                      !strncmp( psz_uri, "vlc:", 4 ) ) )
@@ -309,7 +312,7 @@ static playlist_item_t *NextItem( playlist_t *p_playlist )
     {
         p_new = p_sys->request.p_item;
         int i_skip = p_sys->request.i_skip;
-        PL_DEBUG( "processing request item %s node %s skip %i",
+        PL_DEBUG( "processing request item: %s, node: %s, skip: %i",
                         PLI_NAME( p_sys->request.p_item ),
                         PLI_NAME( p_sys->request.p_node ), i_skip );
 
@@ -465,10 +468,6 @@ static int LoopInput( playlist_t *p_playlist )
     {
         PL_DEBUG( "dead input" );
 
-        assert( p_sys->p_input_resource == NULL );
-
-        p_sys->p_input_resource = input_DetachResource( p_input );
-
         PL_UNLOCK;
         /* We can unlock as we return VLC_EGENERIC (no event will be lost) */
 
@@ -544,7 +543,7 @@ static void LoopRequest( playlist_t *p_playlist )
     playlist_item_t *p_item = NextItem( p_playlist );
     if( p_item )
     {
-        msg_Dbg( p_playlist, "starting new item" );
+        msg_Dbg( p_playlist, "starting playback of the new playlist item" );
         PlayItem( p_playlist, p_item );
         return;
     }