Add thread checker for the VST controller
This commit is contained in:
parent
eba974cfe1
commit
9023209dfd
2 changed files with 12 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "SfizzVstIDs.h"
|
#include "SfizzVstIDs.h"
|
||||||
#include "base/source/fstreamer.h"
|
#include "base/source/fstreamer.h"
|
||||||
#include "base/source/updatehandler.h"
|
#include "base/source/updatehandler.h"
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
{
|
{
|
||||||
|
|
@ -20,6 +21,9 @@ tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
// initialize the update handler
|
// initialize the update handler
|
||||||
Steinberg::UpdateHandler::instance();
|
Steinberg::UpdateHandler::instance();
|
||||||
|
|
||||||
|
// initialize the thread checker
|
||||||
|
threadChecker_ = Vst::ThreadChecker::create();
|
||||||
|
|
||||||
// create update objects
|
// create update objects
|
||||||
queuedUpdates_ = Steinberg::owned(new QueuedUpdates);
|
queuedUpdates_ = Steinberg::owned(new QueuedUpdates);
|
||||||
sfzUpdate_ = Steinberg::owned(new SfzUpdate);
|
sfzUpdate_ = Steinberg::owned(new SfzUpdate);
|
||||||
|
|
@ -228,6 +232,12 @@ tresult SfizzVstControllerNoUi::notify(Vst::IMessage* message)
|
||||||
if (result != kResultFalse)
|
if (result != kResultFalse)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
if (!threadChecker_->test()) {
|
||||||
|
static std::atomic_bool warn_once_flag { false };
|
||||||
|
if (!warn_once_flag.exchange(true))
|
||||||
|
fprintf(stderr, "[sfizz] controller notification arrives from the wrong thread\n");
|
||||||
|
}
|
||||||
|
|
||||||
const char* id = message->getMessageID();
|
const char* id = message->getMessageID();
|
||||||
Vst::IAttributeList* attr = message->getAttributes();
|
Vst::IAttributeList* attr = message->getAttributes();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "SfizzVstUpdates.h"
|
#include "SfizzVstUpdates.h"
|
||||||
#include "public.sdk/source/vst/vsteditcontroller.h"
|
#include "public.sdk/source/vst/vsteditcontroller.h"
|
||||||
#include "public.sdk/source/vst/vstparameters.h"
|
#include "public.sdk/source/vst/vstparameters.h"
|
||||||
|
#include "public.sdk/source/common/threadchecker.h"
|
||||||
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
||||||
#include "vstgui/plugin-bindings/vst3editor.h"
|
#include "vstgui/plugin-bindings/vst3editor.h"
|
||||||
#include <sfizz_message.h>
|
#include <sfizz_message.h>
|
||||||
|
|
@ -44,6 +45,7 @@ public:
|
||||||
REFCOUNT_METHODS(Vst::EditController)
|
REFCOUNT_METHODS(Vst::EditController)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::unique_ptr<Vst::ThreadChecker> threadChecker_;
|
||||||
Steinberg::IPtr<QueuedUpdates> queuedUpdates_;
|
Steinberg::IPtr<QueuedUpdates> queuedUpdates_;
|
||||||
Steinberg::IPtr<SfzUpdate> sfzUpdate_;
|
Steinberg::IPtr<SfzUpdate> sfzUpdate_;
|
||||||
Steinberg::IPtr<SfzDescriptionUpdate> sfzDescriptionUpdate_;
|
Steinberg::IPtr<SfzDescriptionUpdate> sfzDescriptionUpdate_;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue