aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-11 20:46:55 +0100
committerMax Kellermann <max@duempel.org>2008-11-11 20:46:55 +0100
commitacf0d141be9bae98311be9479fc46e77f6f87961 (patch)
tree87e23a8eb9d83483a44d4bce04ed85b1c0784d5c
parent81d2076bcffd78ab8b6cb1bdf13b07d863e977b8 (diff)
downloadmpd-acf0d141be9bae98311be9479fc46e77f6f87961.tar.gz
mpd-acf0d141be9bae98311be9479fc46e77f6f87961.tar.xz
mpd-acf0d141be9bae98311be9479fc46e77f6f87961.zip
playlist: track song metadata changes
When the tag of the current song changes (e.g. a new tag was sent in the stream), update the playlist, so clients pick up the new tag.
Diffstat (limited to '')
-rw-r--r--src/playlist.c21
-rw-r--r--src/playlist.h5
2 files changed, 14 insertions, 12 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 61a0bb56b..0f0e0da6c 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -830,13 +830,8 @@ enum playlist_result playPlaylistById(int id, int stopOnError)
static void syncCurrentPlayerDecodeMetadata(void)
{
- struct song *songPlayer = playerCurrentDecodeSong();
struct song *song;
int songNum;
- char path_max_tmp[MPD_PATH_MAX];
-
- if (!songPlayer)
- return;
if (playlist_state != PLAYLIST_STATE_PLAY)
return;
@@ -844,16 +839,18 @@ static void syncCurrentPlayerDecodeMetadata(void)
songNum = playlist.order[playlist.current];
song = playlist.songs[songNum];
- if (!song_is_file(song) &&
- 0 == strcmp(song_get_url(song, path_max_tmp), songPlayer->url) &&
- !tag_equal(song->tag, songPlayer->tag)) {
- assert(!song_in_database(song));
+ if (song != playlist.prev_song) {
+ /* song change: initialize playlist.prev_{song,tag} */
+
+ playlist.prev_song = song;
+ playlist.prev_tag = song->tag;
+ } else if (song->tag != playlist.prev_tag) {
+ /* tag change: update playlist */
- if (song->tag)
- tag_free(song->tag);
- song->tag = tag_dup(songPlayer->tag);
playlist.songMod[songNum] = playlist.version;
incrPlaylistVersion();
+
+ playlist.prev_tag = song->tag;
}
}
diff --git a/src/playlist.h b/src/playlist.h
index 34da9f9af..137475afb 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -54,6 +54,11 @@ typedef struct _Playlist {
bool repeat;
bool random;
uint32_t version;
+
+ /** used by syncCurrentPlayerDecodeMetadata() to detect tag changes */
+ const struct song *prev_song;
+ /** used by syncCurrentPlayerDecodeMetadata() to detect tag changes */
+ const struct tag *prev_tag;
} Playlist;
extern bool playlist_saveAbsolutePaths;