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

◆ cleanup_completed_routing()

void MayaFlux::Nodes::NodeGraphManager::cleanup_completed_routing ( ProcessingToken  token)

Cleans up completed routing transitions for a given token.

Parameters
tokenProcessing domain to clean up routing for

This method should be called after routing states have been updated to remove any nodes or networks that have completed their fade-out transitions and are no longer contributing to the output of their previous channels.

Definition at line 732 of file NodeGraphManager.cpp.

733{
734 std::vector<std::pair<std::shared_ptr<Node>, uint32_t>> nodes_to_remove;
735
736 for (const auto& node : m_node_registry) {
737 if (!node->needs_channel_routing())
738 continue;
739
740 auto& state = node->get_routing_state();
741
742 if (state.phase == RoutingState::COMPLETED) {
743 for (uint32_t ch = 0; ch < 32; ch++) {
744 if ((state.from_channels & (1 << ch)) && !(state.to_channels & (1 << ch))) {
745 nodes_to_remove.emplace_back(node, ch);
746 }
747 }
748 state = RoutingState {};
749 }
750 }
751
752 for (auto& [node, channel] : nodes_to_remove) {
753 remove_from_root(node, token, channel);
754 }
755
756 std::vector<std::pair<std::shared_ptr<Network::NodeNetwork>, uint32_t>> networks_to_cleanup;
757
758 for (const auto& network : get_all_networks(token)) {
759 if (!network || !network->needs_channel_routing())
760 continue;
761
762 auto& state = network->get_routing_state();
763
764 if (state.phase == RoutingState::COMPLETED) {
765 network->set_channel_mask(state.to_channels);
766
767 for (uint32_t ch = 0; ch < 32; ch++) {
768 if ((state.from_channels & (1 << ch)) && !(state.to_channels & (1 << ch))) {
769 networks_to_cleanup.emplace_back(network, ch);
770 }
771 }
772 state = RoutingState {};
773 }
774 }
775
776 for (auto& [network, channel] : networks_to_cleanup) {
777 network->remove_channel_usage(channel);
778
779 if (network->get_channel_mask() == 0) {
780 auto& networks = m_audio_networks[token];
781 std::erase_if(networks, [&](const auto& n) { return n == network; });
783 }
784 }
785}
Core::GlobalNetworkConfig network
Definition Config.cpp:37
std::unordered_set< std::shared_ptr< Node > > m_node_registry
Registry of all nodes by their string identifiers.
std::vector< std::shared_ptr< Network::NodeNetwork > > get_all_networks(ProcessingToken token) const
Get all networks for a specific token across all channels.
void remove_from_root(const std::shared_ptr< Node > &node, ProcessingToken token, unsigned int channel=0)
Remove node from a specific processing token and channel.
std::unordered_map< ProcessingToken, std::vector< std::shared_ptr< Network::NodeNetwork > > > m_audio_networks
Audio-sink networks Only populated for networks with OutputMode::AUDIO_SINK.
void unregister_network_global(const std::shared_ptr< Network::NodeNetwork > &network)
Unregister network globally.
@ COMPLETED
Routing transition has completed.
Definition NodeSpec.hpp:82

References MayaFlux::Nodes::RoutingState::COMPLETED, get_all_networks(), m_audio_networks, m_node_registry, network, remove_from_root(), and unregister_network_global().

+ Here is the call graph for this function: