diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index 947259536..5f032b3d1 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -212,7 +212,8 @@ public: CarlaEngineBridge(const char* const audioBaseName, const char* const controlBaseName, const char* const timeBaseName) : CarlaEngine(), CarlaThread("CarlaEngineBridge"), - fIsRunning(false) + fIsRunning(false), + fNextUIState(-1) { carla_stdout("CarlaEngineBridge::CarlaEngineBridge(%s, %s, %s)", audioBaseName, controlBaseName, timeBaseName); @@ -358,6 +359,20 @@ public: return "Bridge"; } + void idle() noexcept override + { + CarlaEngine::idle(); + + if (fNextUIState == -1 || ! fIsRunning) + return; + + try { + carla_show_custom_ui(0, bool(fNextUIState)); + } CARLA_SAFE_EXCEPTION("bridge show_custom_ui"); + + fNextUIState = -1; + } + // ------------------------------------- // CarlaThread virtual calls @@ -589,14 +604,12 @@ public: case kPluginBridgeOpcodeShowUI: carla_stdout("-----------------------------------------------------, got SHOW UI"); - - carla_show_custom_ui(0, true); + fNextUIState = 1; break; case kPluginBridgeOpcodeHideUI: carla_stdout("-----------------------------------------------------, got HIDE UI"); - - carla_show_custom_ui(0, false); + fNextUIState = 0; break; case kPluginBridgeOpcodeQuit: @@ -615,6 +628,8 @@ public: } fIsRunning = false; + + callback(ENGINE_CALLBACK_ENGINE_STOPPED, 0, 0, 0, 0.0f, nullptr); } private: @@ -623,6 +638,7 @@ private: BridgeTime fShmTime; volatile bool fIsRunning; + volatile int fNextUIState; CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineBridge) }; diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index 19653c2a4..153f52efb 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -228,11 +228,15 @@ public: std::free(tmpServerPath); } + lo_server_thread_start(fOscServerThread); + fEngine->setOscBridgeData(&fOscControlData); } void oscClose() { + lo_server_thread_stop(fOscServerThread); + fEngine->setOscBridgeData(nullptr); if (fOscServerThread != nullptr) @@ -284,7 +288,7 @@ public: carla_stderr("Plugin preset load failed, error was:\n%s", carla_get_last_error()); } - gIsInitiated = true; + gIsInitiated = true; #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) JUCEApplicationBase::createInstance = &juce_CreateApplication;