Skip to content
Permalink
Browse files

Support more than 62 simultaneous VST plugins for Qt<5.10

  • Loading branch information...
DomClark authored and zonkmachine committed Dec 2, 2018
1 parent 614bca7 commit 9c9290eeeba73ed4e8ad7ec56411056dde56fb33
Showing with 29 additions and 7 deletions.
  1. +10 −1 include/RemotePlugin.h
  2. +19 −6 src/core/RemotePlugin.cpp
@@ -755,9 +755,15 @@ class ProcessWatcher : public QThread
}


void quit()
void stop()
{
m_quit = true;
quit();
}

void reset()
{
m_quit = false;
}

private:
@@ -864,6 +870,9 @@ public slots:
QProcess m_process;
ProcessWatcher m_watcher;

QString m_exec;
QStringList m_args;

QMutex m_commMutex;
bool m_splitChannels;
#ifdef USE_QT_SHMEM
@@ -54,7 +54,10 @@ ProcessWatcher::ProcessWatcher( RemotePlugin * _p ) :

void ProcessWatcher::run()
{
while( !m_quit && m_plugin->isRunning() )
m_plugin->m_process.start( m_plugin->m_exec, m_plugin->m_args );
exec();
m_plugin->m_process.moveToThread( m_plugin->thread() );
while( !m_quit && m_plugin->messagesLeft() )
{
msleep( 200 );
}
@@ -120,14 +123,19 @@ RemotePlugin::RemotePlugin() :
qWarning( "Unable to start the server." );
}
#endif
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
this, SLOT( processFinished( int, QProcess::ExitStatus ) ),
Qt::DirectConnection );
connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
&m_watcher, SLOT( quit() ), Qt::DirectConnection );
}




RemotePlugin::~RemotePlugin()
{
m_watcher.quit();
m_watcher.stop();
m_watcher.wait();

if( m_failed == false )
@@ -200,6 +208,11 @@ bool RemotePlugin::init(const QString &pluginExecutable,
return failed();
}

// ensure the watcher is ready in case we're running again
// (e.g. 32-bit VST plugins on Windows)
m_watcher.wait();
m_watcher.reset();

QStringList args;
#ifdef SYNC_WITH_SHM_FIFO
// swap in and out for bidirectional communication
@@ -212,15 +225,15 @@ bool RemotePlugin::init(const QString &pluginExecutable,
#ifndef DEBUG_REMOTE_PLUGIN
m_process.setProcessChannelMode( QProcess::ForwardedChannels );
m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() );
m_process.start( exec, args );
m_exec = exec;
m_args = args;
// we start the process on the watcher thread to work around QTBUG-8819
m_process.moveToThread( &m_watcher );
m_watcher.start( QThread::LowestPriority );
#else
qDebug() << exec << args;
#endif

connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
this, SLOT( processFinished( int, QProcess::ExitStatus ) ) );

#ifndef SYNC_WITH_SHM_FIFO
struct pollfd pollin;
pollin.fd = m_server;

0 comments on commit 9c9290e

Please sign in to comment.
You can’t perform that action at this time.