From 9af470c92dd7dab57740fff266e5fd49f437572d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 26 Nov 2014 08:49:19 +0100 Subject: Playlist: add method SongStarted() Empty currently, but code will be added song. --- src/queue/Playlist.cxx | 10 ++++++++++ src/queue/Playlist.hxx | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/queue/Playlist.cxx b/src/queue/Playlist.cxx index 0dc36f5e7..4419d6e6e 100644 --- a/src/queue/Playlist.cxx +++ b/src/queue/Playlist.cxx @@ -60,6 +60,12 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order) pc.EnqueueSong(new DetachedSong(song)); } +void +playlist::SongStarted() +{ + assert(current >= 0); +} + inline void playlist::QueuedSongStarted(PlayerControl &pc) { @@ -78,6 +84,8 @@ playlist::QueuedSongStarted(PlayerControl &pc) DeleteOrder(pc, old_current); idle_add(IDLE_PLAYER); + + SongStarted(); } const DetachedSong * @@ -152,6 +160,8 @@ playlist::PlayOrder(PlayerControl &pc, int order) pc.Play(new DetachedSong(song)); current = order; + + SongStarted(); } void diff --git a/src/queue/Playlist.hxx b/src/queue/Playlist.hxx index fb75377f0..ab8fbe2d4 100644 --- a/src/queue/Playlist.hxx +++ b/src/queue/Playlist.hxx @@ -134,6 +134,17 @@ protected: */ void OnModified(); + /** + * Called when playback of a new song starts. Unlike + * QueuedSongStarted(), this also gets called when the user + * manually switches to another song. It may be used for + * playlist fixups. + * + * The song being started is specified by the #current + * attribute. + */ + void SongStarted(); + /** * Updates the "queued song". Calculates the next song * according to the current one (if MPD isn't playing, it @@ -152,7 +163,8 @@ protected: /** * Called when the player thread has started playing the - * "queued" song. + * "queued" song, i.e. it has switched from one song to the + * next automatically. */ void QueuedSongStarted(PlayerControl &pc); -- cgit v1.2.3