Commit 91c1edba authored by Laurent Aimar's avatar Laurent Aimar

Removed an unused lock.

Fixed a playlist race condition on input events.

The playlist was loosing state events from input. And thus it may not
always be able to detect (by itself) the end of a stream (It happens
easily with small playlist files).
parent 2f05f475
...@@ -203,8 +203,6 @@ struct playlist_t ...@@ -203,8 +203,6 @@ struct playlist_t
playlist_preparse_t *p_preparse; /**< Preparser object */ playlist_preparse_t *p_preparse; /**< Preparser object */
playlist_fetcher_t *p_fetcher;/**< Meta and art fetcher object */ playlist_fetcher_t *p_fetcher;/**< Meta and art fetcher object */
vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */
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*/
......
...@@ -76,7 +76,6 @@ playlist_t * playlist_Create( vlc_object_t *p_parent ) ...@@ -76,7 +76,6 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
VariablesInit( p_playlist ); VariablesInit( p_playlist );
/* Initialise data structures */ /* Initialise data structures */
vlc_mutex_init( &p_playlist->gc_lock );
p_playlist->i_last_playlist_id = 0; p_playlist->i_last_playlist_id = 0;
p_playlist->p_input = NULL; p_playlist->p_input = NULL;
...@@ -199,9 +198,7 @@ static void ObjectGarbageCollector( playlist_t *p_playlist, bool b_force ) ...@@ -199,9 +198,7 @@ static void ObjectGarbageCollector( playlist_t *p_playlist, bool b_force )
return; return;
} }
vlc_mutex_lock( &p_playlist->gc_lock );
p_playlist->b_cant_sleep = false; p_playlist->b_cant_sleep = false;
vlc_mutex_unlock( &p_playlist->gc_lock );
} }
/* Input Callback */ /* Input Callback */
...@@ -330,7 +327,8 @@ void set_current_status_node( playlist_t * p_playlist, ...@@ -330,7 +327,8 @@ void set_current_status_node( playlist_t * p_playlist,
/** /**
* Main loop * Main loop
* *
* Main loop for the playlist * 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 * \param p_playlist the playlist object
* \return nothing * \return nothing
*/ */
...@@ -338,7 +336,8 @@ void playlist_MainLoop( playlist_t *p_playlist ) ...@@ -338,7 +336,8 @@ void playlist_MainLoop( playlist_t *p_playlist )
{ {
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
bool b_playexit = var_GetBool( p_playlist, "play-and-exit" ); bool b_playexit = var_GetBool( p_playlist, "play-and-exit" );
PL_LOCK;
PL_ASSERT_LOCKED;
if( p_playlist->b_reset_currently_playing && if( p_playlist->b_reset_currently_playing &&
mdate() - p_playlist->last_rebuild_date > 30000 ) // 30 ms mdate() - p_playlist->last_rebuild_date > 30000 ) // 30 ms
...@@ -406,9 +405,7 @@ check_input: ...@@ -406,9 +405,7 @@ check_input:
} }
else if( p_playlist->p_input->i_state != INIT_S ) else if( p_playlist->p_input->i_state != INIT_S )
{ {
PL_UNLOCK;
ObjectGarbageCollector( p_playlist, false ); ObjectGarbageCollector( p_playlist, false );
PL_LOCK;
} }
} }
else else
...@@ -430,7 +427,6 @@ check_input: ...@@ -430,7 +427,6 @@ check_input:
{ {
msg_Dbg( p_playlist, "nothing to play" ); msg_Dbg( p_playlist, "nothing to play" );
p_playlist->status.i_status = PLAYLIST_STOPPED; p_playlist->status.i_status = PLAYLIST_STOPPED;
PL_UNLOCK;
if( b_playexit == true ) if( b_playexit == true )
{ {
...@@ -441,6 +437,9 @@ check_input: ...@@ -441,6 +437,9 @@ check_input:
return; return;
} }
playlist_PlayItem( p_playlist, p_item ); playlist_PlayItem( p_playlist, p_item );
/* playlist_PlayItem loose input event, we need to recheck */
//if( !p_playlist->b_cant_sleep )
goto check_input;
} }
else else
{ {
...@@ -449,12 +448,9 @@ check_input: ...@@ -449,12 +448,9 @@ check_input:
p_playlist->status.i_status = PLAYLIST_STOPPED; p_playlist->status.i_status = PLAYLIST_STOPPED;
/* Collect garbage */ /* Collect garbage */
PL_UNLOCK;
ObjectGarbageCollector( p_playlist, b_gc_forced ); ObjectGarbageCollector( p_playlist, b_gc_forced );
PL_LOCK;
} }
} }
PL_UNLOCK;
} }
/** /**
......
...@@ -140,9 +140,7 @@ static void RunControlThread ( playlist_t *p_playlist ) ...@@ -140,9 +140,7 @@ static void RunControlThread ( playlist_t *p_playlist )
vlc_object_lock( p_playlist ); vlc_object_lock( p_playlist );
while( vlc_object_alive( p_playlist ) ) while( vlc_object_alive( p_playlist ) )
{ {
PL_UNLOCK;
playlist_MainLoop( p_playlist ); playlist_MainLoop( p_playlist );
PL_LOCK;
/* The playlist lock has been unlocked, so we can't tell if /* The playlist lock has been unlocked, so we can't tell if
* someone has killed us in the meantime. Check now. */ * someone has killed us in the meantime. Check now. */
...@@ -152,9 +150,11 @@ static void RunControlThread ( playlist_t *p_playlist ) ...@@ -152,9 +150,11 @@ static void RunControlThread ( playlist_t *p_playlist )
if( p_playlist->b_cant_sleep ) if( p_playlist->b_cant_sleep )
{ {
/* 100 ms is an acceptable delay for playlist operations */ /* 100 ms is an acceptable delay for playlist operations */
PL_UNLOCK; vlc_object_unlock( p_playlist );
msleep( INTF_IDLE_SLEEP*2 ); msleep( INTF_IDLE_SLEEP*2 );
PL_LOCK;
vlc_object_lock( p_playlist );
} }
else else
{ {
......
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