Commit 583d3c85 authored by Laurent Aimar's avatar Laurent Aimar

No functionnal changes.

(Moved around playlist code)
parent d2ce7fe9
This diff is collapsed.
...@@ -181,61 +181,6 @@ static void playlist_Destructor( vlc_object_t * p_this ) ...@@ -181,61 +181,6 @@ static void playlist_Destructor( vlc_object_t * p_this )
msg_Err( p_this, "Destroyed" ); msg_Err( p_this, "Destroyed" );
} }
/* Input Callback */
static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
playlist_t *p_playlist = p_data;
if( newval.i_int != INPUT_EVENT_STATE &&
newval.i_int != INPUT_EVENT_ES )
return VLC_SUCCESS;
PL_LOCK;
vlc_object_signal_unlocked( p_playlist );
PL_UNLOCK;
return VLC_SUCCESS;
}
/* Internals */
void playlist_release_current_input( playlist_t * p_playlist )
{
PL_ASSERT_LOCKED;
if( !pl_priv(p_playlist)->p_input ) return;
input_thread_t * p_input = pl_priv(p_playlist)->p_input;
var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
pl_priv(p_playlist)->p_input = NULL;
/* Release the playlist lock, because we may get stuck
* in vlc_object_release() for some time. */
PL_UNLOCK;
vlc_thread_join( p_input );
vlc_object_release( p_input );
PL_LOCK;
}
void playlist_set_current_input(
playlist_t * p_playlist, input_thread_t * p_input )
{
PL_ASSERT_LOCKED;
playlist_release_current_input( p_playlist );
if( p_input )
{
vlc_object_hold( p_input );
pl_priv(p_playlist)->p_input = p_input;
var_AddCallback( p_input, "intf-event", InputEvent, p_playlist );
}
}
/** Get current playing input. /** Get current playing input.
*/ */
input_thread_t * playlist_CurrentInput( playlist_t * p_playlist ) input_thread_t * playlist_CurrentInput( playlist_t * p_playlist )
...@@ -298,115 +243,6 @@ void set_current_status_node( playlist_t * p_playlist, ...@@ -298,115 +243,6 @@ void set_current_status_node( playlist_t * p_playlist,
pl_priv(p_playlist)->status.p_node = p_node; pl_priv(p_playlist)->status.p_node = p_node;
} }
/**
* Main loop
*
* Main loop for the playlist. It should be entered with the
* playlist lock (otherwise input event may be lost)
* \param p_playlist the playlist object
* \return nothing
*/
void playlist_MainLoop( playlist_t *p_playlist )
{
bool b_playexit = var_GetBool( p_playlist, "play-and-exit" );
PL_ASSERT_LOCKED;
if( pl_priv(p_playlist)->b_reset_currently_playing &&
mdate() - pl_priv(p_playlist)->last_rebuild_date > 30000 ) // 30 ms
{
ResetCurrentlyPlaying( p_playlist, var_GetBool( p_playlist, "random" ),
get_current_status_item( p_playlist ) );
pl_priv(p_playlist)->last_rebuild_date = mdate();
}
check_input:
/* If there is an input, check that it doesn't need to die. */
if( pl_priv(p_playlist)->p_input )
{
input_thread_t *p_input = pl_priv(p_playlist)->p_input;
if( pl_priv(p_playlist)->request.b_request && !p_input->b_die )
{
PL_DEBUG( "incoming request - stopping current input" );
input_StopThread( p_input );
}
/* This input is dead. Remove it ! */
if( p_input->b_dead )
{
sout_instance_t **pp_sout = &pl_priv(p_playlist)->p_sout;
PL_DEBUG( "dead input" );
assert( *pp_sout == NULL );
if( var_CreateGetBool( p_input, "sout-keep" ) )
*pp_sout = input_DetachSout( p_input );
/* Destroy input */
playlist_release_current_input( p_playlist );
int i_activity= var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity",
i_activity - DEFAULT_INPUT_ACTIVITY );
goto check_input;
}
/* This input is dying, let it do */
else if( p_input->b_die )
{
PL_DEBUG( "dying input" );
PL_UNLOCK;
msleep( INTF_IDLE_SLEEP );
PL_LOCK;
goto check_input;
}
/* This input has finished, ask it to die ! */
else if( p_input->b_error || p_input->b_eof )
{
PL_DEBUG( "finished input" );
input_StopThread( p_input );
/* No need to wait here, we'll wait in the p_input->b_die case */
goto check_input;
}
}
else
{
/* No input. Several cases
* - No request, running status -> start new item
* - No request, stopped status -> collect garbage
* - Request, running requested -> start new item
* - Request, stopped requested -> collect garbage
*/
int i_status = pl_priv(p_playlist)->request.b_request ?
pl_priv(p_playlist)->request.i_status : pl_priv(p_playlist)->status.i_status;
if( i_status != PLAYLIST_STOPPED )
{
msg_Dbg( p_playlist, "starting new item" );
playlist_item_t *p_item = playlist_NextItem( p_playlist );
if( p_item == NULL )
{
msg_Dbg( p_playlist, "nothing to play" );
pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
if( b_playexit == true )
{
msg_Info( p_playlist, "end of playlist, exiting" );
vlc_object_kill( p_playlist->p_libvlc );
}
return;
}
playlist_PlayItem( p_playlist, p_item );
/* playlist_PlayItem loose input event, we need to recheck */
goto check_input;
}
else
{
pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
}
}
}
static void VariablesInit( playlist_t *p_playlist ) static void VariablesInit( playlist_t *p_playlist )
{ {
vlc_value_t val; vlc_value_t val;
......
...@@ -109,19 +109,11 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist, ...@@ -109,19 +109,11 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
input_item_t *p_input ); input_item_t *p_input );
/* Engine */ /* Engine */
void playlist_MainLoop( playlist_t * );
void ResetCurrentlyPlaying( playlist_t *, bool, playlist_item_t * );
playlist_item_t * get_current_status_item( playlist_t * p_playlist); playlist_item_t * get_current_status_item( playlist_t * p_playlist);
playlist_item_t * get_current_status_node( playlist_t * p_playlist ); playlist_item_t * get_current_status_node( playlist_t * p_playlist );
void set_current_status_item( playlist_t *, playlist_item_t * ); void set_current_status_item( playlist_t *, playlist_item_t * );
void set_current_status_node( playlist_t *, playlist_item_t * ); void set_current_status_node( playlist_t *, playlist_item_t * );
/* Control */
playlist_item_t * playlist_NextItem ( playlist_t * );
int playlist_PlayItem ( playlist_t *, playlist_item_t * );
/* Load/Save */ /* Load/Save */
int playlist_MLLoad( playlist_t *p_playlist ); int playlist_MLLoad( playlist_t *p_playlist );
int playlist_MLDump( playlist_t *p_playlist ); int playlist_MLDump( playlist_t *p_playlist );
...@@ -145,11 +137,6 @@ int playlist_DeleteFromInputInParent( playlist_t *, int, playlist_item_t *, bool ...@@ -145,11 +137,6 @@ int playlist_DeleteFromInputInParent( playlist_t *, int, playlist_item_t *, bool
int playlist_DeleteFromItemId( playlist_t*, int ); int playlist_DeleteFromItemId( playlist_t*, int );
int playlist_ItemRelease( playlist_item_t * ); int playlist_ItemRelease( playlist_item_t * );
void playlist_release_current_input( playlist_t * p_playlist );
void playlist_set_current_input(
playlist_t * p_playlist, input_thread_t * p_input );
/** /**
* @} * @}
*/ */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment