diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-10 21:34:48 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-10 21:35:16 +1000 |
| commit | c37ccb985125f5efdf7600989331085f60d8a973 (patch) | |
| tree | 4c0cbce4d9111e82a180e73b7021e23eb6a4b0db /src/codecs/opus.cpp | |
| parent | 958160aa545e3d91b2a4f1a367817e73d298e8a9 (diff) | |
| download | tangara-fw-c37ccb985125f5efdf7600989331085f60d8a973.tar.gz | |
Reintroduce track timer, now relying more on codecs
Diffstat (limited to 'src/codecs/opus.cpp')
| -rw-r--r-- | src/codecs/opus.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/codecs/opus.cpp b/src/codecs/opus.cpp index c0727c6b..f5ff471a 100644 --- a/src/codecs/opus.cpp +++ b/src/codecs/opus.cpp @@ -122,9 +122,24 @@ auto XiphOpusDecoder::OpenStream(std::shared_ptr<IStream> input) return cpp::fail(Error::kMalformedData); } + auto l = op_pcm_total(opus_, -1); + std::optional<uint32_t> length; + if (l > 0) { + // Output is always downmixed to two channels, but the pcm count does not + // reflect this. + int channels = op_channel_count(opus_, -1); + if (channels == 1) { + l *= 2; + } else if (channels > 2) { + l /= channels * 2; + } + length = l; + } + return OutputFormat{ .num_channels = 2, .sample_rate_hz = 48000, + .total_samples = length, }; } |
