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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user