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;}

This comment has been minimized.

@DomClark

DomClark Jul 4, 2018
Member

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.

This comment has been minimized.

@PhysSong

PhysSong Jul 4, 2018
Author Member

You're right here, probably a mistake.

This comment has been minimized.

@PhysSong

PhysSong Jul 5, 2018
Author Member

Fixed in e79aeb7.

@PhysSong
Copy link
Member Author

@PhysSong PhysSong commented Jul 12, 2018

Merge?

@PhysSong PhysSong merged commit 408b72c into LMMS:stable-1.2 Jul 13, 2018
2 checks passed
2 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@PhysSong PhysSong deleted the PhysSong:remoteblock branch Jul 13, 2018
@falkTX
Copy link
Contributor

@falkTX 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

@PhysSong PhysSong commented Jul 13, 2018

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

@falkTX
Copy link
Contributor

@falkTX 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

@PhysSong PhysSong commented Jul 14, 2018

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

@PhysSong PhysSong commented Aug 25, 2018

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

@PhysSong
Copy link
Member Author

@PhysSong PhysSong commented Apr 27, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.