output_all: reset elapsed_time at song border

Another quirk fixed: after the last chunk of a song has been played,
the "elapsed_time" variable is set to the chunk's time stamp.  When
the client receives the PLAYER idle event and asks MPD for the current
time stamp, MPD will return the last time stamp of the previous song
when it hasn't played the first chunk of the current song yet.
This commit is contained in:
Max Kellermann 2010-01-02 21:16:51 +01:00
parent d3b763a48c
commit 915182bcb8
3 changed files with 16 additions and 0 deletions

View File

@ -558,6 +558,14 @@ audio_output_all_close(void)
audio_output_all_elapsed_time = -1.0;
}
void
audio_output_all_song_border(void)
{
/* clear the elapsed_time pointer at the beginning of a new
song */
audio_output_all_elapsed_time = 0.0;
}
float
audio_output_all_get_elapsed_time(void)
{

View File

@ -141,6 +141,12 @@ audio_output_all_drain(void);
void
audio_output_all_cancel(void);
/**
* Indicate that a new song will begin now.
*/
void
audio_output_all_song_border(void);
/**
* Returns the "elapsed_time" stamp of the most recently finished
* chunk. A negative value is returned when no chunk has been

View File

@ -736,6 +736,8 @@ player_song_border(struct player *player)
music_pipe_free(player->pipe);
player->pipe = player->dc->pipe;
audio_output_all_song_border();
if (!player_wait_for_decoder(player))
return false;