diff options
author | Max Kellermann <max@duempel.org> | 2009-07-23 12:27:05 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-07-23 12:27:05 +0200 |
commit | caf48ee973b621786365a774f4ae18a80665fae5 (patch) | |
tree | b6d0f33ea7f9e8d6e2945f7e4433839f884b9563 /src | |
parent | 0749dbfadfa7145d86bc75a486d91b0ce14169ba (diff) | |
download | mpd-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 'src')
-rw-r--r-- | src/audio_format.h | 9 | ||||
-rw-r--r-- | src/player_thread.c | 17 |
2 files changed, 4 insertions, 22 deletions
diff --git a/src/audio_format.h b/src/audio_format.h index cf067b705..a88fc3a4c 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -172,13 +172,4 @@ static inline double audio_format_time_to_size(const struct audio_format *af) return af->sample_rate * audio_format_frame_size(af); } -/** - * Returns the floating point factor which converts a storage size in - * bytes to a time span. - */ -static inline double audioFormatSizeToTime(const struct audio_format *af) -{ - return 1.0 / audio_format_time_to_size(af); -} - #endif 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(); |