diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-10 22:24:47 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-10 22:24:47 +1000 |
| commit | 06283e07140f39a9f3db636c8a4ff8fcbc56a290 (patch) | |
| tree | fcf0ec2555ffa0db3060100d16b653d3a39e36e7 /src/codecs | |
| parent | c37ccb985125f5efdf7600989331085f60d8a973 (diff) | |
| download | tangara-fw-06283e07140f39a9f3db636c8a4ff8fcbc56a290.tar.gz | |
Fix issues with timing stereo streams
Diffstat (limited to 'src/codecs')
| -rw-r--r-- | src/codecs/foxenflac.cpp | 2 | ||||
| -rw-r--r-- | src/codecs/mad.cpp | 4 | ||||
| -rw-r--r-- | src/codecs/opus.cpp | 10 |
3 files changed, 5 insertions, 11 deletions
diff --git a/src/codecs/foxenflac.cpp b/src/codecs/foxenflac.cpp index b1ba348a..b378e47e 100644 --- a/src/codecs/foxenflac.cpp +++ b/src/codecs/foxenflac.cpp @@ -64,7 +64,7 @@ auto FoxenFlacDecoder::OpenStream(std::shared_ptr<IStream> input) uint64_t num_samples = fx_flac_get_streaminfo(flac_, FLAC_KEY_N_SAMPLES); if (num_samples > 0) { - format.total_samples = num_samples / fs; + format.total_samples = num_samples; } return format; diff --git a/src/codecs/mad.cpp b/src/codecs/mad.cpp index dfa568d4..f4cfb3b9 100644 --- a/src/codecs/mad.cpp +++ b/src/codecs/mad.cpp @@ -92,7 +92,9 @@ auto MadMp3Decoder::OpenStream(std::shared_ptr<IStream> input) auto vbr_length = GetVbrLength(header); if (vbr_length) { - output.total_samples = vbr_length; + output.total_samples = vbr_length.value() * channels; + } else { + // FIXME: calculate length using the filesize, assuming CBR. } return output; } diff --git a/src/codecs/opus.cpp b/src/codecs/opus.cpp index f5ff471a..e6e3a1af 100644 --- a/src/codecs/opus.cpp +++ b/src/codecs/opus.cpp @@ -125,15 +125,7 @@ auto XiphOpusDecoder::OpenStream(std::shared_ptr<IStream> input) 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; + length = l * 2; } return OutputFormat{ |
