VST3: disable MIDI busses before removing plugin

There is anecdotal evidence that some plugins require this
to exit cleanly.
This commit is contained in:
Robin Gareus
2020-09-30 16:43:42 +02:00
parent 8209b4b948
commit 814eca48af
2 changed files with 21 additions and 8 deletions

View File

@@ -151,6 +151,7 @@ private:
VST3PI (const VST3PI&);
void terminate ();
bool connect_components ();
bool disconnect_components ();
@@ -165,6 +166,8 @@ private:
void set_parameter_by_id (Vst::ParamID id, float value, int32 sample_off);
void set_parameter_internal (Vst::ParamID id, float& value, int32 sample_off, bool normalized);
void set_event_bus_state (bool enabled);
bool midi_controller (int32_t, int16_t, Vst::CtrlNumber, Vst::ParamID &id);
bool live_midi_cc (int32_t, int16_t, Vst::CtrlNumber);

View File

@@ -1078,14 +1078,7 @@ VST3PI::VST3PI (boost::shared_ptr<ARDOUR::VST3PluginModule> m, std::string uniqu
synchronize_states ();
/* enable all MIDI busses */
int32 n_bus_in = _component->getBusCount (Vst::kEvent, Vst::kInput);
int32 n_bus_out = _component->getBusCount (Vst::kEvent, Vst::kOutput);
for (int32 i = 0; i < n_bus_in; ++i) {
_component->activateBus (Vst::kEvent, Vst::kInput, i, true);
}
for (int32 i = 0; i < n_bus_out; ++i) {
_component->activateBus (Vst::kEvent, Vst::kOutput, i, true);
}
set_event_bus_state (true);
}
VST3PI::~VST3PI ()
@@ -1118,6 +1111,9 @@ VST3PI::unit_data ()
void
VST3PI::terminate ()
{
/* disable all MIDI busses */
set_event_bus_state (false);
deactivate ();
_processor = 0;
@@ -1765,6 +1761,20 @@ VST3PI::add_event (Evoral::Event<samplepos_t> const& ev, int32_t bus)
}
}
void
VST3PI::set_event_bus_state (bool enable)
{
int32 n_bus_in = _component->getBusCount (Vst::kEvent, Vst::kInput);
int32 n_bus_out = _component->getBusCount (Vst::kEvent, Vst::kOutput);
for (int32 i = 0; i < n_bus_in; ++i) {
_component->activateBus (Vst::kEvent, Vst::kInput, i, enable);
}
for (int32 i = 0; i < n_bus_out; ++i) {
_component->activateBus (Vst::kEvent, Vst::kOutput, i, enable);
}
}
void
VST3PI::enable_io (std::vector<bool> const& ins, std::vector<bool> const& outs)
{