Skip to content

Commit

Permalink
Support more than 62 simultaneous VST plugins for Qt<5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
DomClark authored and zonkmachine committed Dec 7, 2018
1 parent 614bca7 commit 9c9290e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
11 changes: 10 additions & 1 deletion include/RemotePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,15 @@ class ProcessWatcher : public QThread
}


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

void reset()
{
m_quit = false;
}

private:
Expand Down Expand Up @@ -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
Expand Down
25 changes: 19 additions & 6 deletions src/core/RemotePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 9c9290e

Please sign in to comment.