MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ process_token()

void MayaFlux::Nodes::NodeGraphManager::process_token ( ProcessingToken  token,
unsigned int  num_samples = 1 
)

Process all nodes in a specific token domain Calls registered processor if available, otherwise calls process() on each root.

Parameters
tokenProcessing domain to process
num_samplesNumber of samples/frames to process

Processes all root nodes for the specified processing domain (token). If a custom processor is registered for the token, it is called with all root nodes. Otherwise, process() is called on each root node individually.

Definition at line 112 of file NodeGraphManager.cpp.

113{
114 if (m_terminate_requested.load())
115 return;
116
117 auto roots = get_all_root_nodes(token);
118
119 if (auto it = m_token_processors.find(token); it != m_token_processors.end()) {
120 it->second(std::span<RootNode*>(roots.data(), roots.size()));
121 return;
122 }
123
124 if (!preprocess_networks(token)) {
125 return;
126 }
127
128 auto it = m_token_networks.find(token);
129 if (it != m_token_networks.end()) {
130 for (auto& network : it->second) {
131 if (!network || !network->is_enabled()) {
132 continue;
133 }
134
135 if (!network->is_processed_this_cycle()) {
136 network->mark_processing(true);
137 network->process_batch(num_samples);
138 network->mark_processing(false);
139 network->mark_processed(true);
140 }
141 }
142 }
143
144 postprocess_networks(token, std::nullopt);
145
146 if (token == ProcessingToken::AUDIO_RATE) {
147 for (auto* root : roots) {
148 root->process_batch(num_samples);
149 }
150 } else if (token == ProcessingToken::VISUAL_RATE) {
151 for (auto* root : roots) {
152 root->process_batch_frame(num_samples);
153 }
154 }
155}
Core::GlobalNetworkConfig network
Definition Config.cpp:43
std::unordered_map< ProcessingToken, std::vector< std::shared_ptr< Network::NodeNetwork > > > m_token_networks
Non-audio networks (token-level processing) For NONE, GRAPHICS_BIND, CUSTOM output modes.
std::atomic< bool > m_terminate_requested
Global termination flag.
std::unordered_map< ProcessingToken, std::function< void(std::span< RootNode * >)> > m_token_processors
Registered custom processors for each processing token.
bool preprocess_networks(ProcessingToken token)
Preprocess networks for a specific token.
void postprocess_networks(ProcessingToken token, std::optional< uint32_t > channel)
Postprocess networks for a specific token and channel.
std::vector< RootNode * > get_all_root_nodes(ProcessingToken token)
Get spans of root nodes for a token (for custom processing)
@ AUDIO_RATE
Nodes that process at the audio sample rate.
@ VISUAL_RATE
Nodes that process at the visual frame rate.

References MayaFlux::Nodes::AUDIO_RATE, get_all_root_nodes(), m_terminate_requested, m_token_networks, m_token_processors, network, postprocess_networks(), preprocess_networks(), and MayaFlux::Nodes::VISUAL_RATE.

Referenced by process_all_tokens().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: