From b14ce3137286d39854c9bbd798186dbc0d3308f0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 12 Aug 2025 18:56:24 +0200 Subject: [PATCH] Consolidate rt processor-changed signal emission Prefer a single signal and bit flags, instead of individual signals. This allows to call resort_route() at most once (if at all for certain changes). Notably Mixbus comp/gate/eq type changes can use NoProcessorChange to only request a GUI update. --- libs/ardour/route.cc | 30 +++++++++++++++++------------- libs/ardour/session.cc | 11 ++--------- libs/ardour/session_transport.cc | 12 ++++++++---- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index f3c57fda89..7f341606be 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1055,6 +1055,10 @@ inline Route::PluginSetupOptions operator&= (Route::PluginSetupOptions& a, const return a = static_cast (static_cast (a) & static_cast (b)); } +inline RouteProcessorChange::Type operator|= (RouteProcessorChange::Type& a, const RouteProcessorChange::Type& b) { + return a = static_cast (static_cast (a) | static_cast (b)); +} + int Route::add_processors (const ProcessorList& others, std::shared_ptr before, ProcessorStreams* err) { @@ -4231,20 +4235,20 @@ void Route::emit_pending_signals () { int sig = _pending_signals.fetch_and (0); - if (sig & EmitMeterChanged) { - _meter->emit_configuration_changed(); - meter_change (); /* EMIT SIGNAL */ - if (sig & EmitMeterVisibilityChange) { - processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */ - } else { - processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */ + + if (sig != 0) { + bool meter_viz_changed = (sig & (EmitMeterVisibilityChange | EmitMeterChanged)) == (EmitMeterVisibilityChange | EmitMeterChanged); + RouteProcessorChange::Type t = RouteProcessorChange::NoProcessorChange; + if (sig & EmitRtProcessorChange) { + t |= RouteProcessorChange::RealTimeChange; } - } - if (sig & EmitRtProcessorChange) { - processors_changed (RouteProcessorChange (RouteProcessorChange::RealTimeChange)); /* EMIT SIGNAL */ - } - if (sig & EmitSendReturnChange) { - processors_changed (RouteProcessorChange (RouteProcessorChange::SendReturnChange, false)); /* EMIT SIGNAL */ + if (sig & EmitSendReturnChange) { + t |= RouteProcessorChange::SendReturnChange; + } + if (sig & EmitMeterVisibilityChange) { + t |= RouteProcessorChange::MeterPointChange; + } + processors_changed (RouteProcessorChange (t, meter_viz_changed)); } /* this would be a job for the butler. diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 77554547c9..9b00b17062 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -8166,15 +8166,8 @@ Session::ProcessorChangeBlocker::~ProcessorChangeBlocker () if (PBD::atomic_dec_and_test (_session->_ignore_route_processor_changes)) { RouteProcessorChange::Type type = (RouteProcessorChange::Type) _session->_ignored_a_processor_change.fetch_and (0); if (_reconfigure_on_delete) { - if (type & RouteProcessorChange::GeneralChange) { - _session->route_processors_changed (RouteProcessorChange ()); - } else { - if (type & RouteProcessorChange::MeterPointChange) { - _session->route_processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange)); - } - if (type & RouteProcessorChange::RealTimeChange) { - _session->route_processors_changed (RouteProcessorChange (RouteProcessorChange::RealTimeChange)); - } + if (type != RouteProcessorChange::NoProcessorChange) { + _session->route_processors_changed (type); } } } diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 68d8321024..7938daf323 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1963,21 +1963,25 @@ Session::route_processors_changed (RouteProcessorChange c) return; } - if (c.type == RouteProcessorChange::MeterPointChange) { - /* sort rec-armed routes first */ + if (c.type == RouteProcessorChange::NoProcessorChange) { + return; + } + + if (c.type & RouteProcessorChange::MeterPointChange) { + /* sort rec-armed routes to be processed first */ resort_routes (); set_dirty (); return; } - if (c.type == RouteProcessorChange::RealTimeChange) { + if (c.type & RouteProcessorChange::RealTimeChange) { set_dirty (); return; } resort_routes (); - if (c.type == RouteProcessorChange::SendReturnChange) { + if (c.type & RouteProcessorChange::SendReturnChange) { update_latency_compensation (true, false); } else { update_latency_compensation (false, false);