From dbfc6116a98ee78fde36fb5cbb8c412845206ab1 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 2 Jun 2020 19:33:36 +0100 Subject: [PATCH] Fix a couple of issues with carla-plugin Signed-off-by: falkTX --- source/backend/CarlaEngine.hpp | 3 +- source/backend/CarlaStandalone.cpp | 4 +- source/backend/engine/CarlaEngineNative.cpp | 59 +++++++++------------ source/frontend/carla_host.py | 4 +- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 413890163..69ff4aa45 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -1146,7 +1146,8 @@ public: * Call the file callback, if set. * May be called by plugins. */ - const char* runFileCallback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter) noexcept; + virtual const char* runFileCallback(FileCallbackOpcode action, + bool isDir, const char* title, const char* filter) noexcept; /*! * Set the file callback to @a func. diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index a22d84209..2b28d5197 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -588,7 +588,6 @@ void carla_set_engine_callback(CarlaHostHandle handle, EngineCallbackFunc func, { carla_debug("carla_set_engine_callback(%p, %p, %p)", handle, func, ptr); -#ifndef BUILD_BRIDGE if (handle->isStandalone) { CarlaHostStandalone& shandle((CarlaHostStandalone&)*handle); @@ -596,9 +595,10 @@ void carla_set_engine_callback(CarlaHostHandle handle, EngineCallbackFunc func, shandle.engineCallback = func; shandle.engineCallbackPtr = ptr; +#ifndef BUILD_BRIDGE shandle.logThread.setCallback(func, ptr); - } #endif + } if (handle->engine != nullptr) handle->engine->setCallback(func, ptr); diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index ca09bebd8..bd0bd1d1f 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -240,9 +240,6 @@ public: pData->options.resourceDir = carla_strdup(pHost->resourceDir); pData->options.binaryDir = carla_strdup(carla_get_library_folder()); - - setCallback(_ui_server_callback, this); - setFileCallback(_ui_file_callback, this); } ~CarlaEngineNative() override @@ -329,6 +326,9 @@ public: { CarlaEngine::callback(sendHost, sendOsc, action, pluginId, value1, value2, value3, valuef, valueStr); + if (sendHost) + uiServerCallback(action, pluginId, value1, value2, value3, valuef, valueStr); + switch (action) { case ENGINE_CALLBACK_IDLE: @@ -353,6 +353,24 @@ public: } } + const char* runFileCallback(FileCallbackOpcode action, + bool isDir, const char* title, const char* filter) noexcept override + { + switch (action) + { + case FILE_CALLBACK_DEBUG: + return nullptr; + + case FILE_CALLBACK_OPEN: + return pHost->ui_open_file(pHost->handle, isDir, title, filter); + + case FILE_CALLBACK_SAVE: + return pHost->ui_save_file(pHost->handle, isDir, title, filter); + } + + return nullptr; + } + // ------------------------------------------------------------------- void touchPluginParameter(const uint id, const uint32_t parameterId, const bool touch) noexcept override @@ -810,23 +828,6 @@ protected: fUiServer.flushMessages(); } - const char* uiFileCallback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter) - { - switch (action) - { - case FILE_CALLBACK_DEBUG: - return nullptr; - - case FILE_CALLBACK_OPEN: - return pHost->ui_open_file(pHost->handle, isDir, title, filter); - - case FILE_CALLBACK_SAVE: - return pHost->ui_save_file(pHost->handle, isDir, title, filter); - } - - return nullptr; - } - void uiServerInfo() { CARLA_SAFE_ASSERT_RETURN(fIsRunning,); @@ -1395,6 +1396,9 @@ protected: fUiServer.idlePipe(); + if (! fUiServer.isPipeRunning()) + return; + char tmpBuf[STR_MAX+1]; carla_zeroChars(tmpBuf, STR_MAX+1); @@ -1655,21 +1659,6 @@ public: // ------------------------------------------------------------------- - static void _ui_server_callback(void* handle, EngineCallbackOpcode action, uint pluginId, - int value1, int value2, int value3, - float valuef, const char* valueStr) - { - handlePtr->uiServerCallback(action, pluginId, value1, value2, value3, valuef, valueStr); - } - - static const char* _ui_file_callback(void* handle, FileCallbackOpcode action, bool isDir, - const char* title, const char* filter) - { - return handlePtr->uiFileCallback(action, isDir, title, filter); - } - - // ------------------------------------------------------------------- - #undef handlePtr private: diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index ce5df696a..c5998ad17 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -955,7 +955,7 @@ class HostWindow(QMainWindow): self.ui.act_canvas_show_internal.blockSignals(True) self.ui.act_canvas_show_external.blockSignals(True) - if processMode == ENGINE_PROCESS_MODE_PATCHBAY: # and not self.host.isPlugin: + if processMode == ENGINE_PROCESS_MODE_PATCHBAY and not self.host.isPlugin: self.ui.act_canvas_show_internal.setChecked(True) self.ui.act_canvas_show_internal.setVisible(True) self.ui.act_canvas_show_external.setChecked(False) @@ -966,7 +966,7 @@ class HostWindow(QMainWindow): self.ui.act_canvas_show_internal.setVisible(False) self.ui.act_canvas_show_external.setChecked(True) self.ui.act_canvas_show_external.setVisible(False) - self.fExternalPatchbay = True + self.fExternalPatchbay = not self.host.isPlugin self.ui.act_canvas_show_internal.blockSignals(False) self.ui.act_canvas_show_external.blockSignals(False)