From b6ad5b49c0842969351e64b77898a68a39de74de Mon Sep 17 00:00:00 2001 From: Avaer Kazmer Date: Sun, 4 Mar 2018 18:11:05 -0800 Subject: [PATCH] Bugfix vorbis decoder seeking --- src/VorbisDecoder.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/VorbisDecoder.cpp b/src/VorbisDecoder.cpp index 61b6953..2c0e02f 100644 --- a/src/VorbisDecoder.cpp +++ b/src/VorbisDecoder.cpp @@ -233,8 +233,17 @@ public: } static int seek_func(void *datasource, ogg_int64_t offset, int whence) { VorbisDecoderInternal *decoder = (VorbisDecoderInternal *)datasource; - decoder->dataPos = std::min(offset, decoder->data.size()); - return 0; + size_t newPos = 0; + if (whence == SEEK_SET) { + newPos = offset; + } else if (whence == SEEK_CUR) { + newPos = decoder->dataPos + offset; + } else if (whence == SEEK_END) { + newPos = decoder->data.size() + offset; + } + newPos = std::min(offset, decoder->data.size()); + decoder->dataPos = newPos; + return newPos; } static int close_func(void *datasource) { return 0;