From fb233df7a91a2a8f93aaf220a94a1048729da38e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 2 Nov 2008 17:13:26 +0100 Subject: player: copy stream tag to the song struct Non-local songs used to have no tags. If the decoder sends us a tag, we should incorporate it into the song struct. This way, clients can always show the correct song name (if provided by the server). --- src/player_thread.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/player_thread.c b/src/player_thread.c index 36a738149..f0c25a694 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -27,6 +27,7 @@ #include "crossfade.h" #include "song.h" #include "pipe.h" +#include "idle.h" enum xfade_state { XFADE_DISABLED = -1, @@ -213,15 +214,28 @@ static void processDecodeInput(struct player *player) } static int -playChunk(struct music_chunk *chunk, const struct audio_format *format, - double sizeToTime) +playChunk(struct song *song, struct music_chunk *chunk, + const struct audio_format *format, double sizeToTime) { pc.elapsedTime = chunk->times; pc.bitRate = chunk->bit_rate; - if (chunk->tag != NULL) + if (chunk->tag != NULL) { sendMetadataToAudioDevice(chunk->tag); + if (!song_is_file(song)) { + /* always update the tag of remote streams */ + + if (song->tag != NULL) + tag_free(song->tag); + song->tag = tag_dup(chunk->tag); + + /* notify all clients that the tag of the + current song has changed */ + idle_add(IDLE_PLAYER); + } + } + pcm_volume(chunk->data, chunk->length, format, pc.softwareVolume); @@ -409,8 +423,8 @@ static void do_play(void) } /* play the current chunk */ - if (playChunk(beginChunk, &play_audio_format, - sizeToTime) < 0) + if (playChunk(player.song, beginChunk, + &play_audio_format, sizeToTime) < 0) break; music_pipe_shift(); -- cgit v1.2.3