- /* close all remaining vout */
- while( ( p_obj = vlc_object_find( p_playlist,
- VLC_OBJECT_VOUT, FIND_CHILD ) ) )
- {
- vlc_object_detach( p_obj );
- vlc_object_release( p_obj );
- vout_Destroy( (vout_thread_t *)p_obj );
- }
+ /* Core should have terminated all SDs before the playlist */
+ /* TODO: It fails to do so when not playing anything -- Courmisch */
+ playlist_ServicesDiscoveryKillAll( p_playlist );
+ playlist_MLDump( p_playlist );
+
+ vlc_object_kill( p_playlist->p_preparse );
+ vlc_thread_join( p_playlist->p_preparse );
+ vlc_object_kill( p_playlist->p_fetcher );
+ vlc_thread_join( p_playlist->p_fetcher );
+
+ PL_LOCK;
+
+ /* Release the current node */
+ set_current_status_node( p_playlist, NULL );
+
+ /* Release the current item */
+ set_current_status_item( p_playlist, NULL );
+
+ FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
+ free( p_del->pp_children );
+ vlc_gc_decref( p_del->p_input );
+ free( p_del );
+ FOREACH_END();
+ ARRAY_RESET( p_playlist->all_items );
+ FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->items_to_delete )
+ free( p_del->pp_children );
+ vlc_gc_decref( p_del->p_input );
+ free( p_del );
+ FOREACH_END();
+ ARRAY_RESET( p_playlist->items_to_delete );
+
+ ARRAY_RESET( p_playlist->items );
+ ARRAY_RESET( p_playlist->current );
+
+ PL_UNLOCK;