Skip to content

Commit

Permalink
VstEmbed: Support changing embed method without restart
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Nov 10, 2017
1 parent 3e6e6bb commit 09058c1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 22 deletions.
8 changes: 5 additions & 3 deletions include/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include <QtCore/QPair>
#include <QtCore/QStringList>
#include <QtCore/QVector>
#include <QtCore/QObject>

#include "export.h"
#include "MemoryManager.h"

class LmmsCore;

Expand All @@ -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()
{
Expand Down Expand Up @@ -244,6 +244,8 @@ class EXPORT ConfigManager
// creates the working directory & subdirectories on disk.
void createWorkingDir();

signals:
void valueChanged( QString cls, QString attribute, QString value );

private:
static ConfigManager * s_instanceOfMe;
Expand Down
23 changes: 19 additions & 4 deletions plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QMenu>
#include <QDomElement>

#include "ConfigManager.h"
#include "BufferManager.h"
#include "Engine.h"
#include "gui_templates.h"
Expand Down Expand Up @@ -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 );
}


Expand Down Expand Up @@ -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 );
}




Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions plugins/vestige/vestige.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class vestigeInstrument : public Instrument

protected slots:
void setParameter( void );
void handleConfigChange( QString cls, QString attr, QString value );
void reloadPlugin();

private:
void closePlugin( void );
Expand Down
2 changes: 1 addition & 1 deletion plugins/vst_base/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ void VstPlugin::showUI()

void VstPlugin::hideUI()
{
RemotePlugin::hideUI();
if ( m_embedMethod == "none" )
{
RemotePlugin::hideUI();
}
else if ( pluginWidget() != nullptr )
{
Expand Down
11 changes: 7 additions & 4 deletions src/core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
24 changes: 14 additions & 10 deletions src/gui/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 );
}
}


Expand Down

0 comments on commit 09058c1

Please sign in to comment.