diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-03-10 11:28:33 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-04-19 10:27:59 +1000 |
| commit | a9531c86a433c8b7ae1f77ff0266c27c39eca7f4 (patch) | |
| tree | 11835552aa2ecb400537781d8eb3851118c47e61 /src/audio/pipeline.cpp | |
| parent | 2a46eecdc6334c31cee2b40427d2536b48cbb6be (diff) | |
| download | tangara-fw-a9531c86a433c8b7ae1f77ff0266c27c39eca7f4.tar.gz | |
mostly single task pipeline
Diffstat (limited to 'src/audio/pipeline.cpp')
| -rw-r--r-- | src/audio/pipeline.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/audio/pipeline.cpp b/src/audio/pipeline.cpp new file mode 100644 index 00000000..f42e6853 --- /dev/null +++ b/src/audio/pipeline.cpp @@ -0,0 +1,52 @@ +#include "pipeline.hpp" +#include "stream_info.hpp" + +namespace audio { + +Pipeline::Pipeline(IAudioElement* output) : root_(output), subtrees_() {} +Pipeline::~Pipeline() {} + +auto Pipeline::AddInput(IAudioElement* input) -> Pipeline* { + subtrees_.emplace_back(input); + return subtrees_.back().get(); +} + +auto Pipeline::OutputElement() const -> IAudioElement* { + return root_; +} + +auto Pipeline::NumInputs() const -> std::size_t { + return subtrees_.size(); +} + +auto Pipeline::InStreams( + std::vector<MappableRegion<kPipelineBufferSize>>* regions, + std::vector<MutableStream>* out) -> void { + for (int i = 0; i < subtrees_.size(); i++) { + MutableStream s = subtrees_[i]->OutStream(®ions->at(i)); + out->push_back(s); + } +} + +auto Pipeline::OutStream(MappableRegion<kPipelineBufferSize>* region) + -> MutableStream { + return {&output_info_, region->Map(output_buffer_)}; +} + +auto Pipeline::GetIterationOrder() -> std::vector<Pipeline*> { + std::vector<Pipeline*> to_search{this}; + std::vector<Pipeline*> found; + + while (!to_search.empty()) { + Pipeline* current = to_search.back(); + to_search.pop_back(); + found.push_back(current); + + to_search.insert(to_search.end(), current->subtrees_.begin(), + current->subtrees_.end()); + } + + return found; +} + +} // namespace audio |
