aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlayerControl.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-21 23:22:16 +0200
committerMax Kellermann <max@duempel.org>2013-10-22 00:02:21 +0200
commit2f43e4bc668f04a222500ab34536ef00149e209f (patch)
tree260593ec865b3f13b8cb11f86a86d23bb10ad2ad /src/PlayerControl.hxx
parentf8c23488c942a89df74b231307281cf1919fab61 (diff)
downloadmpd-2f43e4bc668f04a222500ab34536ef00149e209f.tar.gz
mpd-2f43e4bc668f04a222500ab34536ef00149e209f.tar.xz
mpd-2f43e4bc668f04a222500ab34536ef00149e209f.zip
Playlist: copy stream tags from the PlayerThread
Finally restores an important feature that has been broken for several months when the PlayerThread started working with Song copies instead of pointers to the Queue's Song instances (commit e96779d).
Diffstat (limited to 'src/PlayerControl.hxx')
-rw-r--r--src/PlayerControl.hxx43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/PlayerControl.hxx b/src/PlayerControl.hxx
index b2b2087e2..bdfc10fec 100644
--- a/src/PlayerControl.hxx
+++ b/src/PlayerControl.hxx
@@ -100,7 +100,7 @@ struct player_control {
Thread thread;
/**
- * This lock protects #command, #state, #error.
+ * This lock protects #command, #state, #error, #tagged_song.
*/
mutable Mutex mutex;
@@ -129,6 +129,18 @@ struct player_control {
*/
Error error;
+ /**
+ * A copy of the current #Song after its tags have been
+ * updated by the decoder (for example, a radio stream that
+ * has sent a new tag after switching to the next song). This
+ * shall be used by the GlobalEvents::TAG handler to update
+ * the current #Song in the queue.
+ *
+ * Protected by #mutex. Set by the PlayerThread and consumed
+ * by the main thread.
+ */
+ Song *tagged_song;
+
uint16_t bit_rate;
AudioFormat audio_format;
float total_time;
@@ -356,6 +368,35 @@ public:
return error_type;
}
+ /**
+ * Set the #tagged_song attribute to a newly allocated copy of
+ * the given #Song. Locks and unlocks the object.
+ */
+ void LockSetTaggedSong(const Song &song);
+
+ void ClearTaggedSong();
+
+ /**
+ * Read and clear the #tagged_song attribute.
+ *
+ * Caller must lock the object.
+ */
+ Song *ReadTaggedSong() {
+ Song *result = tagged_song;
+ tagged_song = nullptr;
+ return result;
+ }
+
+ /**
+ * Like ReadTaggedSong(), but locks and unlocks the object.
+ */
+ Song *LockReadTaggedSong() {
+ Lock();
+ Song *result = ReadTaggedSong();
+ Unlock();
+ return result;
+ }
+
void Stop();
void UpdateAudio();