diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-02-10 15:32:21 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-02-10 15:32:21 +1100 |
| commit | 61c91b3cdb2c9dd655f3adf0f461f5cefb3b2e9b (patch) | |
| tree | 8d0bb288781f86455f02219d0b7ac8cee493eeb3 /src/audio/audio_decoder.cpp | |
| parent | cabfd4b75ecc733bdf36997606a686c4d2bc277d (diff) | |
| download | tangara-fw-61c91b3cdb2c9dd655f3adf0f461f5cefb3b2e9b.tar.gz | |
Mostly working pipeline, including proper EOF signalling
Diffstat (limited to 'src/audio/audio_decoder.cpp')
| -rw-r--r-- | src/audio/audio_decoder.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp index 27b9cca3..d90ca496 100644 --- a/src/audio/audio_decoder.cpp +++ b/src/audio/audio_decoder.cpp @@ -84,6 +84,16 @@ auto AudioDecoder::ProcessChunk(const cpp::span<std::byte>& chunk) return {}; } +auto AudioDecoder::ProcessEndOfStream() -> void { + has_samples_to_send_ = false; + needs_more_input_ = true; + current_codec_.reset(); + + SendOrBufferEvent( + std::unique_ptr<StreamEvent>( + StreamEvent::CreateEndOfStream(input_events_))); +} + auto AudioDecoder::Process() -> cpp::result<void, AudioProcessingError> { if (has_samples_to_send_) { ESP_LOGI(kTag, "sending samples"); @@ -132,7 +142,7 @@ auto AudioDecoder::Process() -> cpp::result<void, AudioProcessingError> { has_samples_to_send_ = true; if (needs_more_input_) { - chunk_reader_->HandleLeftovers(current_codec_->GetInputPosition()); + chunk_reader_->HandleBytesUsed(current_codec_->GetInputPosition()); } } |
