MayaFlux 0.3.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 78 of file NodeGraphManager.cpp.

79{
80 if (m_terminate_requested.load())
81 return;
82
83 auto roots = get_all_root_nodes(token);
84
85 if (auto it = m_token_processors.find(token); it != m_token_processors.end()) {
86 it->second(std::span<RootNode*>(roots.data(), roots.size()));
87 return;
88 }
89
90 if (!preprocess_networks(token)) {
91 return;
92 }
93
94 auto it = m_token_networks.find(token);
95 if (it != m_token_networks.end()) {
96 for (auto& network : it->second) {
97 if (!network || !network->is_enabled()) {
98 continue;
99 }
100
101 if (!network->is_processed_this_cycle()) {
102 network->mark_processing(true);
103 network->process_batch(num_samples);
104 network->mark_processing(false);
105 network->mark_processed(true);
106 }
107 }
108 }
109
110 postprocess_networks(token, std::nullopt);
111
112 if (token == ProcessingToken::AUDIO_RATE) {
113 for (auto* root : roots) {
114 root->process_batch(num_samples);
115 }
116 } else if (token == ProcessingToken::VISUAL_RATE) {
117 for (auto* root : roots) {
118 root->process_batch_frame(num_samples);
119 }
120 }
121}
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(), 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: