9 return std::ranges::any_of(callbacks,
10 [&callback](
const std::pair<NodeHook, NodeCondition>& pair) {
11 return pair.second.target_type() == callback.target_type();
17 return std::ranges::any_of(callbacks,
18 [&callback, &condition](
const std::pair<NodeHook, NodeCondition>& pair) {
19 return pair.first.target_type() == callback.target_type() && pair.second.target_type() == condition.target_type();
26 callbacks.emplace_back(callback, condition);
35 auto it = callbacks.begin();
37 while (it != callbacks.end()) {
38 if (it->second.target_type() == callback.target_type()) {
39 it = callbacks.erase(it);
51 flag.compare_exchange_strong(expected, desired);
56 auto expected = flag.load();
57 flag.compare_exchange_strong(expected, desired);
62 auto current = state.load();
65 desired =
static_cast<NodeState>(current | flag);
66 }
while (!state.compare_exchange_weak(current, desired,
67 std::memory_order_acq_rel,
68 std::memory_order_acquire));
73 auto current = state.load();
76 desired =
static_cast<NodeState>(current & ~flag);
77 }
while (!state.compare_exchange_weak(current, desired,
78 std::memory_order_acq_rel,
79 std::memory_order_acquire));
84 flag.compare_exchange_weak(expected, desired);
89 count.fetch_add(amount, std::memory_order_relaxed);
94 count.fetch_sub(amount, std::memory_order_relaxed);
99 if (node && node->m_modulator_count.load(std::memory_order_relaxed) == 0) {
100 node->reset_processed_state();
104std::vector<uint32_t>
get_active_channels(
const std::shared_ptr<Nodes::Node>& node, uint32_t fallback_channel)
106 uint32_t channel_mask = node ? node->get_channel_mask().load() : 0;
112 std::vector<uint32_t> channels;
114 if (channel_mask == 0) {
115 channels.push_back(fallback_channel);
118 if (channel_mask & (1ULL <<
channel)) {
131 double progress = 0.;
135 for (uint32_t ch = 0; ch < 32; ++ch) {
137 state.
amount[ch] = will_be_in ? 1.0 : 0.0;
143 for (uint32_t ch = 0; ch < 32; ch++) {
147 if (was_in && will_be_in) {
149 }
else if (was_in && !will_be_in) {
150 state.
amount[ch] = 1.0 - progress;
151 }
else if (!was_in && will_be_in) {
152 state.
amount[ch] = progress;
TypedHook<> NodeHook
Alias for TypedHook<NodeContext>.
NodeState
Represents the processing state of a node in the audio graph.
bool callback_pair_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Returns true if the exact callback+condition pair is already present.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
bool safe_remove_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Removes all conditional callbacks whose condition target_type() matches.
constexpr uint32_t MAX_CHANNEL_COUNT
Hard limit imposed by uint32_t channel mask width.
std::vector< uint32_t > get_active_channels(const std::shared_ptr< Nodes::Node > &node, uint32_t fallback_channel)
Extracts active channel list from a node's channel mask.
void atomic_set_strong(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with strong memory ordering.
bool conditional_callback_exists(const std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeCondition &callback)
Returns true if a condition function is already present in a conditional callback collection.
void try_reset_processed_state(std::shared_ptr< Node > node)
Attempts to reset the processed state of a node.
void atomic_inc_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically increments the modulator count by a specified amount.
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.
void atomic_set_flag_strong(std::atomic< NodeState > &flag, const NodeState &desired)
Atomically sets a node state flag to a specific value.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
void atomic_dec_modulator_count(std::atomic< uint32_t > &count, int amount)
Atomically decrements the modulator count by a specified amount.
bool safe_add_conditional_callback(std::vector< std::pair< NodeHook, NodeCondition > > &callbacks, const NodeHook &callback, const NodeCondition &condition)
Adds a conditional callback if the exact pair is not already present.
void atomic_set_flag_weak(std::atomic< NodeState > &flag, NodeState &expected, const NodeState &desired)
Atomically sets a node state flag with weak memory ordering.
void update_routing_state(RoutingState &state)
Updates the routing state for a node based on its current channel usage.
Contains the node-based computational processing system components.
enum MayaFlux::Nodes::RoutingState::Phase NONE
@ COMPLETED
Routing transition has completed.
Represents the state of routing transitions for a node.