Commit cbfaa4a2 authored by Max Kellermann's avatar Max Kellermann

player_thread: postpone song tags during cross-fade

Previously, tags of the new song being cross-faded in were sent immediately. That can cause wrong information being displayed, because the "previous" song might send its tag at the end again, overriding the "next" song's tag. This patch saves & merges the tag of the next song, and sends it when cross-fading is finished, and the next song really starts.
parent 2e72a9b2
...@@ -3,6 +3,7 @@ ver 0.15.9 (2009/??/??) ...@@ -3,6 +3,7 @@ ver 0.15.9 (2009/??/??)
- mad: fix crash when seeking at end of song - mad: fix crash when seeking at end of song
- mpcdec: fix negative shift on fixed-point samples - mpcdec: fix negative shift on fixed-point samples
* playlist: fix single+repeat in random mode * playlist: fix single+repeat in random mode
* player: postpone song tags during cross-fade
ver 0.15.8 (2010/01/17) ver 0.15.8 (2010/01/17)
......
...@@ -90,6 +90,13 @@ struct player { ...@@ -90,6 +90,13 @@ struct player {
unsigned cross_fade_chunks; unsigned cross_fade_chunks;
/** /**
* The tag of the "next" song during cross-fade. It is
* postponed, and sent to the output thread when the new song
* really begins.
*/
struct tag *cross_fade_tag;
/**
* The current audio format for the audio outputs. * The current audio format for the audio outputs.
*/ */
struct audio_format play_audio_format; struct audio_format play_audio_format;
...@@ -518,6 +525,14 @@ play_next_chunk(struct player *player) ...@@ -518,6 +525,14 @@ play_next_chunk(struct player *player)
chunk = music_pipe_shift(player->pipe); chunk = music_pipe_shift(player->pipe);
assert(chunk != NULL); assert(chunk != NULL);
/* don't send the tags of the new song (which
is being faded in) yet; postpone it until
the current song is faded out */
player->cross_fade_tag =
tag_merge_replace(player->cross_fade_tag,
other_chunk->tag);
other_chunk->tag = NULL;
cross_fade_apply(chunk, other_chunk, cross_fade_apply(chunk, other_chunk,
&dc.out_audio_format, &dc.out_audio_format,
cross_fade_position, cross_fade_position,
...@@ -544,6 +559,14 @@ play_next_chunk(struct player *player) ...@@ -544,6 +559,14 @@ play_next_chunk(struct player *player)
assert(chunk != NULL); assert(chunk != NULL);
/* insert the postponed tag if cross-fading is finished */
if (player->xfade != XFADE_ENABLED && player->cross_fade_tag != NULL) {
chunk->tag = tag_merge_replace(chunk->tag,
player->cross_fade_tag);
player->cross_fade_tag = NULL;
}
/* play the current chunk */ /* play the current chunk */
success = play_chunk(player->song, chunk, &player->play_audio_format, success = play_chunk(player->song, chunk, &player->play_audio_format,
...@@ -608,6 +631,7 @@ static void do_play(void) ...@@ -608,6 +631,7 @@ static void do_play(void)
.xfade = XFADE_UNKNOWN, .xfade = XFADE_UNKNOWN,
.cross_fading = false, .cross_fading = false,
.cross_fade_chunks = 0, .cross_fade_chunks = 0,
.cross_fade_tag = NULL,
.size_to_time = 0.0, .size_to_time = 0.0,
}; };
...@@ -754,6 +778,9 @@ static void do_play(void) ...@@ -754,6 +778,9 @@ static void do_play(void)
music_pipe_clear(player.pipe, player_buffer); music_pipe_clear(player.pipe, player_buffer);
music_pipe_free(player.pipe); music_pipe_free(player.pipe);
if (player.cross_fade_tag != NULL)
tag_free(player.cross_fade_tag);
pc.state = PLAYER_STATE_STOP; pc.state = PLAYER_STATE_STOP;
event_pipe_emit(PIPE_EVENT_PLAYLIST); event_pipe_emit(PIPE_EVENT_PLAYLIST);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment