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();
|
sfz::Sfizz* synth = _synth.get();
|
||||||
|
|
||||||
|
if (bool(state) == _isActive)
|
||||||
|
return kResultTrue;
|
||||||
|
|
||||||
if (!synth)
|
if (!synth)
|
||||||
return kResultFalse;
|
return kResultFalse;
|
||||||
|
|
||||||
|
|
@ -192,13 +195,13 @@ tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
||||||
_fileChangePeriod = static_cast<uint32>(1.0 * processSetup.sampleRate);
|
_fileChangePeriod = static_cast<uint32>(1.0 * processSetup.sampleRate);
|
||||||
_playStateChangePeriod = static_cast<uint32>(50e-3 * processSetup.sampleRate);
|
_playStateChangePeriod = static_cast<uint32>(50e-3 * processSetup.sampleRate);
|
||||||
|
|
||||||
_workRunning = true;
|
startBackgroundWork();
|
||||||
_worker = std::thread([this]() { doBackgroundWork(); });
|
|
||||||
} else {
|
} else {
|
||||||
synth->allSoundOff();
|
|
||||||
stopBackgroundWork();
|
stopBackgroundWork();
|
||||||
|
synth->allSoundOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isActive = bool(state);
|
||||||
return kResultTrue;
|
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()
|
void SfizzVstProcessor::stopBackgroundWork()
|
||||||
{
|
{
|
||||||
if (!_workRunning)
|
if (!_workRunning)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ public:
|
||||||
private:
|
private:
|
||||||
// synth state. acquire processMutex before accessing
|
// synth state. acquire processMutex before accessing
|
||||||
std::unique_ptr<sfz::Sfizz> _synth;
|
std::unique_ptr<sfz::Sfizz> _synth;
|
||||||
|
bool _isActive = false;
|
||||||
SfizzVstState _state;
|
SfizzVstState _state;
|
||||||
float _currentStretchedTuning = 0;
|
float _currentStretchedTuning = 0;
|
||||||
|
|
||||||
|
|
@ -94,6 +95,7 @@ private:
|
||||||
|
|
||||||
// worker
|
// worker
|
||||||
void doBackgroundWork();
|
void doBackgroundWork();
|
||||||
|
void startBackgroundWork();
|
||||||
void stopBackgroundWork();
|
void stopBackgroundWork();
|
||||||
// writer
|
// writer
|
||||||
bool writeWorkerMessage(const char* type, const void* data, uintptr_t size);
|
bool writeWorkerMessage(const char* type, const void* data, uintptr_t size);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue