summaryrefslogtreecommitdiff
path: root/src/codecs/vorbis.cpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-04-02 11:13:50 +1100
committerailurux <ailuruxx@gmail.com>2024-04-02 11:13:50 +1100
commite20ebe7574db5aedc73f07b7bb3a0a01eae93c84 (patch)
tree34c93ec8a80e282f3ce3e47dd60c41e46de0f8b3 /src/codecs/vorbis.cpp
parenta750af35aa6afda40aadca8f7cf8db75f41a43b2 (diff)
parent0d0c4b2307cac8436fea7276956f293262b265ed (diff)
downloadtangara-fw-e20ebe7574db5aedc73f07b7bb3a0a01eae93c84.tar.gz
Merge branch 'main' into lua-volume
Diffstat (limited to 'src/codecs/vorbis.cpp')
-rw-r--r--src/codecs/vorbis.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/codecs/vorbis.cpp b/src/codecs/vorbis.cpp
index 7fb53f1b..9131451b 100644
--- a/src/codecs/vorbis.cpp
+++ b/src/codecs/vorbis.cpp
@@ -77,7 +77,8 @@ TremorVorbisDecoder::~TremorVorbisDecoder() {
ov_clear(vorbis_.get());
}
-auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input)
+auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input,
+ uint32_t offset)
-> cpp::result<OutputFormat, Error> {
int res = ov_open_callbacks(input.get(), vorbis_.get(), NULL, 0, kCallbacks);
if (res < 0) {
@@ -117,6 +118,10 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input)
length = l * info->channels;
}
+ if (offset && ov_time_seek(vorbis_.get(), offset * 1000) != 0) {
+ return cpp::fail(Error::kInternalError);
+ }
+
return OutputFormat{
.num_channels = static_cast<uint8_t>(info->channels),
.sample_rate_hz = static_cast<uint32_t>(info->rate),
@@ -145,11 +150,4 @@ auto TremorVorbisDecoder::DecodeTo(cpp::span<sample::Sample> output)
};
}
-auto TremorVorbisDecoder::SeekTo(size_t target) -> cpp::result<void, Error> {
- if (ov_pcm_seek(vorbis_.get(), target) != 0) {
- return cpp::fail(Error::kInternalError);
- }
- return {};
-}
-
} // namespace codecs