playlist: protect acess to player state in playlist_sync()

This commit is contained in:
Max Kellermann 2010-06-19 13:15:42 +02:00
parent cff727644d
commit 442b327582

@ -219,7 +219,12 @@ playlist_sync(struct playlist *playlist)
playing anymore; ignore the event */ playing anymore; ignore the event */
return; return;
if (pc_get_state() == PLAYER_STATE_STOP) player_lock();
enum player_state pc_state = pc_get_state();
const struct song *pc_next_song = pc.next_song;
player_unlock();
if (pc_state == PLAYER_STATE_STOP)
/* the player thread has stopped: check if playback /* the player thread has stopped: check if playback
should be restarted with the next song. That can should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast happen if the playlist isn't filling the queue fast
@ -228,7 +233,7 @@ playlist_sync(struct playlist *playlist)
else { else {
/* check if the player thread has already started /* check if the player thread has already started
playing the queued song */ playing the queued song */
if (pc.next_song == NULL && playlist->queued != -1) if (pc_next_song == NULL && playlist->queued != -1)
playlist_song_started(playlist); playlist_song_started(playlist);
/* make sure the queued song is always set (if /* make sure the queued song is always set (if