MayaFlux 0.4.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 109 of file NodeGraphManager.cpp.

110{
111 if (m_terminate_requested.load())
112 return;
113
114 auto roots = get_all_root_nodes(token);
115
116 if (auto it = m_token_processors.find(token); it != m_token_processors.end()) {
117 it->second(std::span<RootNode*>(roots.data(), roots.size()));
118 return;
119 }
120
121 if (!preprocess_networks(token)) {
122 return;
123 }
124
125 auto it = m_token_networks.find(token);
126 if (it != m_token_networks.end()) {
127 for (auto& network : it->second) {
128 if (!network || !network->is_enabled()) {
129 continue;
130 }
131
132 if (!network->is_processed_this_cycle()) {
133 network->mark_processing(true);
134 network->process_batch(num_samples);
135 network->mark_processing(false);
136 network->mark_processed(true);
137 }
138 }
139 }
140
141 postprocess_networks(token, std::nullopt);
142
143 if (token == ProcessingToken::AUDIO_RATE) {
144 for (auto* root : roots) {
145 root->process_batch(num_samples);
146 }
147 } else if (token == ProcessingToken::VISUAL_RATE) {
148 for (auto* root : roots) {
149 root->process_batch_frame(num_samples);
150 }
151 }
152}
Core::GlobalNetworkConfig network
Definition Config.cpp:37
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: