Merge pull request #625 from jpcima/vst-pluginval
Fix a crash that makes VST fail pluginval
This commit is contained in:
commit
1a50bcaa72
2 changed files with 17 additions and 3 deletions
|
|
@ -182,6 +182,9 @@ tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
|||
{
|
||||
sfz::Sfizz* synth = _synth.get();
|
||||
|
||||
if (bool(state) == _isActive)
|
||||
return kResultTrue;
|
||||
|
||||
if (!synth)
|
||||
return kResultFalse;
|
||||
|
||||
|
|
@ -192,13 +195,13 @@ tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
|||
_fileChangePeriod = static_cast<uint32>(1.0 * processSetup.sampleRate);
|
||||
_playStateChangePeriod = static_cast<uint32>(50e-3 * processSetup.sampleRate);
|
||||
|
||||
_workRunning = true;
|
||||
_worker = std::thread([this]() { doBackgroundWork(); });
|
||||
startBackgroundWork();
|
||||
} else {
|
||||
synth->allSoundOff();
|
||||
stopBackgroundWork();
|
||||
synth->allSoundOff();
|
||||
}
|
||||
|
||||
_isActive = bool(state);
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
|
|
@ -642,6 +645,15 @@ void SfizzVstProcessor::doBackgroundWork()
|
|||
}
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::startBackgroundWork()
|
||||
{
|
||||
if (_workRunning)
|
||||
return;
|
||||
|
||||
_workRunning = true;
|
||||
_worker = std::thread([this]() { doBackgroundWork(); });
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::stopBackgroundWork()
|
||||
{
|
||||
if (!_workRunning)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public:
|
|||
private:
|
||||
// synth state. acquire processMutex before accessing
|
||||
std::unique_ptr<sfz::Sfizz> _synth;
|
||||
bool _isActive = false;
|
||||
SfizzVstState _state;
|
||||
float _currentStretchedTuning = 0;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ private:
|
|||
|
||||
// worker
|
||||
void doBackgroundWork();
|
||||
void startBackgroundWork();
|
||||
void stopBackgroundWork();
|
||||
// writer
|
||||
bool writeWorkerMessage(const char* type, const void* data, uintptr_t size);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue