Use tryLock in audio threads for VST/ZynAddSubFX (#4460)

Prevent loading VST or toggling ZynAddSubFX GUI
from blocking entire audio processing
This commit is contained in:
Hyunjin Song
2018-07-13 10:40:24 +09:00
committed by GitHub
parent 9f64d52146
commit 408b72c798
3 changed files with 7 additions and 7 deletions

View File

@@ -95,9 +95,11 @@ bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames )
sampleFrame * buf = new sampleFrame[_frames];
#endif
memcpy( buf, _buf, sizeof( sampleFrame ) * _frames );
m_pluginMutex.lock();
m_plugin->process( buf, buf );
m_pluginMutex.unlock();
if (m_pluginMutex.tryLock())
{
m_plugin->process( buf, buf );
m_pluginMutex.unlock();
}
double out_sum = 0.0;
const float w = wetLevel();

View File

@@ -359,14 +359,12 @@ void vestigeInstrument::loadFile( const QString & _file )
void vestigeInstrument::play( sampleFrame * _buf )
{
m_pluginMutex.lock();
if (!m_pluginMutex.tryLock()) {return;}
const fpp_t frames = Engine::mixer()->framesPerPeriod();
if( m_plugin == NULL )
{
BufferManager::clear( _buf, frames );
m_pluginMutex.unlock();
return;
}

View File

@@ -326,7 +326,7 @@ QString ZynAddSubFxInstrument::nodeName() const
void ZynAddSubFxInstrument::play( sampleFrame * _buf )
{
m_pluginMutex.lock();
if (!m_pluginMutex.tryLock()) {return;}
if( m_remotePlugin )
{
m_remotePlugin->process( NULL, _buf );