# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <assert.h>
+#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_sout.h>
#include <vlc_playlist.h>
* \param p_playlist the playlist object
* \return nothing
*/
-void playlist_Destroy( playlist_t *p_playlist )
-{
- /* XXX: should go in the playlist destructor */
- var_Destroy( p_playlist, "intf-change" );
- var_Destroy( p_playlist, "item-change" );
- var_Destroy( p_playlist, "playlist-current" );
- var_Destroy( p_playlist, "intf-popupmenu" );
- var_Destroy( p_playlist, "intf-show" );
- var_Destroy( p_playlist, "play-and-stop" );
- var_Destroy( p_playlist, "play-and-exit" );
- var_Destroy( p_playlist, "random" );
- var_Destroy( p_playlist, "repeat" );
- var_Destroy( p_playlist, "loop" );
- var_Destroy( p_playlist, "activity" );
-
- vlc_object_release( p_playlist );
-}
static void playlist_Destructor( vlc_object_t * p_this )
{
playlist_t * p_playlist = (playlist_t *)p_this;
- // Kill preparser
if( p_playlist->p_preparse )
- {
vlc_object_release( p_playlist->p_preparse );
- }
- // Kill meta fetcher
if( p_playlist->p_fetcher )
- {
vlc_object_release( p_playlist->p_fetcher );
- }
}
/* Destroy remaining objects */
msg_Dbg( p_playlist, "garbage collector destroying 1 vout" );
vlc_object_detach( p_obj );
vlc_object_release( p_obj );
- vout_Destroy( (vout_thread_t *)p_obj );
+ vlc_object_release( (vout_thread_t *)p_obj );
}
#ifdef ENABLE_SOUT
while( ( p_obj = vlc_object_find( p_playlist, VLC_OBJECT_SOUT,
{
int i_activity;
input_thread_t *p_input;
+ sout_instance_t **pp_sout =
+ &libvlc_priv(p_playlist->p_libvlc)->p_sout;
+
PL_DEBUG( "dead input" );
p_input = p_playlist->p_input;
p_playlist->p_input = NULL;
+ assert( *pp_sout == NULL );
+ if( var_CreateGetBool( p_input, "sout-keep" ) )
+ *pp_sout = input_DetachSout( p_input );
/* Release the playlist lock, because we may get stuck
* in vlc_object_release() for some time. */
p_playlist->p_input = NULL;
PL_UNLOCK;
+ /* sout-keep: no need to anything here.
+ * The last input will destroy its sout, if any, by itself */
+
/* Destroy input */
vlc_object_release( p_input );
continue;
}
#ifdef ENABLE_SOUT
- /* close all remaining sout */
- while( ( p_obj = vlc_object_find( p_playlist,
- VLC_OBJECT_SOUT, FIND_CHILD ) ) )
- {
- vlc_object_detach( p_obj );
- vlc_object_release( p_obj );
- sout_DeleteInstance( (sout_instance_t*)p_obj );
- }
+ /* close the remaining sout-keep (if there was no input atm) */
+ sout_instance_t *p_sout = libvlc_priv (p_playlist->p_libvlc)->p_sout;
+ if (p_sout)
+ sout_DeleteInstance( p_sout );
#endif
/* close all remaining vout */
{
vlc_object_detach( p_obj );
vlc_object_release( p_obj );
- vout_Destroy( (vout_thread_t *)p_obj );
+ vlc_object_release( (vout_thread_t *)p_obj );
}
while( p_playlist->i_sds )
input_item_t *p_current;
int i_activity;
- while( !p_playlist->b_die )
+ vlc_object_lock( p_obj );
+
+ while( vlc_object_alive( p_obj ) )
{
- vlc_object_lock( p_obj );
- while( p_obj->i_waiting == 0 )
+ if( p_obj->i_waiting == 0 )
{
- if( vlc_object_wait( p_obj ) || p_playlist->b_die )
- {
- vlc_object_unlock( p_obj );
- return;
- }
+ vlc_object_wait( p_obj );
+ continue;
}
p_current = p_obj->pp_waiting[0];
vlc_object_unlock( p_obj );
/* Sleep at least 1ms */
msleep( (i_activity+1) * 1000 );
+ vlc_object_lock( p_obj );
}
+ vlc_object_unlock( p_obj );
}
/**
input_item_t *p_item;
int i_activity;
- while( !p_playlist->b_die )
+ vlc_mutex_lock( &p_obj->object_lock );
+
+ while( vlc_object_alive( p_obj ) )
{
- vlc_mutex_lock( &p_obj->object_lock );
- while( p_obj->i_waiting == 0 )
+ if( p_obj->i_waiting == 0 )
{
- vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
- if( p_playlist->b_die )
- {
- vlc_mutex_unlock( &p_obj->object_lock );
- return;
- }
+ vlc_object_wait( p_obj );
+ continue;
}
p_item = p_obj->pp_waiting[0];
vlc_object_unlock( p_obj );
/* Sleep at least 1ms */
msleep( (i_activity+1) * 1000 );
+ vlc_mutex_lock( &p_obj->object_lock );
}
+ vlc_mutex_unlock( &p_obj->object_lock );
}
static void VariablesInit( playlist_t *p_playlist )
var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL );
- var_Create( p_playlist, "intf-show", VLC_VAR_BOOL );
- val.b_bool = true;
- var_Set( p_playlist, "intf-show", val );
-
var_Create( p_playlist, "activity", VLC_VAR_INTEGER );
var_SetInteger( p_playlist, "activity", 0 );