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

◆ cleanup_completed_routing()

void MayaFlux::Buffers::BufferSupplyMixing::cleanup_completed_routing ( ProcessingToken  token)

Cleans up completed routing transitions.

Parameters
tokenProcessing domain to clean up

Removes buffers from old channels and finalizes registration to new channels after fade completion.

Definition at line 269 of file BufferSupplyMixing.cpp.

270{
271 if (!m_unit_manager.has_audio_unit(token)) {
272 return;
273 }
274
275 auto& unit = m_unit_manager.get_audio_unit_mutable(token);
276
277 std::vector<std::tuple<std::shared_ptr<AudioBuffer>, uint32_t, uint32_t>> buffers_to_move;
278
279 for (uint32_t channel = 0; channel < unit.channel_count; ++channel) {
280 auto root_buffer = unit.get_buffer(channel);
281
282 for (auto& child : root_buffer->get_child_buffers()) {
283 if (!child->needs_routing()) {
284 continue;
285 }
286
287 auto& state = child->get_routing_state();
288
289 if (state.phase == BufferRoutingState::COMPLETED) {
290 buffers_to_move.emplace_back(child, state.from_channel, state.to_channel);
291 }
292 }
293 }
294
295 for (auto& [buffer, from_ch, to_ch] : buffers_to_move) {
296 auto root_from = unit.get_buffer(from_ch);
297 auto root_to = unit.get_buffer(to_ch);
298
299 root_from->remove_child_buffer(buffer);
300
301 buffer->set_channel_id(to_ch);
302 root_to->add_child_buffer(buffer);
303
304 remove_supplied_audio_buffer(buffer, token, to_ch);
305
306 buffer->get_routing_state() = BufferRoutingState {};
307 }
308}
bool remove_supplied_audio_buffer(const std::shared_ptr< AudioBuffer > &buffer, ProcessingToken token, uint32_t channel)
Removes a previously supplied buffer from a token and channel.
TokenUnitManager & m_unit_manager
Reference to the token/unit manager.
bool has_audio_unit(ProcessingToken token) const
Checks if an audio unit exists for the given token.
RootAudioUnit & get_audio_unit_mutable(ProcessingToken token)
Gets an existing audio unit without creating if missing (mutable)
std::shared_ptr< RootAudioBuffer > get_buffer(uint32_t channel) const

References MayaFlux::Buffers::BufferRoutingState::COMPLETED, MayaFlux::Buffers::TokenUnitManager::get_audio_unit_mutable(), MayaFlux::Buffers::RootAudioUnit::get_buffer(), MayaFlux::Buffers::TokenUnitManager::has_audio_unit(), m_unit_manager, and remove_supplied_audio_buffer().

+ Here is the call graph for this function: