Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tryLock in audio threads for VST/ZynAddSubFX #4460

Merged
merged 2 commits into from
Jul 13, 2018

Conversation

PhysSong
Copy link
Member

@PhysSong PhysSong commented Jul 4, 2018

Prevent loading VST or toggling ZynAddSubFX GUI from blocking entire audio processing. It still blocks audio output from specific VeSTige/ZynAddSubFX but not whole playback.
Address #1825.

Prevent loading VST or toggling ZynAddSubFX GUI
from blocking entire audio processing.
@@ -62,7 +62,7 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
{
//m_effect->closePlugin();
//m_effect->openPlugin( _this.attribute( "plugin" ) );
m_effect->m_pluginMutex.lock();
if (!m_effect->m_pluginMutex.tryLock()) {return;}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this cause the plugin settings not to be loaded if the mutex can't be locked? I think this code runs on the main thread anyway so it shouldn't affect audio processing if it has to wait for the mutex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right here, probably a mistake.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e79aeb7.

@PhysSong
Copy link
Member Author

Merge?

@PhysSong PhysSong merged commit 408b72c into LMMS:stable-1.2 Jul 13, 2018
@PhysSong PhysSong deleted the remoteblock branch July 13, 2018 01:40
@falkTX
Copy link
Contributor

falkTX commented Jul 13, 2018

won't this produce lag noise when the lock is on (GUI doing stuff) because we are not clearing the buffer?
the last buffer values will remain there unchanged.

@PhysSong
Copy link
Member Author

PlayHandle::doProcessing clears the buffer before processing, so I believe it doesn't matter.

@falkTX
Copy link
Contributor

falkTX commented Jul 13, 2018

If that is the case then all is good :)
Now I wonder if carla plugin is doing the same... I think not..

@PhysSong
Copy link
Member Author

Now I wonder if carla plugin is doing the same... I think not..

I guess the mutex can be dropped with a proper workaround for race conditions(maybe Mixer::requestChangeInModel stuff?). However, the mutex is less likely to cause severe blocking than the VST/ZynAddSubFX case...

@PhysSong
Copy link
Member Author

I guess this patch might break rendering. Should I restrict this fix to playback only?

@PhysSong
Copy link
Member Author

I found that this is insufficient because RemotePlugin::process() calls lock(). I think #5074 (comment) might be the ultimate solution.

sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
Prevent loading VST or toggling ZynAddSubFX GUI
from blocking entire audio processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants