Commit 64600f1f authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* src/playlist/playlist.c: Don't do any playlist actions if there are no items in the playlist.

 * REST: remove code duplication in some places. there might be more locations.
parent 11981e96
...@@ -294,13 +294,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -294,13 +294,8 @@ static void Run( intf_thread_t *p_intf )
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{ {
vlc_mutex_lock( &p_playlist->object_lock ); playlist_Play( p_playlist );
if( p_playlist->i_size ) vlc_object_release( p_playlist );
{
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
} }
} }
else if( i_action == ACTIONID_PLAY_PAUSE ) else if( i_action == ACTIONID_PLAY_PAUSE )
......
...@@ -487,19 +487,18 @@ unsigned int VLCModifiersToCocoa( unsigned int i_key ) ...@@ -487,19 +487,18 @@ unsigned int VLCModifiersToCocoa( unsigned int i_key )
[self setSubmenusEnabled: FALSE]; [self setSubmenusEnabled: FALSE];
[self manageVolumeSlider]; [self manageVolumeSlider];
/* Check if we need to start playing */ p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_intf->b_play )
{
p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{
/* Check if we need to start playing */
if( p_intf->b_play )
{ {
playlist_Play( p_playlist ); playlist_Play( p_playlist );
vlc_object_release( p_playlist );
} }
[o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
vlc_object_release( p_playlist );
} }
[o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool )];
} }
- (void)initStrings - (void)initStrings
......
...@@ -317,16 +317,7 @@ bool Instance::OnInit() ...@@ -317,16 +317,7 @@ bool Instance::OnInit()
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist ) if( p_playlist )
{ {
vlc_mutex_lock( &p_playlist->object_lock ); playlist_Play( p_playlist );
if( p_playlist->i_size )
{
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play( p_playlist );
}
else
{
vlc_mutex_unlock( &p_playlist->object_lock );
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
} }
......
...@@ -156,8 +156,9 @@ void playlist_Destroy( playlist_t * p_playlist ) ...@@ -156,8 +156,9 @@ void playlist_Destroy( playlist_t * p_playlist )
/** /**
* Do a playlist action * Do a playlist action.
* *
* If there is something in the playlist then you can do playlist actions.
* \param p_playlist the playlist to do the command on * \param p_playlist the playlist to do the command on
* \param i_command the command to do * \param i_command the command to do
* \param i_arg the argument to the command. See playlist_command_t for details * \param i_arg the argument to the command. See playlist_command_t for details
...@@ -169,6 +170,12 @@ void playlist_Command( playlist_t * p_playlist, playlist_command_t i_command, ...@@ -169,6 +170,12 @@ void playlist_Command( playlist_t * p_playlist, playlist_command_t i_command,
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
if( p_playlist->i_size <= 0 )
{
vlc_mutex_unlock( &p_playlist->object_lock );
return;
}
switch( i_command ) switch( i_command )
{ {
case PLAYLIST_STOP: case PLAYLIST_STOP:
......
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