8 : m_is_processing(false)
11 , m_skip_state_management(false)
20 uint32_t state = node->m_state.load();
29 bool expected =
false;
30 if (m_pending_op.active.compare_exchange_strong(
32 std::memory_order_acquire,
33 std::memory_order_relaxed)) {
34 m_pending_op.node = node;
48 uint32_t state = node->m_state.load();
54 uint32_t state = node->m_state.load();
59 bool expected =
false;
60 if (m_pending_op.active.compare_exchange_strong(
62 std::memory_order_acquire,
63 std::memory_order_relaxed)) {
65 m_pending_op.node = node;
78 if ((*it).get() == node.get()) {
84 node->reset_processed_state();
86 uint32_t flag = node->m_state.load();
98 bool expected =
false;
100 std::memory_order_acquire, std::memory_order_relaxed)) {
120 uint32_t state = node->m_state.load();
122 auto generator = std::dynamic_pointer_cast<Nodes::Generator::Generator>(node);
123 if (generator && generator->should_mock_process()) {
124 generator->process_sample();
126 sample += node->process_sample();
130 sample += node->get_last_output();
145 uint32_t state = node->m_state.load();
147 node->process_sample();
161 node->request_reset_from_channel(
m_channel);
170 std::vector<double> output(num_samples);
172 for (
unsigned int i = 0; i < num_samples; i++) {
180 for (uint32_t i = 0; i < num_frames; i++) {
189 if (m_pending_op.active.load(std::memory_order_acquire)) {
190 auto& op = m_pending_op;
191 uint32_t state = op.node->m_state.load();
202 if ((*it).get() == op.node.get()) {
208 op.node->reset_processed_state();
217 op.active.store(
false, std::memory_order_release);
static MayaFlux::Nodes::ProcessingToken token
void process_pending_operations()
Processes any pending node registration/unregistration operations.
std::vector< std::shared_ptr< Node > > m_Nodes
Collection of nodes registered with this root node.
uint32_t m_channel
The processing channel index for this root node.
RootNode(ProcessingToken token=ProcessingToken::AUDIO_RATE, uint32_t channel=0)
Constructs a RootNode for a specific processing token and channel.
void unregister_node(const std::shared_ptr< Node > &node)
Removes a node from this root node.
void process_frame()
Processes a single frame from all registered nodes.
bool preprocess()
Checks if the root node can process pending operations.
void register_node(const std::shared_ptr< Node > &node)
Adds a node to this root node.
std::atomic< bool > m_is_processing
Flag indicating if the root node is currently processing nodes.
double process_sample()
Processes a single sample from all registered nodes.
bool m_skip_state_management
Flag indicating whether to skip preprocessing and post processing.
void process_batch_frame(uint32_t num_frames)
Processes multiple frames from all registered nodes.
struct MayaFlux::Nodes::RootNode::PendingOp m_pending_ops[2048]
std::atomic< uint32_t > m_pending_count
Counter tracking the number of pending operations.
void postprocess()
Performs post-processing after all nodes have been processed.
std::vector< double > process_batch(uint32_t num_samples)
Processes all registered nodes and combines their outputs.
ProcessingToken
Enumerates the different processing domains for nodes.
void atomic_add_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically adds a flag to a node state.
void atomic_set_flag_strong(std::atomic< Utils::NodeState > &flag, const Utils::NodeState &desired)
Atomically sets a node state flag to a specific value.
void atomic_remove_flag(std::atomic< Utils::NodeState > &state, Utils::NodeState flag)
Atomically removes a flag from a node state.
Contains the node-based computational processing system components.
@ PENDING_REMOVAL
Node is marked for removal.
@ INACTIVE
Engine is not processing this node.
@ ACTIVE
Engine is processing this node.
@ PROCESSED
Node has been processed this cycle.