From 6fe4068c8e076fc6313220bc5d6aac68e3d8cf68 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 31 Jan 2020 19:24:26 +0100 Subject: [PATCH] decoder/ogg: move code to SeekByte() --- src/decoder/plugins/OggDecoder.cxx | 10 ++++++++-- src/decoder/plugins/OggDecoder.hxx | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/decoder/plugins/OggDecoder.cxx b/src/decoder/plugins/OggDecoder.cxx index e01c0f8eb..2dec9913a 100644 --- a/src/decoder/plugins/OggDecoder.cxx +++ b/src/decoder/plugins/OggDecoder.cxx @@ -68,6 +68,13 @@ OggDecoder::LoadEndGranulePos() const return packet.granulepos; } +inline void +OggDecoder::SeekByte(offset_type offset) +{ + input_stream.LockSeek(offset); + PostSeek(); +} + void OggDecoder::SeekGranulePos(ogg_int64_t where_granulepos) { @@ -79,7 +86,6 @@ OggDecoder::SeekGranulePos(ogg_int64_t where_granulepos) offset_type offset(where_granulepos * input_stream.GetSize() / end_granulepos); - input_stream.LockSeek(offset); - PostSeek(); + SeekByte(offset); } diff --git a/src/decoder/plugins/OggDecoder.hxx b/src/decoder/plugins/OggDecoder.hxx index 33bf8d352..4783f1c6e 100644 --- a/src/decoder/plugins/OggDecoder.hxx +++ b/src/decoder/plugins/OggDecoder.hxx @@ -22,6 +22,7 @@ #include "lib/xiph/OggVisitor.hxx" #include "decoder/Reader.hxx" +#include "input/Offset.hxx" class OggDecoder : public OggVisitor { ogg_int64_t end_granulepos; @@ -53,6 +54,13 @@ protected: return end_granulepos > 0; } + /** + * Seek the #InputStream and update the #OggVisitor. + * + * Throws on error. + */ + void SeekByte(offset_type offset); + void SeekGranulePos(ogg_int64_t where_granulepos); };