summaryrefslogtreecommitdiff
path: root/src/audio/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-03-26 12:12:42 +1100
committerjacqueline <me@jacqueline.id.au>2024-03-26 12:12:42 +1100
commit078b77d0f796be3c787f62b9b830512e38d3b076 (patch)
tree7873bc9d557be64b5e7579a69fbbe387fe4f1143 /src/audio/include
parent175bfc4e3e9f7aa39e084d3f1625347f1d5711ec (diff)
downloadtangara-fw-078b77d0f796be3c787f62b9b830512e38d3b076.tar.gz
pass stream start/update/end events through the whole pipeline
Diffstat (limited to 'src/audio/include')
-rw-r--r--src/audio/include/audio_converter.hpp18
-rw-r--r--src/audio/include/audio_events.hpp15
-rw-r--r--src/audio/include/audio_fsm.hpp9
3 files changed, 20 insertions, 22 deletions
diff --git a/src/audio/include/audio_converter.hpp b/src/audio/include/audio_converter.hpp
index dcd068b5..232b5d8e 100644
--- a/src/audio/include/audio_converter.hpp
+++ b/src/audio/include/audio_converter.hpp
@@ -10,6 +10,7 @@
#include <cstdint>
#include <memory>
+#include "audio_events.hpp"
#include "audio_sink.hpp"
#include "audio_source.hpp"
#include "codec.hpp"
@@ -31,20 +32,23 @@ class SampleConverter {
auto SetOutput(std::shared_ptr<IAudioOutput>) -> void;
- auto ConvertSamples(cpp::span<sample::Sample>,
- const IAudioOutput::Format& format,
- bool is_eos) -> void;
+ auto beginStream(std::shared_ptr<TrackInfo>) -> void;
+ auto continueStream(cpp::span<sample::Sample>) -> void;
+ auto endStream() -> void;
private:
auto Main() -> void;
- auto SetTargetFormat(const IAudioOutput::Format& format) -> void;
- auto HandleSamples(cpp::span<sample::Sample>, bool) -> size_t;
+ auto handleBeginStream(std::shared_ptr<TrackInfo>) -> void;
+ auto handleContinueStream(size_t samples_available) -> void;
+ auto handleEndStream() -> void;
- auto SendToSink(cpp::span<sample::Sample>) -> void;
+ auto handleSamples(cpp::span<sample::Sample>) -> size_t;
+
+ auto sendToSink(cpp::span<sample::Sample>) -> void;
struct Args {
- IAudioOutput::Format format;
+ std::shared_ptr<TrackInfo>* track;
size_t samples_available;
bool is_end_of_stream;
};
diff --git a/src/audio/include/audio_events.hpp b/src/audio/include/audio_events.hpp
index 9af30467..b8a0dba6 100644
--- a/src/audio/include/audio_events.hpp
+++ b/src/audio/include/audio_events.hpp
@@ -51,6 +51,8 @@ struct TrackInfo {
/* The encoded format of the this track. */
codecs::StreamType encoding;
+
+ IAudioOutput::Format format;
};
/*
@@ -136,23 +138,18 @@ struct OutputModeChanged : tinyfsm::Event {};
namespace internal {
-struct DecoderOpened : tinyfsm::Event {
+struct StreamStarted : tinyfsm::Event {
std::shared_ptr<TrackInfo> track;
-};
-
-struct DecoderClosed : tinyfsm::Event {};
-
-struct DecoderError : tinyfsm::Event {};
-
-struct ConverterConfigurationChanged : tinyfsm::Event {
IAudioOutput::Format src_format;
IAudioOutput::Format dst_format;
};
-struct ConverterProgress : tinyfsm::Event {
+struct StreamUpdate : tinyfsm::Event {
uint32_t samples_sunk;
};
+struct StreamEnded : tinyfsm::Event {};
+
} // namespace internal
} // namespace audio
diff --git a/src/audio/include/audio_fsm.hpp b/src/audio/include/audio_fsm.hpp
index 62bb4786..c00813ac 100644
--- a/src/audio/include/audio_fsm.hpp
+++ b/src/audio/include/audio_fsm.hpp
@@ -46,12 +46,9 @@ class AudioState : public tinyfsm::Fsm<AudioState> {
void react(const SetTrack&);
void react(const TogglePlayPause&);
- void react(const internal::DecoderOpened&);
- void react(const internal::DecoderClosed&);
- void react(const internal::DecoderError&);
-
- void react(const internal::ConverterConfigurationChanged&);
- void react(const internal::ConverterProgress&);
+ void react(const internal::StreamStarted&);
+ void react(const internal::StreamUpdate&);
+ void react(const internal::StreamEnded&);
void react(const StepUpVolume&);
void react(const StepDownVolume&);