Fork of Tangara with customizations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tangara-fw/src/audio/pipeline.cpp

57 lines
1.3 KiB

#include "pipeline.hpp"
#include <memory>
#include "stream_info.hpp"
namespace audio {
Pipeline::Pipeline(IAudioElement* output) : root_(output), subtrees_() {
assert(output != nullptr);
}
Pipeline::~Pipeline() {}
auto Pipeline::AddInput(IAudioElement* input) -> Pipeline* {
subtrees_.push_back(std::make_unique<Pipeline>(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<RawStream>* out) -> void {
for (int i = 0; i < subtrees_.size(); i++) {
RawStream s = subtrees_[i]->OutStream(&regions->at(i));
out->push_back(s);
}
}
auto Pipeline::OutStream(MappableRegion<kPipelineBufferSize>* region)
-> RawStream {
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);
for (const auto& i : current->subtrees_) {
to_search.push_back(i.get());
}
}
return found;
}
} // namespace audio