diff options
author | Max Kellermann <max@musicpd.org> | 2018-09-23 17:15:08 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-09-23 17:17:57 +0200 |
commit | 0e0bc7976fa2431699f01cadbc2dc486ddf7bd38 (patch) | |
tree | df4f0ae119fa662bd4688c1d4ca07d5ff440ef89 /src/queue | |
parent | 8c638c50a31b8931acded3ddf6300420ce6e91f6 (diff) |
player/Control: add LockGetSyncInfo()
Diffstat (limited to 'src/queue')
-rw-r--r-- | src/queue/Playlist.cxx | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/queue/Playlist.cxx b/src/queue/Playlist.cxx index 358cbee1a..dabeac5f2 100644 --- a/src/queue/Playlist.cxx +++ b/src/queue/Playlist.cxx @@ -91,7 +91,7 @@ playlist::SongStarted() inline void playlist::QueuedSongStarted(PlayerControl &pc) { - assert(!pc.HasNextSong()); + assert(!pc.LockGetSyncInfo().has_next_song); assert(queued >= -1); assert(current >= 0); @@ -195,12 +195,9 @@ playlist::SyncWithPlayer(PlayerControl &pc) playing anymore; ignore the event */ return; - pc.Lock(); - const PlayerState pc_state = pc.GetState(); - bool pc_has_next_song = pc.HasNextSong(); - pc.Unlock(); + const auto i = pc.LockGetSyncInfo(); - if (pc_state == PlayerState::STOP) + if (i.state == PlayerState::STOP) /* the player thread has stopped: check if playback should be restarted with the next song. That can happen if the playlist isn't filling the queue fast @@ -209,16 +206,12 @@ playlist::SyncWithPlayer(PlayerControl &pc) else { /* check if the player thread has already started playing the queued song */ - if (!pc_has_next_song && queued != -1) + if (!i.has_next_song && queued != -1) QueuedSongStarted(pc); - pc.Lock(); - pc_has_next_song = pc.HasNextSong(); - pc.Unlock(); - /* make sure the queued song is always set (if possible) */ - if (!pc_has_next_song && queued < 0) + if (!pc.LockGetSyncInfo().has_next_song && queued < 0) UpdateQueuedSong(pc, nullptr); } } |