aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.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/player_thread.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 'src/player_thread.c')
-rw-r--r--src/player_thread.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index 7368b4d4b..6777d5d61 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -151,7 +151,6 @@ player_wait_for_decoder(struct player *player)
player->song = pc.next_song;
pc.next_song = NULL;
- pc.elapsed_time = 0;
player->queued = false;
/* set the "starting" flag, which will be cleared by
@@ -330,7 +329,6 @@ static bool player_seek_decoder(struct player *player)
return false;
}
- pc.elapsed_time = where;
player_command_finished();
player->xfade = XFADE_UNKNOWN;
@@ -409,6 +407,14 @@ static void player_process_command(struct player *player)
player->queued = false;
player_command_finished();
break;
+
+ case PLAYER_COMMAND_REFRESH:
+ if (audio_format_defined(&player->play_audio_format))
+ audio_output_all_check();
+
+ pc.elapsed_time = audio_output_all_get_elapsed_time();
+ player_command_finished();
+ break;
}
}
@@ -456,7 +462,6 @@ play_chunk(struct song *song, struct music_chunk *chunk,
return true;
}
- pc.elapsed_time = chunk->times;
pc.bit_rate = chunk->bit_rate;
/* send the chunk to the audio outputs */
@@ -630,7 +635,6 @@ static void do_play(void)
return;
}
- pc.elapsed_time = 0;
pc.state = PLAYER_STATE_PLAY;
player_command_finished();
@@ -813,6 +817,11 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
player_command_finished();
break;
+ case PLAYER_COMMAND_REFRESH:
+ /* no-op when not playing */
+ player_command_finished();
+ break;
+
case PLAYER_COMMAND_NONE:
notify_wait(&pc.notify);
break;