Commit caf48ee9 authored by Max Kellermann's avatar Max Kellermann

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.
parent 0749dbfa
......@@ -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
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment