VstEmbed: Support changing embed method without restart

This commit is contained in:
Lukas W
2017-11-10 09:18:40 +01:00
parent f9f4d0cb9c
commit 358a251cff
6 changed files with 48 additions and 22 deletions

View File

@@ -32,9 +32,9 @@
#include <QtCore/QPair>
#include <QtCore/QStringList>
#include <QtCore/QVector>
#include <QtCore/QObject>
#include "export.h"
#include "MemoryManager.h"
class LmmsCore;
@@ -51,9 +51,9 @@ const QString TRACK_ICON_PATH = "track_icons/";
const QString LOCALE_PATH = "locale/";
class EXPORT ConfigManager
class EXPORT ConfigManager : public QObject
{
MM_OPERATORS
Q_OBJECT
public:
static inline ConfigManager * inst()
{
@@ -244,6 +244,8 @@ public:
// creates the working directory & subdirectories on disk.
void createWorkingDir();
signals:
void valueChanged( QString cls, QString attribute, QString value );
private:
static ConfigManager * s_instanceOfMe;

View File

@@ -32,6 +32,7 @@
#include <QMenu>
#include <QDomElement>
#include "ConfigManager.h"
#include "BufferManager.h"
#include "Engine.h"
#include "gui_templates.h"
@@ -89,6 +90,10 @@ vestigeInstrument::vestigeInstrument( InstrumentTrack * _instrument_track ) :
// now we need a play-handle which cares for calling play()
InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track );
Engine::mixer()->addPlayHandle( iph );
connect( ConfigManager::inst(), SIGNAL( valueChanged(QString,QString,QString) ),
this, SLOT( handleConfigChange(QString, QString, QString) ),
Qt::QueuedConnection );
}
@@ -170,6 +175,20 @@ void vestigeInstrument::setParameter( void )
}
}
void vestigeInstrument::handleConfigChange(QString cls, QString attr, QString value)
{
if ( cls == "ui" && attr == "vstembedmethod" )
{
reloadPlugin();
}
}
void vestigeInstrument::reloadPlugin()
{
closePlugin();
loadFile( m_pluginDLL );
}
@@ -366,10 +385,6 @@ void vestigeInstrument::closePlugin( void )
}
m_pluginMutex.lock();
if( m_plugin )
{
delete m_plugin->pluginWidget();
}
delete m_plugin;
m_plugin = NULL;
m_pluginMutex.unlock();

View File

@@ -74,6 +74,8 @@ public:
protected slots:
void setParameter( void );
void handleConfigChange( QString cls, QString attr, QString value );
void reloadPlugin();
private:
void closePlugin( void );

View File

@@ -587,9 +587,9 @@ void VstPlugin::showUI()
void VstPlugin::hideUI()
{
RemotePlugin::hideUI();
if ( m_embedMethod == "none" )
{
RemotePlugin::hideUI();
}
else if ( pluginWidget() != nullptr )
{

View File

@@ -352,12 +352,15 @@ void ConfigManager::setValue( const QString & cls,
{
if( m_settings.contains( cls ) )
{
for( stringPairVector::iterator it = m_settings[cls].begin();
it != m_settings[cls].end(); ++it )
for( QPair<QString, QString>& pair : m_settings[cls])
{
if( ( *it ).first == attribute )
if( pair.first == attribute )
{
( *it ).second = value;
if ( pair.second != value )
{
pair.second = value;
emit valueChanged( cls, attribute, value );
}
return;
}
}

View File

@@ -1019,6 +1019,20 @@ SetupDialog::~SetupDialog()
void SetupDialog::accept()
{
if( m_warnAfterSetup )
{
QMessageBox::information( NULL, tr( "Restart LMMS" ),
tr( "Please note that most changes "
"won't take effect until "
"you restart LMMS!" ),
QMessageBox::Ok );
}
// Hide dialog before setting values. This prevents an obscure bug
// where non-embedded VST windows would steal focus and prevent LMMS
// from taking mouse input, rendering the application unusable.
QDialog::accept();
ConfigManager::inst()->setValue( "mixer", "framesperaudiobuffer",
QString::number( m_bufferSize ) );
ConfigManager::inst()->setValue( "mixer", "audiodev",
@@ -1094,16 +1108,6 @@ void SetupDialog::accept()
}
ConfigManager::inst()->saveConfigFile();
QDialog::accept();
if( m_warnAfterSetup )
{
QMessageBox::information( NULL, tr( "Restart LMMS" ),
tr( "Please note that most changes "
"won't take effect until "
"you restart LMMS!" ),
QMessageBox::Ok );
}
}