From 8456af6d8de03141087f124c7025b14de065f374 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 22 Nov 2025 17:50:51 +0100 Subject: [PATCH] Update I/O plugin port-names when plugin changes them --- libs/ardour/ardour/io_plug.h | 2 ++ libs/ardour/io_plug.cc | 63 ++++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/libs/ardour/ardour/io_plug.h b/libs/ardour/ardour/io_plug.h index 44f810b562..90210bba3c 100644 --- a/libs/ardour/ardour/io_plug.h +++ b/libs/ardour/ardour/io_plug.h @@ -59,6 +59,7 @@ public: int set_block_size (pframes_t); void set_public_latency (bool); bool ensure_io (); + void set_pretty_port_names (); bool is_pre () const { return _pre; } @@ -119,6 +120,7 @@ private: void create_parameters (); void parameter_changed_externally (uint32_t, float); void property_changed_externally (uint32_t, Variant); + void processor_change (RouteProcessorChange const&); void setup (); diff --git a/libs/ardour/io_plug.cc b/libs/ardour/io_plug.cc index ef02839204..fb190a9095 100644 --- a/libs/ardour/io_plug.cc +++ b/libs/ardour/io_plug.cc @@ -257,6 +257,7 @@ IOPlug::setup () _plugin->reconfigure_io (_n_in, aux_in, _n_out); _plugin->ParameterChangedExternally.connect_same_thread (*this, std::bind (&IOPlug::parameter_changed_externally, this, _1, _2)); _plugin->PropertyChanged.connect_same_thread (*this, std::bind (&IOPlug::property_changed_externally, this, _1, _2)); + _plugin->ProcessorChange.connect_same_thread (*this, std::bind (&IOPlug::processor_change, this, _1)); _plugin->activate (); _plugin->set_insert (this, 0); } @@ -384,6 +385,14 @@ IOPlug::property_changed_externally (uint32_t which, Variant val) } } +void +IOPlug::processor_change (RouteProcessorChange const& rpc) +{ + if (rpc & RouteProcessorChange::PortNameChange) { + set_pretty_port_names (); + } +} + int IOPlug::set_block_size (pframes_t n_samples) { @@ -400,21 +409,9 @@ IOPlug::ui_elements () const return rv; } -bool -IOPlug::ensure_io () +void +IOPlug::set_pretty_port_names () { - PBD::Unwinder uw (_configuring_io, true); - - /* must be called with process-lock held */ - if (_input->ensure_io (_n_in, false, this) != 0) { - return false; - } - if (_output->ensure_io (_n_out, false, this) != 0) { - return false; - } - - _bufs.ensure_buffers (ChanCount::max (_n_in, _n_out), _session.get_block_size ()); - for (uint32_t i = 0; i < _n_in.n_audio (); ++i) { const auto& pd (_plugin->describe_io_port (DataType::AUDIO, true, i)); std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name); @@ -435,17 +432,35 @@ IOPlug::ensure_io () std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name); _output->midi (i)->set_pretty_name (pn); } +} - if (_pre) { - for (uint32_t i = 0; i < _n_out.n_audio (); ++i) { - std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->audio (i)->name ()); - _audio_input_ports.insert (make_pair (n, PortManager::AudioInputPort (24288))); // 2^19 ~ 1MB / port - } - for (uint32_t i = 0; i < _n_out.n_midi (); ++i) { - std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->midi (i)->name ()); - _midi_input_ports.insert (make_pair (n, PortManager::MIDIInputPort (32))); - } - } +bool +IOPlug::ensure_io () +{ + PBD::Unwinder uw (_configuring_io, true); + + /* must be called with process-lock held */ + if (_input->ensure_io (_n_in, false, this) != 0) { + return false; + } + if (_output->ensure_io (_n_out, false, this) != 0) { + return false; + } + + _bufs.ensure_buffers (ChanCount::max (_n_in, _n_out), _session.get_block_size ()); + + set_pretty_port_names (); + + if (_pre) { + for (uint32_t i = 0; i < _n_out.n_audio (); ++i) { + std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->audio (i)->name ()); + _audio_input_ports.insert (make_pair (n, PortManager::AudioInputPort (24288))); // 2^19 ~ 1MB / port + } + for (uint32_t i = 0; i < _n_out.n_midi (); ++i) { + std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->midi (i)->name ()); + _midi_input_ports.insert (make_pair (n, PortManager::MIDIInputPort (32))); + } + } return true; }