]> git.sesse.net Git - vlc/blobdiff - src/playlist/engine.c
dejidjei:
[vlc] / src / playlist / engine.c
index 4419aa5ec16bd5777aff31b9a31f8fd56a649671..90b552663a5667b5001daee45de00f941dc429dd 100644 (file)
@@ -1,8 +1,7 @@
 /*****************************************************************************
  * engine.c : Run the playlist and handle its control
  *****************************************************************************
- * Copyright (C) 1999-2007 the VideoLAN team
- * $Id$
+ * Copyright (C) 1999-2008 the VideoLAN team
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          ClĂ©ment Stenac <zorglub@videolan.org>
@@ -68,10 +67,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     p_playlist = vlc_custom_create( p_parent, sizeof( *p_playlist ),
                                     VLC_OBJECT_GENERIC, playlist_name );
     if( !p_playlist )
-    {
-        msg_Err( p_parent, "out of memory" );
         return NULL;
-    }
 
     TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds );
 
@@ -177,16 +173,13 @@ static void playlist_Destructor( vlc_object_t * p_this )
 
     if( p_playlist->p_fetcher )
         vlc_object_release( p_playlist->p_fetcher );
-#ifndef NDEBUG
-    libvlc_priv (p_this->p_libvlc)->p_playlist = NULL; /* pl_Yield() will fail */
-#endif
+
+    msg_Dbg( p_this, "Destroyed" );
 }
 
 /* Destroy remaining objects */
 static void ObjectGarbageCollector( playlist_t *p_playlist, bool b_force )
 {
-    vlc_object_t *p_obj;
-
     if( !b_force )
     {
         if( mdate() - p_playlist->gc_date < 1000000 )
@@ -225,7 +218,7 @@ static void input_selected_stream_changed( const vlc_event_t * event, void * dat
 /* Internals */
 void playlist_release_current_input( playlist_t * p_playlist )
 {
-    vlc_assert_locked( &p_playlist->object_lock );
+    vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
 
     if( !p_playlist->p_input ) return;
 
@@ -240,6 +233,7 @@ void playlist_release_current_input( playlist_t * p_playlist )
 
     /* Release the playlist lock, because we may get stuck
      * in vlc_object_release() for some time. */
+    printf("_______ releasing\n");
     PL_UNLOCK;
     vlc_object_release( p_input );
     PL_LOCK;
@@ -248,7 +242,7 @@ void playlist_release_current_input( playlist_t * p_playlist )
 void playlist_set_current_input(
     playlist_t * p_playlist, input_thread_t * p_input )
 {
-    vlc_assert_locked( &p_playlist->object_lock );
+    vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
 
     playlist_release_current_input( p_playlist );
 
@@ -264,6 +258,18 @@ void playlist_set_current_input(
     }
 }
 
+/** Get current playing input.
+ */
+input_thread_t * playlist_CurrentInput( playlist_t * p_playlist )
+{
+    input_thread_t * p_input;
+    PL_LOCK;
+    p_input = p_playlist->p_input;
+    if( p_input ) vlc_object_yield( p_input );
+    PL_UNLOCK;
+    return p_input;
+}
+
 
 /**
  * @}
@@ -426,8 +432,6 @@ check_input:
 */
 void playlist_LastLoop( playlist_t *p_playlist )
 {
-    vlc_object_t *p_obj;
-
     /* If there is an input, kill it */
     while( 1 )
     {
@@ -476,8 +480,26 @@ void playlist_LastLoop( playlist_t *p_playlist )
         sout_DeleteInstance( p_sout );
 #endif
 
+    if( p_playlist->status.p_node &&
+        p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG )
+    {
+         PL_DEBUG( "%s was marked for deletion, deleting",
+                         PLI_NAME( p_playlist->status.p_node  ) );
+         playlist_ItemDelete( p_playlist->status.p_node );
+         p_playlist->status.p_node = NULL;
+    }
+    if( p_playlist->status.p_item &&
+        p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG )
+    {
+         PL_DEBUG( "%s was marked for deletion, deleting",
+                         PLI_NAME( p_playlist->status.p_item  ) );
+         playlist_ItemDelete( p_playlist->status.p_item );
+         p_playlist->status.p_item = NULL;
+    }
+
     /* Core should have terminated all SDs before the playlist */
-    assert( p_playlist->i_sds == 0 );
+    /* TODO: It fails to do so when not playing anything -- Courmisch */
+    playlist_ServicesDiscoveryKillAll( p_playlist );
     playlist_MLDump( p_playlist );
 
     PL_LOCK;
@@ -580,6 +602,13 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }
 
@@ -661,6 +690,13 @@ void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }
 
@@ -686,8 +722,6 @@ static void VariablesInit( playlist_t *p_playlist )
     val.i_int = -1;
     var_Set( p_playlist, "playlist-current", val );
 
-    var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL );
-
     var_Create( p_playlist, "activity", VLC_VAR_INTEGER );
     var_SetInteger( p_playlist, "activity", 0 );