From b242ba998699208c87dc066158964de0866b61e2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 7 May 2024 14:19:19 +1000 Subject: Improve decoder's interface to accept streams --- src/tangara/audio/audio_decoder.hpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/tangara/audio/audio_decoder.hpp') diff --git a/src/tangara/audio/audio_decoder.hpp b/src/tangara/audio/audio_decoder.hpp index dfd6f403..ee68290c 100644 --- a/src/tangara/audio/audio_decoder.hpp +++ b/src/tangara/audio/audio_decoder.hpp @@ -9,10 +9,10 @@ #include #include -#include "audio/audio_converter.hpp" #include "audio/audio_events.hpp" #include "audio/audio_sink.hpp" #include "audio/audio_source.hpp" +#include "audio/processor.hpp" #include "codec.hpp" #include "database/track.hpp" #include "types.hpp" @@ -20,35 +20,39 @@ namespace audio { /* - * Handle to a persistent task that takes bytes from the given source, decodes - * them into sample::Sample (normalised to 16 bit signed PCM), and then - * forwards the resulting stream to the given converter. + * Handle to a persistent task that takes encoded bytes from arbitrary sources, + * decodes them into sample::Sample (normalised to 16 bit signed PCM), and then + * streams them onward to the sample processor. */ class Decoder { public: - static auto Start(std::shared_ptr source, - std::shared_ptr converter) -> Decoder*; + static auto Start(std::shared_ptr) -> Decoder*; - auto Main() -> void; + auto open(std::shared_ptr) -> void; Decoder(const Decoder&) = delete; Decoder& operator=(const Decoder&) = delete; private: - Decoder(std::shared_ptr source, - std::shared_ptr converter); + Decoder(std::shared_ptr); + + auto Main() -> void; - auto BeginDecoding(std::shared_ptr) -> bool; - auto ContinueDecoding() -> bool; + auto prepareDecode(std::shared_ptr) -> void; + auto continueDecode() -> bool; + auto finishDecode() -> void; - std::shared_ptr source_; - std::shared_ptr converter_; + std::shared_ptr processor_; + + // Struct used with the next_stream_ queue. + struct NextStream { + std::shared_ptr stream; + }; + QueueHandle_t next_stream_; std::shared_ptr stream_; std::unique_ptr codec_; - - std::optional current_format_; - std::optional current_sink_format_; + std::shared_ptr track_; std::span codec_buffer_; }; -- cgit v1.2.3