Commit 3decf123 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: remove status.i_status

parent 8fed9f21
...@@ -87,39 +87,30 @@ static void playlist_vaControl( playlist_t *p_playlist, int i_query, va_list arg ...@@ -87,39 +87,30 @@ static void playlist_vaControl( playlist_t *p_playlist, int i_query, va_list arg
} }
case PLAYLIST_PLAY: case PLAYLIST_PLAY:
if( pl_priv(p_playlist)->p_input ) if( pl_priv(p_playlist)->p_input == NULL )
{
pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
break;
}
else
{ {
pl_priv(p_playlist)->request.b_request = true; pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist ); pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist ); pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
pl_priv(p_playlist)->request.i_skip = 0; pl_priv(p_playlist)->request.i_skip = 0;
} }
else
var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
break; break;
case PLAYLIST_TOGGLE_PAUSE: case PLAYLIST_TOGGLE_PAUSE:
if( !pl_priv(p_playlist)->p_input ) if( pl_priv(p_playlist)->p_input == NULL )
{ /* FIXME: is this really useful without input? */ {
pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED; pl_priv(p_playlist)->request.b_request = true;
/* return without notifying the playlist thread as there is nothing to do */ pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
return; pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
pl_priv(p_playlist)->request.i_skip = 0;
} }
else
if( var_GetInteger( pl_priv(p_playlist)->p_input, "state" ) == PAUSE_S ) if( var_GetInteger( pl_priv(p_playlist)->p_input, "state" ) == PAUSE_S )
{
pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S ); var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
}
else else
{
pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED;
var_SetInteger( pl_priv(p_playlist)->p_input, "state", PAUSE_S ); var_SetInteger( pl_priv(p_playlist)->p_input, "state", PAUSE_S );
}
break; break;
case PLAYLIST_SKIP: case PLAYLIST_SKIP:
......
...@@ -261,7 +261,6 @@ playlist_t *playlist_Create( vlc_object_t *p_parent ) ...@@ -261,7 +261,6 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
pl_priv(p_playlist)->status.p_item = NULL; pl_priv(p_playlist)->status.p_item = NULL;
pl_priv(p_playlist)->status.p_node = p_playlist->p_playing; pl_priv(p_playlist)->status.p_node = p_playlist->p_playing;
pl_priv(p_playlist)->request.b_request = false; pl_priv(p_playlist)->request.b_request = false;
pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
if (ml != NULL) if (ml != NULL)
playlist_MLLoad( p_playlist ); playlist_MLLoad( p_playlist );
...@@ -496,8 +495,14 @@ playlist_item_t * playlist_CurrentPlayingItem( playlist_t * p_playlist ) ...@@ -496,8 +495,14 @@ playlist_item_t * playlist_CurrentPlayingItem( playlist_t * p_playlist )
int playlist_Status( playlist_t * p_playlist ) int playlist_Status( playlist_t * p_playlist )
{ {
input_thread_t *p_input = pl_priv(p_playlist)->p_input;
PL_ASSERT_LOCKED; PL_ASSERT_LOCKED;
return pl_priv(p_playlist)->status.i_status; if( p_input == NULL )
return PLAYLIST_STOPPED;
if( var_GetInteger( p_input, "state" ) == PAUSE_S )
return PLAYLIST_PAUSED;
return PLAYLIST_RUNNING;
} }
...@@ -61,7 +61,6 @@ typedef struct playlist_private_t ...@@ -61,7 +61,6 @@ typedef struct playlist_private_t
struct { struct {
/* Current status. These fields are readonly, only the playlist /* Current status. These fields are readonly, only the playlist
* main loop can touch it*/ * main loop can touch it*/
playlist_status_t i_status; /**< Current status of playlist */
playlist_item_t * p_item; /**< Currently playing/active item */ playlist_item_t * p_item; /**< Currently playing/active item */
playlist_item_t * p_node; /**< Current node to play from */ playlist_item_t * p_node; /**< Current node to play from */
} status; } status;
......
...@@ -190,9 +190,8 @@ void ResetCurrentlyPlaying( playlist_t *p_playlist, ...@@ -190,9 +190,8 @@ void ResetCurrentlyPlaying( playlist_t *p_playlist,
* *
* \param p_playlist the playlist object * \param p_playlist the playlist object
* \param p_item the item to play * \param p_item the item to play
* \return nothing
*/ */
static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) static bool PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
{ {
playlist_private_t *p_sys = pl_priv(p_playlist); playlist_private_t *p_sys = pl_priv(p_playlist);
input_item_t *p_input = p_item->p_input; input_item_t *p_input = p_item->p_input;
...@@ -203,9 +202,6 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) ...@@ -203,9 +202,6 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
p_item->i_nb_played++; p_item->i_nb_played++;
set_current_status_item( p_playlist, p_item ); set_current_status_item( p_playlist, p_item );
p_sys->status.i_status = PLAYLIST_RUNNING;
assert( p_sys->p_input == NULL ); assert( p_sys->p_input == NULL );
PL_UNLOCK; PL_UNLOCK;
...@@ -243,6 +239,7 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) ...@@ -243,6 +239,7 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
PL_LOCK; PL_LOCK;
p_sys->p_input = p_input_thread; p_sys->p_input = p_input_thread;
return p_input_thread != NULL;
} }
/** /**
...@@ -268,7 +265,14 @@ static playlist_item_t *NextItem( playlist_t *p_playlist ) ...@@ -268,7 +265,14 @@ static playlist_item_t *NextItem( playlist_t *p_playlist )
/* Start the real work */ /* Start the real work */
if( p_sys->request.b_request ) if( p_sys->request.b_request )
{ {
/* Clear the request */
p_sys->request.b_request = false;
p_new = p_sys->request.p_item; p_new = p_sys->request.p_item;
if( p_new == NULL && p_sys->request.p_node == NULL )
return NULL; /* Stop request! */
int i_skip = p_sys->request.i_skip; int i_skip = p_sys->request.i_skip;
PL_DEBUG( "processing request item: %s, node: %s, skip: %i", PL_DEBUG( "processing request item: %s, node: %s, skip: %i",
PLI_NAME( p_sys->request.p_item ), PLI_NAME( p_sys->request.p_item ),
...@@ -351,8 +355,6 @@ static playlist_item_t *NextItem( playlist_t *p_playlist ) ...@@ -351,8 +355,6 @@ static playlist_item_t *NextItem( playlist_t *p_playlist )
p_new = ARRAY_VAL( p_playlist->current, p_new = ARRAY_VAL( p_playlist->current,
p_playlist->i_current_index ); p_playlist->i_current_index );
} }
/* Clear the request */
p_sys->request.b_request = false;
} }
/* "Automatic" item change ( next ) */ /* "Automatic" item change ( next ) */
else else
...@@ -469,41 +471,15 @@ static void LoopInput( playlist_t *p_playlist ) ...@@ -469,41 +471,15 @@ static void LoopInput( playlist_t *p_playlist )
vlc_cond_wait( &p_sys->signal, &p_sys->lock ); vlc_cond_wait( &p_sys->signal, &p_sys->lock );
} }
static void LoopRequest( playlist_t *p_playlist, int i_status ) static bool Next( playlist_t *p_playlist )
{ {
playlist_private_t *p_sys = pl_priv(p_playlist);
assert( !p_sys->p_input );
/* 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
*/
if( i_status == PLAYLIST_STOPPED )
{
p_sys->status.i_status = PLAYLIST_STOPPED;
vlc_cond_wait( &p_sys->signal, &p_sys->lock );
return;
}
playlist_item_t *p_item = NextItem( p_playlist ); playlist_item_t *p_item = NextItem( p_playlist );
if( p_item ) if( p_item == NULL )
{ return false;
msg_Dbg( p_playlist, "starting playback of the new playlist item" );
ResyncCurrentIndex( p_playlist, p_item );
PlayItem( p_playlist, p_item );
return;
}
msg_Dbg( p_playlist, "nothing to play" );
p_sys->status.i_status = PLAYLIST_STOPPED;
if( var_InheritBool( p_playlist, "play-and-exit" ) ) msg_Dbg( p_playlist, "starting playback of new item" );
{ ResyncCurrentIndex( p_playlist, p_item );
msg_Info( p_playlist, "end of playlist, exiting" ); return PlayItem( p_playlist, p_item );
libvlc_Quit( p_playlist->p_libvlc );
}
} }
/** /**
...@@ -515,32 +491,41 @@ static void *Thread ( void *data ) ...@@ -515,32 +491,41 @@ static void *Thread ( void *data )
playlist_private_t *p_sys = pl_priv(p_playlist); playlist_private_t *p_sys = pl_priv(p_playlist);
PL_LOCK; PL_LOCK;
for( ;; ) while( !p_sys->killed )
{ {
while( p_sys->p_input != NULL ) /* Playlist in stopped state */
LoopInput( p_playlist ); assert(p_sys->p_input == NULL);
if( !p_sys->request.b_request )
{
vlc_cond_wait( &p_sys->signal, &p_sys->lock );
continue;
}
if( p_sys->killed ) while( !p_sys->killed && Next( p_playlist ) )
break; /* THE END */ { /* Playlist in running state */
assert(p_sys->p_input != NULL);
int status = p_sys->status.i_status; do
if( p_sys->request.b_request ) LoopInput( p_playlist );
status = (p_sys->request.p_item || p_sys->request.p_node) while( p_sys->p_input != NULL );
? PLAYLIST_RUNNING : PLAYLIST_STOPPED; }
/* Destroy any video display if the playlist is supposed to stop */ msg_Dbg( p_playlist, "nothing to play" );
if( status == PLAYLIST_STOPPED if( var_InheritBool( p_playlist, "play-and-exit" ) )
&& input_resource_HasVout( p_sys->p_input_resource ) ) {
msg_Info( p_playlist, "end of playlist, exiting" );
libvlc_Quit( p_playlist->p_libvlc );
}
/* Destroy any video display now (XXX: ugly hack) */
if( input_resource_HasVout( p_sys->p_input_resource ) )
{ {
PL_UNLOCK; /* Mind: NO LOCKS while manipulating input resources! */ PL_UNLOCK; /* Mind: NO LOCKS while manipulating input resources! */
input_resource_TerminateVout( p_sys->p_input_resource ); input_resource_TerminateVout( p_sys->p_input_resource );
PL_LOCK; PL_LOCK;
continue; /* lost lock = lost state */
} }
LoopRequest( p_playlist, status );
} }
p_sys->status.i_status = PLAYLIST_STOPPED;
PL_UNLOCK; PL_UNLOCK;
input_resource_Terminate( p_sys->p_input_resource ); input_resource_Terminate( p_sys->p_input_resource );
......
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