From f34b820000b0896ac737d26b91f1c4665cb78d15 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 29 Oct 2021 11:00:50 +0100 Subject: [PATCH] TESTING: Give up on our own context mutex --- plugins/Cardinal/src/plugincontext.hpp | 3 +-- src/CardinalPlugin.cpp | 14 +++---------- src/CardinalUI.cpp | 28 ++++++++++---------------- src/PluginContext.hpp | 2 -- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/plugins/Cardinal/src/plugincontext.hpp b/plugins/Cardinal/src/plugincontext.hpp index e6eab19..bf6724f 100644 --- a/plugins/Cardinal/src/plugincontext.hpp +++ b/plugins/Cardinal/src/plugincontext.hpp @@ -18,7 +18,7 @@ #pragma once #include "plugin.hpp" -#include "../dpf/distrho/extra/Mutex.hpp" +#include "DistrhoUtils.hpp" // ----------------------------------------------------------------------------------------------------------- // from PluginContext.hpp @@ -36,7 +36,6 @@ struct CardinalPluginContext : rack::Context { bool playing, frameZero; int32_t bar, beat, beatsPerBar; double tick, ticksPerBeat, ticksPerFrame; - Mutex mutex; Plugin* const plugin; CardinalPluginContext(Plugin* const p); }; diff --git a/src/CardinalPlugin.cpp b/src/CardinalPlugin.cpp index ebb88a3..d30410f 100644 --- a/src/CardinalPlugin.cpp +++ b/src/CardinalPlugin.cpp @@ -261,7 +261,6 @@ struct Initializer std::vector data(size); std::memcpy(data.data(), blob, size); - const MutexLocker cml(context->mutex); rack::contextSet(context); rack::system::removeRecursively(context->patch->autosavePath); rack::system::createDirectories(context->patch->autosavePath); @@ -287,10 +286,7 @@ struct Initializer // ----------------------------------------------------------------------------------------------------------- struct ScopedContext { - const MutexLocker cml; - ScopedContext(const CardinalBasePlugin* const plugin) - : cml(plugin->context->mutex) { rack::contextSet(plugin->context); } @@ -400,15 +396,11 @@ public: fInitializer->oscPlugin = nullptr; #endif - { - const MutexLocker cml(context->mutex); - rack::contextSet(context); + rack::contextSet(context); #if defined(__MOD_DEVICES__) && !defined(HEADLESS) - delete context->window; - context->window = nullptr; + delete context->window; + context->window = nullptr; #endif - } - delete context; rack::contextSet(nullptr); diff --git a/src/CardinalUI.cpp b/src/CardinalUI.cpp index 2188942..376ee2d 100644 --- a/src/CardinalUI.cpp +++ b/src/CardinalUI.cpp @@ -68,19 +68,16 @@ class CardinalUI : public UI, struct ScopedContext { CardinalPluginContext* const context; - const MutexLocker cml; ScopedContext(CardinalUI* const ui) - : context(ui->fContext), - cml(context->mutex) + : context(ui->fContext) { rack::contextSet(context); WindowParametersRestore(context->window); } ScopedContext(CardinalUI* const ui, const int mods) - : context(ui->fContext), - cml(context->mutex) + : context(ui->fContext) { rack::contextSet(context); rack::window::WindowMods(context->window, mods); @@ -112,23 +109,20 @@ public: rack::window::Window* const window = new rack::window::Window; rack::window::WindowInit(window, this); - { - const MutexLocker cml(fContext->mutex); - rack::contextSet(fContext); + rack::contextSet(fContext); - fContext->scene->removeChild(fContext->scene->menuBar); - fContext->scene->menuBar = rack::app::createMenuBar(getWindow(), getApp().isStandalone()); - fContext->scene->addChildBelow(fContext->scene->menuBar, fContext->scene->rackScroll); + fContext->scene->removeChild(fContext->scene->menuBar); + fContext->scene->menuBar = rack::app::createMenuBar(getWindow(), getApp().isStandalone()); + fContext->scene->addChildBelow(fContext->scene->menuBar, fContext->scene->rackScroll); - fContext->window = window; + fContext->window = window; - rack::widget::Widget::ContextCreateEvent e; - fContext->scene->onContextCreate(e); + rack::widget::Widget::ContextCreateEvent e; + fContext->scene->onContextCreate(e); - window->step(); + window->step(); - rack::contextSet(nullptr); - } + rack::contextSet(nullptr); WindowParametersSetCallback(window, this); } diff --git a/src/PluginContext.hpp b/src/PluginContext.hpp index 778954d..8060730 100644 --- a/src/PluginContext.hpp +++ b/src/PluginContext.hpp @@ -43,8 +43,6 @@ struct CardinalPluginContext : rack::Context { bool playing, frameZero; int32_t bar, beat, beatsPerBar; double tick, ticksPerBeat, ticksPerFrame; - - Mutex mutex; Plugin* const plugin; CardinalPluginContext(Plugin* const p)