summaryrefslogtreecommitdiff
path: root/src/tangara/audio/audio_decoder.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-07 14:19:19 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-07 14:19:19 +1000
commitb242ba998699208c87dc066158964de0866b61e2 (patch)
treeb0598526a28d6224e2290c35de5923d4234b89eb /src/tangara/audio/audio_decoder.hpp
parent344a46d0664eb75d232eacea91a4957a25e071f6 (diff)
downloadtangara-fw-b242ba998699208c87dc066158964de0866b61e2.tar.gz
Improve decoder's interface to accept streams
Diffstat (limited to 'src/tangara/audio/audio_decoder.hpp')
-rw-r--r--src/tangara/audio/audio_decoder.hpp36
1 files changed, 20 insertions, 16 deletions
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 <cstdint>
#include <memory>
-#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<IAudioSource> source,
- std::shared_ptr<SampleConverter> converter) -> Decoder*;
+ static auto Start(std::shared_ptr<SampleProcessor>) -> Decoder*;
- auto Main() -> void;
+ auto open(std::shared_ptr<TaggedStream>) -> void;
Decoder(const Decoder&) = delete;
Decoder& operator=(const Decoder&) = delete;
private:
- Decoder(std::shared_ptr<IAudioSource> source,
- std::shared_ptr<SampleConverter> converter);
+ Decoder(std::shared_ptr<SampleProcessor>);
+
+ auto Main() -> void;
- auto BeginDecoding(std::shared_ptr<TaggedStream>) -> bool;
- auto ContinueDecoding() -> bool;
+ auto prepareDecode(std::shared_ptr<TaggedStream>) -> void;
+ auto continueDecode() -> bool;
+ auto finishDecode() -> void;
- std::shared_ptr<IAudioSource> source_;
- std::shared_ptr<SampleConverter> converter_;
+ std::shared_ptr<SampleProcessor> processor_;
+
+ // Struct used with the next_stream_ queue.
+ struct NextStream {
+ std::shared_ptr<TaggedStream> stream;
+ };
+ QueueHandle_t next_stream_;
std::shared_ptr<codecs::IStream> stream_;
std::unique_ptr<codecs::ICodec> codec_;
-
- std::optional<codecs::ICodec::OutputFormat> current_format_;
- std::optional<IAudioOutput::Format> current_sink_format_;
+ std::shared_ptr<TrackInfo> track_;
std::span<sample::Sample> codec_buffer_;
};