player_control: protect command, state, error with a mutex
Use GMutex/GCond instead of the notify library. Manually lock the player_control object before accessing the protected attributes. Use the GCond object to notify the player thread and the main thread.
This commit is contained in:
@@ -112,9 +112,7 @@ static void decoder_run_song(const struct song *song, const char *uri)
|
||||
dc.state = DECODE_STATE_START;
|
||||
dc.command = DECODE_COMMAND_NONE;
|
||||
|
||||
decoder_unlock();
|
||||
notify_signal(&pc.notify);
|
||||
decoder_lock();
|
||||
player_signal();
|
||||
|
||||
/* wait for the input stream to become ready; its metadata
|
||||
will be available then */
|
||||
@@ -294,17 +292,13 @@ static gpointer decoder_task(G_GNUC_UNUSED gpointer arg)
|
||||
|
||||
dc.command = DECODE_COMMAND_NONE;
|
||||
|
||||
decoder_unlock();
|
||||
notify_signal(&pc.notify);
|
||||
decoder_lock();
|
||||
player_signal();
|
||||
break;
|
||||
|
||||
case DECODE_COMMAND_STOP:
|
||||
dc.command = DECODE_COMMAND_NONE;
|
||||
|
||||
decoder_unlock();
|
||||
notify_signal(&pc.notify);
|
||||
decoder_lock();
|
||||
player_signal();
|
||||
break;
|
||||
|
||||
case DECODE_COMMAND_NONE:
|
||||
|
||||
Reference in New Issue
Block a user