aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-02 17:13:26 +0100
committerMax Kellermann <max@duempel.org>2008-11-02 17:13:26 +0100
commitfb233df7a91a2a8f93aaf220a94a1048729da38e (patch)
treecf70696ea2cbe3df4e42deffc77e6d77c7c54a90 /src/player_thread.c
parent7e7704e42b0be6ffd632b84f34fae268f8cb0bb5 (diff)
downloadmpd-fb233df7a91a2a8f93aaf220a94a1048729da38e.tar.gz
mpd-fb233df7a91a2a8f93aaf220a94a1048729da38e.tar.xz
mpd-fb233df7a91a2a8f93aaf220a94a1048729da38e.zip
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).
Diffstat (limited to '')
-rw-r--r--src/player_thread.c24
1 files 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();