summaryrefslogtreecommitdiff
path: root/src/tangara/audio/audio_decoder.hpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-05-10 12:20:51 +1000
committerailurux <ailuruxx@gmail.com>2024-05-10 12:20:51 +1000
commite4ce7c4ac23402e09be8d6a52e0f739c0dff4ff0 (patch)
tree3e04ac08a884fb6d6c887cd70218316a30ae3371 /src/tangara/audio/audio_decoder.hpp
parent5b109ed32709c271a6803382c5738802919c9c69 (diff)
parent2afeb2989b2f845664e12f93e850aab983be12cc (diff)
downloadtangara-fw-e4ce7c4ac23402e09be8d6a52e0f739c0dff4ff0.tar.gz
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
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..64561d9d 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(bool cancel) -> 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_;
};