diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-04-03 14:06:30 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-04-19 10:29:40 +1000 |
| commit | 3836768bb8b95188e6657ab69027d1d9e4b13a77 (patch) | |
| tree | e4330202da1375a6f49d959a7b839643adccd3ca /src/audio/audio_decoder.cpp | |
| parent | 7c6fd654f50e6665efa4226c6b927f9762734182 (diff) | |
| download | tangara-fw-3836768bb8b95188e6657ab69027d1d9e4b13a77.tar.gz | |
new pipeline working(?), but the dac eludes me
Diffstat (limited to 'src/audio/audio_decoder.cpp')
| -rw-r--r-- | src/audio/audio_decoder.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp index ada1f8f7..03c7e998 100644 --- a/src/audio/audio_decoder.cpp +++ b/src/audio/audio_decoder.cpp @@ -6,6 +6,7 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <variant> #include "cbor/tinycbor/src/cborinternal_p.h" #include "freertos/FreeRTOS.h" @@ -37,6 +38,7 @@ auto AudioDecoder::ProcessStreamInfo(const StreamInfo& info) -> bool { if (!std::holds_alternative<StreamInfo::Encoded>(info.format)) { return false; } + ESP_LOGI(kTag, "got new stream"); const auto& encoded = std::get<StreamInfo::Encoded>(info.format); // Reuse the existing codec if we can. This will help with gapless playback, @@ -45,12 +47,14 @@ auto AudioDecoder::ProcessStreamInfo(const StreamInfo& info) -> bool { if (current_codec_ != nullptr && current_codec_->CanHandleType(encoded.type)) { current_codec_->ResetForNewStream(); + ESP_LOGI(kTag, "reusing existing decoder"); return true; } // TODO: use audio type from stream auto result = codecs::CreateCodecForType(encoded.type); if (result.has_value()) { + ESP_LOGI(kTag, "creating new decoder"); current_codec_ = std::move(result.value()); } else { ESP_LOGE(kTag, "no codec for this file"); @@ -73,6 +77,9 @@ auto AudioDecoder::Process(const std::vector<InputStream>& inputs, } const StreamInfo& info = input->info(); + if (std::holds_alternative<std::monostate>(info.format)) { + return; + } if (!current_input_format_ || *current_input_format_ != info.format) { // The input stream has changed! Immediately throw everything away and // start from scratch. @@ -100,6 +107,9 @@ auto AudioDecoder::Process(const std::vector<InputStream>& inputs, } auto write_res = current_codec_->WriteOutputSamples(output->data()); + if (write_res.first > 0) { + ESP_LOGI(kTag, "wrote %u bytes of samples", write_res.first); + } output->add(write_res.first); has_samples_to_send_ = !write_res.second; |
