aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-23 12:27:05 +0200
committerMax Kellermann <max@duempel.org>2009-07-23 12:27:05 +0200
commitcaf48ee973b621786365a774f4ae18a80665fae5 (patch)
treeb6d0f33ea7f9e8d6e2945f7e4433839f884b9563 /src/player_thread.c
parent0749dbfadfa7145d86bc75a486d91b0ce14169ba (diff)
downloadmpd-caf48ee973b621786365a774f4ae18a80665fae5.tar.gz
mpd-caf48ee973b621786365a774f4ae18a80665fae5.tar.xz
mpd-caf48ee973b621786365a774f4ae18a80665fae5.zip
player_thread: don't use precalculated size_to_time
Calculate the total play time with the audio_format object each time, using audio_format_time_to_size(). The function audioFormatSizeToTime() is not needed anymore, and will be removed with this patch.
Diffstat (limited to '')
-rw-r--r--src/player_thread.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index 950a38e4c..f23faa8b3 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -93,12 +93,6 @@ struct player {
* The current audio format for the audio outputs.
*/
struct audio_format play_audio_format;
-
- /**
- * Coefficient for converting a PCM buffer size into a time
- * span.
- */
- double size_to_time;
};
static struct music_buffer *player_buffer;
@@ -200,8 +194,6 @@ player_check_decoder_startup(struct player *player)
pc.total_time = dc.total_time;
pc.audio_format = dc.in_audio_format;
player->play_audio_format = dc.out_audio_format;
- player->size_to_time =
- audioFormatSizeToTime(&dc.out_audio_format);
player->decoder_starting = false;
if (!player->paused &&
@@ -446,7 +438,7 @@ update_song_tag(struct song *song, const struct tag *new_tag)
*/
static bool
play_chunk(struct song *song, struct music_chunk *chunk,
- const struct audio_format *format, double sizeToTime)
+ const struct audio_format *format)
{
assert(music_chunk_check_format(chunk, format));
@@ -469,7 +461,8 @@ play_chunk(struct song *song, struct music_chunk *chunk,
return false;
}
- pc.total_play_time += sizeToTime * chunk->length;
+ pc.total_play_time += (double)chunk->length /
+ audio_format_time_to_size(format);
return true;
}
@@ -540,8 +533,7 @@ play_next_chunk(struct player *player)
/* play the current chunk */
- success = play_chunk(player->song, chunk, &player->play_audio_format,
- player->size_to_time);
+ success = play_chunk(player->song, chunk, &player->play_audio_format);
if (!success) {
music_buffer_return(player_buffer, chunk);
@@ -608,7 +600,6 @@ static void do_play(void)
.xfade = XFADE_UNKNOWN,
.cross_fading = false,
.cross_fade_chunks = 0,
- .size_to_time = 0.0,
};
player.pipe = music_pipe_new();