]> git.sesse.net Git - vlc/blobdiff - src/playlist/playlist.c
* modules/demux/ogg.c: added support for new Ogg mapping for FLAC.
[vlc] / src / playlist / playlist.c
index 642f019517f7ba6fc0e28ac4aa1d21ec4cca8231..23b67811573d433e056f6bcf59a7321afc7c0ce7 100644 (file)
@@ -165,8 +165,6 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
 
     p_playlist->p_preparse->i_waiting = 0;
     p_playlist->p_preparse->pp_waiting = NULL;
-    vlc_mutex_init( p_playlist->p_preparse,
-                    &p_playlist->p_preparse->object_lock );
 
     vlc_object_attach( p_playlist->p_preparse, p_playlist );
     if( vlc_thread_create( p_playlist->p_preparse, "preparser",
@@ -207,8 +205,6 @@ int playlist_Destroy( playlist_t * p_playlist )
 
     vlc_object_detach( p_playlist->p_preparse );
 
-    vlc_mutex_destroy( &p_playlist->p_preparse->object_lock );
-
     var_Destroy( p_playlist, "intf-change" );
     var_Destroy( p_playlist, "item-change" );
     var_Destroy( p_playlist, "playlist-current" );
@@ -689,7 +685,7 @@ static void RunThread ( playlist_t *p_playlist )
 /* Queue for items to preparse */
 static void RunPreparse ( playlist_preparse_t *p_obj )
 {
-    playlist_t *p_playlist = p_obj->p_parent;
+    playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
     vlc_bool_t b_sleep;
 
     /* Tell above that we're ready */
@@ -861,7 +857,11 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
             p_view = playlist_ViewFind( p_playlist,p_playlist->request.i_view );
             p_playlist->status.p_node = p_playlist->request.p_node;
             p_playlist->status.i_view = p_playlist->request.i_view;
-            if( i_skip > 0 )
+            if( !p_view )
+            {
+                msg_Err( p_playlist, "p_view is NULL and should not! (FIXME)" );
+            }
+            else if( i_skip > 0 )
             {
                 for( i = i_skip; i > 0 ; i-- )
                 {
@@ -870,7 +870,22 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
                                     p_view->p_root,
                                     p_playlist->request.p_node,
                                     p_new );
-                    if( p_new == NULL ) break;
+                    if( p_new == NULL )
+                    {
+                        if( b_loop )
+                        {
+                            p_new = playlist_FindNextFromParent( p_playlist,
+                                      p_playlist->request.i_view,
+                                      p_view->p_root,
+                                      p_playlist->request.p_node,
+                                      NULL );
+                            if( p_new == NULL ) break;
+                        }
+                        else
+                        {
+                            break;
+                        }
+                    }
                 }
             }
             else if( i_skip < 0 )
@@ -909,7 +924,13 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
             else
             {
                 msg_Dbg( p_playlist,"finished" );
-                p_new = NULL;
+                if( b_loop && p_playlist->i_size > 0)
+                {
+                    p_playlist->i_index = 0;
+                    p_new = p_playlist->pp_items[0];
+                }
+                else
+                    p_new = NULL;
             }
         }
         /* We are playing with a view */
@@ -918,11 +939,26 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
             playlist_view_t *p_view =
                     playlist_ViewFind( p_playlist,
                                    p_playlist->status.i_view );
-            p_new = playlist_FindNextFromParent( p_playlist,
+            if( !p_view )
+            {
+                msg_Err( p_playlist, "p_view is NULL and should not! (FIXME)" );
+            }
+            else
+            {
+                p_new = playlist_FindNextFromParent( p_playlist,
                             p_playlist->status.i_view,
                             p_view->p_root,
                             p_playlist->status.p_node,
                             p_playlist->status.p_item );
+                if( p_new == NULL && b_loop )
+                {
+                    p_new = playlist_FindNextFromParent( p_playlist,
+                                   p_playlist->status.i_view,
+                                   p_view->p_root,
+                                   p_playlist->status.p_node,
+                                   NULL );
+                }
+            }
         }
     }
 
@@ -938,8 +974,10 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
     msg_Dbg(p_playlist,"next item found in "I64Fi " us", mdate()-start );
 #endif
 
-    if( p_new == NULL ) { msg_Info( p_playlist, "Nothing to play" ); }
-
+    if( p_new == NULL )
+    {
+        msg_Info( p_playlist, "Nothing to play" );
+    }
     return p_new;
 }
 
@@ -1033,14 +1071,13 @@ static int ItemChange( vlc_object_t *p_obj, const char *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *param )
 {
     playlist_t *p_playlist = (playlist_t *)param;
-    int i_index;
 
     //p_playlist->b_need_update = VLC_TRUE;
     var_SetInteger( p_playlist, "item-change", newval.i_int );
 
     /* Update view */
     /* FIXME: Make that automatic */
-    playlist_ViewUpdate( p_playlist, VIEW_S_AUTHOR );
+//    playlist_ViewUpdate( p_playlist, VIEW_S_AUTHOR );
 
     return VLC_SUCCESS;
 }