Commit 26f0f922 authored by Max Kellermann's avatar Max Kellermann

decoder/opus: use integer seek times

parent bdc4ae2b
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
DecoderCommand HandleTags(const ogg_packet &packet); DecoderCommand HandleTags(const ogg_packet &packet);
DecoderCommand HandleAudio(const ogg_packet &packet); DecoderCommand HandleAudio(const ogg_packet &packet);
bool Seek(OggSyncState &oy, double where); bool Seek(OggSyncState &oy, uint64_t where_frame);
}; };
MPDOpusDecoder::~MPDOpusDecoder() MPDOpusDecoder::~MPDOpusDecoder()
...@@ -328,13 +328,13 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet) ...@@ -328,13 +328,13 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
} }
bool bool
MPDOpusDecoder::Seek(OggSyncState &oy, double where_s) MPDOpusDecoder::Seek(OggSyncState &oy, uint64_t where_frame)
{ {
assert(eos_granulepos > 0); assert(eos_granulepos > 0);
assert(input_stream.IsSeekable()); assert(input_stream.IsSeekable());
assert(input_stream.KnownSize()); assert(input_stream.KnownSize());
const ogg_int64_t where_granulepos(where_s * opus_sample_rate); const ogg_int64_t where_granulepos(where_frame);
/* interpolate the file offset where we expect to find the /* interpolate the file offset where we expect to find the
given granule position */ given granule position */
...@@ -365,7 +365,7 @@ mpd_opus_stream_decode(Decoder &decoder, ...@@ -365,7 +365,7 @@ mpd_opus_stream_decode(Decoder &decoder,
while (true) { while (true) {
auto cmd = d.HandlePackets(); auto cmd = d.HandlePackets();
if (cmd == DecoderCommand::SEEK) { if (cmd == DecoderCommand::SEEK) {
if (d.Seek(oy, decoder_seek_where(decoder))) if (d.Seek(oy, decoder_seek_where_frame(decoder)))
decoder_command_finished(decoder); decoder_command_finished(decoder);
else else
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