Commit c6aafff7 authored by Max Kellermann's avatar Max Kellermann

decoder/sndfile: use integer seek times

parent 26f0f922
...@@ -146,15 +146,6 @@ frame_to_time(sf_count_t frame, const AudioFormat *audio_format) ...@@ -146,15 +146,6 @@ frame_to_time(sf_count_t frame, const AudioFormat *audio_format)
return (float)frame / (float)audio_format->sample_rate; return (float)frame / (float)audio_format->sample_rate;
} }
/**
* Converts a timestamp (in seconds) to a frame number.
*/
static sf_count_t
time_to_frame(float t, const AudioFormat *audio_format)
{
return (sf_count_t)(t * audio_format->sample_rate);
}
static void static void
sndfile_stream_decode(Decoder &decoder, InputStream &is) sndfile_stream_decode(Decoder &decoder, InputStream &is)
{ {
...@@ -199,9 +190,7 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is) ...@@ -199,9 +190,7 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
buffer, num_frames * frame_size, buffer, num_frames * frame_size,
0); 0);
if (cmd == DecoderCommand::SEEK) { if (cmd == DecoderCommand::SEEK) {
sf_count_t c = sf_count_t c = decoder_seek_where_frame(decoder);
time_to_frame(decoder_seek_where(decoder),
&audio_format);
c = sf_seek(sf, c, SEEK_SET); c = sf_seek(sf, c, SEEK_SET);
if (c < 0) if (c < 0)
decoder_seek_error(decoder); decoder_seek_error(decoder);
......
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