aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlayerControl.hxx
diff options
context:
space:
mode:
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();