Update names of sidechains.

When a PluginInsert is created it does not have an owner right away. That's why
a we need to set the sidechains name once the owner is known, in order to
include owner's name into the name.

Furthermore we need to follow renames of the owner.
This commit is contained in:
Johannes Mueller 2018-10-27 21:36:21 +02:00
parent 9a01ef35e7
commit 732fd75f9b
3 changed files with 38 additions and 3 deletions

View File

@ -170,6 +170,7 @@ public:
bool set_preset_out (const ChanCount&);
bool add_sidechain (uint32_t n_audio = 1, uint32_t n_midi = 0);
bool del_sidechain ();
void update_sidechain_name ();
boost::shared_ptr<SideChain> sidechain () const { return _sidechain; }
// end C++ class slavery!

View File

@ -206,10 +206,12 @@ PluginInsert::add_sidechain (uint32_t n_audio, uint32_t n_midi)
return false;
}
std::ostringstream n;
if (n_audio > 0 || n_midi > 0) {
n << "Sidechain " << Session::next_name_id ();
} else {
if (n_audio == 0 && n_midi == 0) {
n << "TO BE RESET FROM XML";
} else if (owner()) {
n << "SC " << owner()->name() << "/" << name() << " " << Session::next_name_id ();
} else {
n << "tobeRenamed";
}
SideChain *sc = new SideChain (_session, n.str ());
_sidechain = boost::shared_ptr<SideChain> (sc);
@ -237,6 +239,25 @@ PluginInsert::del_sidechain ()
return true;
}
void
PluginInsert::update_sidechain_name ()
{
if (!_sidechain) {
return;
}
std::ostringstream n;
n << "SC ";
if (owner()) {
n << owner()->name() << "/";
}
n << name() << " " << Session::next_name_id ();
_sidechain->set_name (n.str());
}
void
PluginInsert::control_list_automation_state_changed (Evoral::Parameter which, AutoState s)
{

View File

@ -849,6 +849,11 @@ Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<
processor->activate ();
}
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
if (pi) {
pi->update_sidechain_name ();
}
return 0;
}
@ -4269,6 +4274,14 @@ Route::set_name (const string& str)
SessionObject::set_name (newname);
for (uint32_t n = 0 ; ; ++n) {
boost::shared_ptr<PluginInsert> pi = boost::static_pointer_cast<PluginInsert> (nth_plugin (n));
if (!pi) {
break;
}
pi->update_sidechain_name ();
}
bool ret = (_input->set_name(newname) && _output->set_name(newname));
if (ret) {