MayaFlux 0.2.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 70 of file NodeGraphManager.cpp.

71{
72 if (m_terminate_requested.load())
73 return;
74
75 auto roots = get_all_root_nodes(token);
76
77 if (auto it = m_token_processors.find(token); it != m_token_processors.end()) {
78 it->second(std::span<RootNode*>(roots.data(), roots.size()));
79 return;
80 }
81
83 return;
84 }
85
86 auto it = m_token_networks.find(token);
87 if (it != m_token_networks.end()) {
88 for (auto& network : it->second) {
89 if (!network || !network->is_enabled()) {
90 continue;
91 }
92
93 if (!network->is_processed_this_cycle()) {
94 network->mark_processing(true);
95 network->process_batch(num_samples);
96 network->mark_processing(false);
97 network->mark_processed(true);
98 }
99 }
100 }
101
102 postprocess_networks(token, std::nullopt);
103
105 for (auto* root : roots) {
106 root->process_batch(num_samples);
107 }
108 } else if (token == ProcessingToken::VISUAL_RATE) {
109 for (auto* root : roots) {
110 root->process_batch_frame(num_samples);
111 }
112 }
113}
static MayaFlux::Nodes::ProcessingToken token
Definition Timers.cpp:8
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, postprocess_networks(), preprocess_networks(), token, 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: