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).
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "crossfade.h"
|
#include "crossfade.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
#include "idle.h"
|
||||||
|
|
||||||
enum xfade_state {
|
enum xfade_state {
|
||||||
XFADE_DISABLED = -1,
|
XFADE_DISABLED = -1,
|
||||||
@@ -213,15 +214,28 @@ static void processDecodeInput(struct player *player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
playChunk(struct music_chunk *chunk, const struct audio_format *format,
|
playChunk(struct song *song, struct music_chunk *chunk,
|
||||||
double sizeToTime)
|
const struct audio_format *format, double sizeToTime)
|
||||||
{
|
{
|
||||||
pc.elapsedTime = chunk->times;
|
pc.elapsedTime = chunk->times;
|
||||||
pc.bitRate = chunk->bit_rate;
|
pc.bitRate = chunk->bit_rate;
|
||||||
|
|
||||||
if (chunk->tag != NULL)
|
if (chunk->tag != NULL) {
|
||||||
sendMetadataToAudioDevice(chunk->tag);
|
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,
|
pcm_volume(chunk->data, chunk->length,
|
||||||
format, pc.softwareVolume);
|
format, pc.softwareVolume);
|
||||||
|
|
||||||
@@ -409,8 +423,8 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* play the current chunk */
|
/* play the current chunk */
|
||||||
if (playChunk(beginChunk, &play_audio_format,
|
if (playChunk(player.song, beginChunk,
|
||||||
sizeToTime) < 0)
|
&play_audio_format, sizeToTime) < 0)
|
||||||
break;
|
break;
|
||||||
music_pipe_shift();
|
music_pipe_shift();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user