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); };