aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-03 21:02:54 +0100
committerMax Kellermann <max@duempel.org>2009-11-03 21:02:54 +0100
commit98150f503a808f4bb0d7be343f1a231a4c8ff0dc (patch)
treee5d8ee4ec2d67a621b6078922e6813fc8505ddf2
parent6c78c21fb80d101fc2ddcebe9b5dcff3463fadc4 (diff)
downloadmpd-98150f503a808f4bb0d7be343f1a231a4c8ff0dc.tar.gz
mpd-98150f503a808f4bb0d7be343f1a231a4c8ff0dc.tar.xz
mpd-98150f503a808f4bb0d7be343f1a231a4c8ff0dc.zip
player_thread: lock inside player_wait_for_decoder()
Lock the player_control object when modifying its attributes.
Diffstat (limited to '')
-rw-r--r--src/player_thread.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index e6c7ea761..91b373380 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -175,6 +175,11 @@ player_wait_for_decoder(struct player *player)
{
struct decoder_control *dc = player->dc;
+ assert(player->queued);
+ assert(pc.next_song != NULL);
+
+ player->queued = false;
+
if (decoder_lock_has_failed(dc)) {
player_lock();
pc.errored_song = dc->song;
@@ -182,23 +187,28 @@ player_wait_for_decoder(struct player *player)
pc.next_song = NULL;
player_unlock();
- player->queued = false;
return false;
}
+ player->song = pc.next_song;
+ player->elapsed_time = 0.0;
+
+ /* set the "starting" flag, which will be cleared by
+ player_check_decoder_startup() */
+ player->decoder_starting = true;
+
+ player_lock();
+
+ /* update player_control's song information */
pc.total_time = pc.next_song->tag != NULL
? pc.next_song->tag->time : 0;
pc.bit_rate = 0;
audio_format_clear(&pc.audio_format);
- player->song = pc.next_song;
+ /* clear the queued song */
pc.next_song = NULL;
- player->queued = false;
- player->elapsed_time = 0.0;
- /* set the "starting" flag, which will be cleared by
- player_check_decoder_startup() */
- player->decoder_starting = true;
+ player_unlock();
/* call syncPlaylistWithQueue() in the main thread */
event_pipe_emit(PIPE_EVENT_PLAYLIST);