aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_all.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-08 22:09:25 +0200
committerMax Kellermann <max@duempel.org>2009-10-08 22:09:25 +0200
commit448aefaace840ccd8b8c1fb82ff72ef986b84f12 (patch)
tree2433cdab57c247e96c5f2576b02bb9d6ac0cc022 /src/output_all.c
parent47b5e73a151f1ccc506f454eaafc5c65885ff0a3 (diff)
downloadmpd-448aefaace840ccd8b8c1fb82ff72ef986b84f12.tar.gz
mpd-448aefaace840ccd8b8c1fb82ff72ef986b84f12.tar.xz
mpd-448aefaace840ccd8b8c1fb82ff72ef986b84f12.zip
player_thread: get "elapsed" from audio outputs
Tracking the "elapsed" time from the chunks which we have sent to the output pipe is very imprecise: since we have implemented the music pipe, we're sending large number of chunks at once, giving the "elapsed" time stamp a resolution of usually more than a second. This patch changes the source of this information to the outputs. If a chunk has been played by all outputs, the "elapsed" time stamp is updated. The new command PLAYER_COMMAND_REFRESH makes the player thread update its status information: it tells the outputs to update the chunk time stamp. After that, player_control.elapsed_time is current.
Diffstat (limited to '')
-rw-r--r--src/output_all.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/output_all.c b/src/output_all.c
index 4b5ba3a6f..b7a42a6a3 100644
--- a/src/output_all.c
+++ b/src/output_all.c
@@ -52,6 +52,11 @@ static struct music_buffer *g_music_buffer;
*/
static struct music_pipe *g_mp;
+/**
+ * The "elapsed_time" stamp of the most recently finished chunk.
+ */
+static float audio_output_all_elapsed_time;
+
unsigned int audio_output_count(void)
{
return num_audio_outputs;
@@ -385,6 +390,8 @@ audio_output_all_check(void)
this chunk */
return music_pipe_size(g_mp);
+ audio_output_all_elapsed_time = chunk->times;
+
is_tail = chunk->next == NULL;
if (is_tail)
/* this is the tail of the pipe - clear the
@@ -468,9 +475,16 @@ audio_output_all_close(void)
music_pipe_clear(g_mp, g_music_buffer);
music_pipe_free(g_mp);
g_mp = NULL;
+ audio_output_all_elapsed_time = 0.0;
}
g_music_buffer = NULL;
audio_format_clear(&input_audio_format);
}
+
+float
+audio_output_all_get_elapsed_time(void)
+{
+ return audio_output_all_elapsed_time;
+}