13
0

Only emit InstrumentInfo::Changed() on actual change

Ignore plugin re-order, meter-pos changes and other cases where
Route calls reset_instrument_info()
This commit is contained in:
Robin Gareus 2017-09-09 18:19:25 +02:00
parent b9f2a2ab3f
commit ba2114644d

View File

@ -49,6 +49,9 @@ InstrumentInfo::~InstrumentInfo ()
void
InstrumentInfo::set_external_instrument (const string& model, const string& mode)
{
if (external_instrument_model == model && external_instrument_mode == mode && internal_instrument.expired ()) {
return;
}
external_instrument_model = model;
external_instrument_mode = mode;
internal_instrument.reset ();
@ -58,6 +61,7 @@ InstrumentInfo::set_external_instrument (const string& model, const string& mode
void
InstrumentInfo::set_internal_instrument (boost::shared_ptr<Processor> p)
{
bool changed = !external_instrument_mode.empty ();
external_instrument_mode = "";
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(p);
@ -67,17 +71,24 @@ InstrumentInfo::set_internal_instrument (boost::shared_ptr<Processor> p)
* InstrumentInfo::get_plugin_patch_name() needs to be overhauled,
* it limits all PluginInsert to generic-midi or only numbers.
*/
changed |= !internal_instrument.expired ();
changed |= external_instrument_model != pi->plugin ()->midnam_model ();
internal_instrument.reset ();
external_instrument_model = pi->plugin ()->midnam_model ();
const std::list<std::string> device_modes = MIDI::Name::MidiPatchManager::instance().custom_device_mode_names_by_model (external_instrument_model);
if (device_modes.size() > 0) {
changed |= external_instrument_mode != device_modes.front();
external_instrument_mode = device_modes.front();
}
} else {
changed |= internal_instrument.lock () != p || external_instrument_model != _("Unknown");
internal_instrument = p;
external_instrument_model = (_("Unknown"));
external_instrument_model = _("Unknown");
}
if (changed) {
Changed(); /* EMIT SIGNAL */
}
Changed(); /* EMIT SIGNAL */
}
string