Fixes #6401: Reload Lv2 plugin on SR change

This also includes banning blop's wavedata plugins, because they crash
on reloading. Reference: https://gitlab.com/drobilla/blop-lv2/-/issues/3
This commit is contained in:
Johannes Lorenz
2022-06-04 23:11:04 +02:00
committed by Johannes Lorenz
parent 7649f5ed24
commit f48dd0fb1f
13 changed files with 168 additions and 41 deletions

View File

@@ -38,7 +38,7 @@ Lv2FxControlDialog::Lv2FxControlDialog(Lv2FxControls *controls) :
{
if (m_reloadPluginButton) {
connect(m_reloadPluginButton, &QPushButton::clicked,
this, [this](){ lv2Controls()->reloadPlugin(); });
this, [this](){ lv2Controls()->reload(); });
}
if (m_toggleUIButton) {
connect(m_toggleUIButton, &QPushButton::toggled,
@@ -67,7 +67,9 @@ Lv2FxControls *Lv2FxControlDialog::lv2Controls()
void Lv2FxControlDialog::modelChanged()
{
Lv2ViewBase::modelChanged(lv2Controls());
connect(lv2Controls(), &Lv2FxControls::modelChanged,
this, [this](){ this->modelChanged();} );
}
} // namespace lmms::gui
} // namespace lmms::gui

View File

@@ -45,7 +45,7 @@ public:
private:
Lv2FxControls *lv2Controls();
void modelChanged() override;
void modelChanged() final;
};

View File

@@ -41,13 +41,33 @@ Lv2FxControls::Lv2FxControls(class Lv2Effect *effect, const QString& uri) :
if (isValid())
{
connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged,
this, [this](){Lv2ControlBase::reloadPlugin();});
this, [this](){onSampleRateChanged();});
}
}
void Lv2FxControls::reload()
{
Lv2ControlBase::reload();
emit modelChanged();
}
void Lv2FxControls::onSampleRateChanged()
{
// TODO: once lv2 options are implemented,
// plugins that support it might allow changing their samplerate
// through it instead of reloading
reload();
}
void Lv2FxControls::saveSettings(QDomDocument &doc, QDomElement &that)
{
Lv2ControlBase::saveSettings(doc, that);

View File

@@ -43,8 +43,11 @@ class Lv2FxControlDialog;
class Lv2FxControls : public EffectControls, public Lv2ControlBase
{
Q_OBJECT
signals:
void modelChanged();
public:
Lv2FxControls(Lv2Effect *effect, const QString &uri);
void reload();
void saveSettings(QDomDocument &_doc, QDomElement &_parent) override;
void loadSettings(const QDomElement &that) override;
@@ -60,6 +63,8 @@ private slots:
void changeControl();
private:
void onSampleRateChanged();
friend class gui::Lv2FxControlDialog;
friend class Lv2Effect;
};

View File

@@ -78,10 +78,12 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg,
{
if (Lv2ControlBase::isValid())
{
clearRunningNotes();
connect(instrumentTrack()->pitchRangeModel(), SIGNAL(dataChanged()),
this, SLOT(updatePitchRange()), Qt::DirectConnection);
connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged,
this, [this](){Lv2ControlBase::reloadPlugin();});
this, [this](){onSampleRateChanged();});
// now we need a play-handle which cares for calling play()
auto iph = new InstrumentPlayHandle(this, instrumentTrackArg);
@@ -101,6 +103,37 @@ Lv2Instrument::~Lv2Instrument()
void Lv2Instrument::reload()
{
Lv2ControlBase::reload();
clearRunningNotes();
emit modelChanged();
}
void Lv2Instrument::clearRunningNotes()
{
#ifdef LV2_INSTRUMENT_USE_MIDI
for (int i = 0; i < NumKeys; ++i) { m_runningNotes[i] = 0; }
#endif
}
void Lv2Instrument::onSampleRateChanged()
{
// TODO: once lv2 options are implemented,
// plugins that support it might allow changing their samplerate
// through it instead of reloading
reload();
}
bool Lv2Instrument::isValid() const { return Lv2ControlBase::isValid(); }
@@ -211,7 +244,7 @@ Lv2InsView::Lv2InsView(Lv2Instrument *_instrument, QWidget *_parent) :
setAutoFillBackground(true);
if (m_reloadPluginButton) {
connect(m_reloadPluginButton, &QPushButton::clicked,
this, [this](){ this->castModel<Lv2Instrument>()->reloadPlugin();} );
this, [this](){ this->castModel<Lv2Instrument>()->reload();} );
}
if (m_toggleUIButton) {
connect(m_toggleUIButton, &QPushButton::toggled,
@@ -267,6 +300,8 @@ void Lv2InsView::dropEvent(QDropEvent *_de)
void Lv2InsView::modelChanged()
{
Lv2ViewBase::modelChanged(castModel<Lv2Instrument>());
connect(castModel<Lv2Instrument>(), &Lv2Instrument::modelChanged,
this, [this](){ this->modelChanged();} );
}

View File

@@ -50,6 +50,8 @@ class Lv2InsView;
class Lv2Instrument : public Instrument, public Lv2ControlBase
{
Q_OBJECT
signals:
void modelChanged();
public:
/*
initialization
@@ -57,6 +59,8 @@ public:
Lv2Instrument(InstrumentTrack *instrumentTrackArg,
Descriptor::SubPluginFeatures::Key* key);
~Lv2Instrument() override;
void reload();
void onSampleRateChanged();
//! Must be checked after ctor or reload
bool isValid() const;
@@ -101,6 +105,7 @@ private:
#ifdef LV2_INSTRUMENT_USE_MIDI
std::array<int, NumKeys> m_runningNotes = {};
#endif
void clearRunningNotes();
friend class gui::Lv2InsView;
};