12 std::shared_ptr<Buffers::BufferManager> buffer_manager,
13 std::shared_ptr<IO::IOManager> io_manager)
14 : m_buffer_manager(
std::move(buffer_manager))
15 , m_io_manager(
std::move(io_manager))
16 , m_scheduler(&scheduler)
23 entry.buffer->get_processing_chain()->remove_processor(entry.processor, entry.buffer);
31 if (op.m_attached_processor) {
37 if (detachable && op.m_target_audio_buffer) {
38 m_buffer_manager->remove_processor(op.m_attached_processor, op.m_target_audio_buffer);
40 if (detachable && op.m_target_graphics_buffer) {
41 m_buffer_manager->remove_processor(op.m_attached_processor, op.m_target_graphics_buffer);
43 op.m_attached_processor =
nullptr;
50 for (
auto& op : operations) {
59 std::function<
void(uint32_t)> on_cycle_start,
60 std::function<
void(uint32_t)> on_cycle_end)
72 std::source_location::current(),
73 "Pipeline requires scheduler for execution");
76 auto self = shared_from_this();
78 if (max_cycles == 0) {
79 max_cycles = UINT64_MAX;
84 auto routine = std::make_shared<Vruta::SoundRoutine>(
98 std::source_location::current(),
99 "Pipeline requires scheduler for execution");
102 auto self = shared_from_this();
104 if (max_cycles == 0) {
105 max_cycles = UINT64_MAX;
110 auto routine = std::make_shared<Vruta::GraphicsRoutine>(
124 std::source_location::current(),
125 "Pipeline requires scheduler for execution");
127 auto self = shared_from_this();
130 auto routine = std::make_shared<Vruta::SoundRoutine>(
142 std::source_location::current(),
143 "Pipeline requires scheduler for execution");
146 auto self = shared_from_this();
153 auto routine = std::make_shared<Vruta::SoundRoutine>(
168 uint64_t samples_per_operation)
173 std::source_location::current(),
174 "Pipeline must have scheduler for scheduled execution");
177 auto self = shared_from_this();
179 if (max_cycles == 0) {
180 max_cycles = UINT64_MAX;
186 auto routine = std::make_shared<Vruta::SoundRoutine>(
197 double seconds_per_operation)
202 std::source_location::current(),
203 "Pipeline must have scheduler for scheduled execution");
214 const auto routine = std::move(
m_routine);
221 const bool running = routine->is_active();
276 std::source_location::current(),
277 "Unknown execution strategy in BufferPipeline");
BufferOperation & with_priority(uint8_t priority)
Set execution priority for scheduler ordering.
@ LOAD
Load data from container to buffer with position control.
@ FUSE
Fuse multiple sources using custom fusion functions.
@ ROUTE
Route data to destination (buffer or container)
@ MODIFY
Modify Buffer Data using custom quick process.
Fundamental unit of operation in buffer processing pipelines.
ExecutionStrategy m_execution_strategy
@ READY
Data ready for processing.
@ CONSUMED
Data has been processed.
Vruta::SoundRoutine execute_reactive(uint64_t max_cycles, uint64_t samples_per_operation)
void end()
End a running pipeline now.
BufferPipeline & on_complete(std::function< void()> cb)
Register a callback fired once when pipeline execution ends.
Vruta::GraphicsRoutine execute_frame_internal(uint64_t max_cycles, uint64_t frames_per_operation)
void execute_for_cycles(uint64_t cycles=0)
Execute the pipeline for a specified number of cycles.
Vruta::SoundRoutine execute_internal(uint64_t max_cycles, uint64_t samples_per_operation)
void execute_continuous()
Start continuous execution of the pipeline.
std::map< std::pair< const BufferOperation *, const Buffers::VKBuffer * >, GraphicsReader > m_readers
void execute_scheduled_at_rate(uint32_t max_cycles=0, double seconds_per_operation=1)
Execute pipeline with real-time rate control.
std::shared_ptr< BufferPipeline > m_active_self
std::vector< BufferOperation > m_operations
void execute_once()
Execute the pipeline for a single cycle.
bool is_running() const
True from an execute call until the pipeline ends or runs out of cycles.
std::vector< DataState > m_data_states
void execute_frame_rate(uint64_t max_cycles=0, uint64_t frames_per_operation=0)
Execute the pipeline at graphics frame rate.
Vruta::SoundRoutine execute_streaming(uint64_t max_cycles, uint64_t samples_per_operation)
Vruta::SoundRoutine execute_parallel(uint64_t max_cycles, uint64_t samples_per_operation)
std::function< void(uint32_t)> m_cycle_end_callback
bool has_pending_data() const
Check if any operations have pending data ready for processing.
std::shared_ptr< Vruta::Routine > m_routine
void mark_data_consumed(uint32_t operation_index)
Execute pipeline synchronized to audio hardware cycle boundaries.
bool m_continuous_execution
std::function< void(uint32_t)> m_cycle_start_callback
std::function< void()> m_on_complete
void execute_buffer_rate(uint64_t max_cycles=0)
Execute pipeline synchronized to audio hardware cycle boundaries.
std::shared_ptr< Buffers::BufferManager > m_buffer_manager
BufferPipeline & parallel(std::initializer_list< BufferOperation > operations)
Execute operations in parallel within the current cycle.
void execute_scheduled(uint64_t max_cycles=0, uint64_t samples_per_operation=1)
Execute pipeline with sample-accurate timing between operations.
Vruta::SoundRoutine execute_phased(uint64_t max_cycles, uint64_t samples_per_operation)
Vruta::TaskScheduler * m_scheduler
BufferPipeline & with_lifecycle(std::function< void(uint32_t)> on_cycle_start, std::function< void(uint32_t)> on_cycle_end)
Set lifecycle callbacks for cycle management.
Coroutine-based execution engine for composable, multi-strategy buffer processing.
A C++20 coroutine-based audio processing task with sample-accurate timing.
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
uint64_t seconds_to_samples(double seconds) const
Converts a time in seconds to a number of samples.
bool cancel_task(const std::shared_ptr< Routine > &routine)
Cancels and removes a task from the scheduler.
Token-based multimodal task scheduling system for unified coroutine processing.
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
@ PHASED
PHASED: Traditional phased execution (default)
@ STREAMING
STREAMING: Immediate flow-through execution.
@ PARALLEL
PARALLEL: Concurrent capture with synchronization.
@ REACTIVE
REACTIVE: Data-driven reactive execution.