summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorayumi <ayumi@noreply.codeberg.org>2025-08-04 04:10:08 +0200
committerayumi <ayumi@noreply.codeberg.org>2025-08-04 04:10:08 +0200
commite25b71e5bd200501a63398b9d11e484d7baf25b6 (patch)
tree6d6c735c821099a1438a79ae8805854b320ee2cf
parentfd064b996a432074b3e5c18b6a8c5439a372f281 (diff)
downloadtangara-fw-e25b71e5bd200501a63398b9d11e484d7baf25b6.tar.gz
Add support for the `SetPreambleFinished` hint in the WavPack decoder
-rw-r--r--src/codecs/wavpack.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/codecs/wavpack.cpp b/src/codecs/wavpack.cpp
index 709302e6..d070701f 100644
--- a/src/codecs/wavpack.cpp
+++ b/src/codecs/wavpack.cpp
@@ -66,6 +66,7 @@ auto WavPackDecoder::OpenStream(std::shared_ptr<IStream> input, uint32_t offset)
channels_ = WavpackGetReducedChannels(&wavpack_);
bitdepth_ = WavpackGetBitsPerSample(&wavpack_);
size_ = kBufSize / channels_;
+ const auto size = input->Size();
const std::optional total = WavpackGetNumSamples(&wavpack_) == -1
? std::nullopt
: std::optional(
@@ -114,6 +115,7 @@ auto WavPackDecoder::OpenStream(std::shared_ptr<IStream> input, uint32_t offset)
return cpp::fail(Error::kMalformedData);
}
+ input_->SetPreambleFinished();
uint32_t samples = 0;
for (size_t i = 0, n = target / size_; i < n; i++)
samples += WavpackUnpackSamples(&wavpack_, buf_, size_);
@@ -130,9 +132,9 @@ auto WavPackDecoder::OpenStream(std::shared_ptr<IStream> input, uint32_t offset)
} else if (offset && (!total || !input_.get()->CanSeek())) {
ESP_LOGE(kTag, "seeking: can’t seek");
return cpp::fail(Error::kInternalError);
- }
+ } else
+ input_->SetPreambleFinished();
- const auto size = input->Size();
return OutputFormat{
.num_channels = channels_,
.sample_rate_hz = rate,