From afeb4123a1520b8150b2366a0a16f793e01602b2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 8 Jul 2022 02:38:40 +0100 Subject: [PATCH] Tweaks for wasm builds; Fix crash when UI is not available Signed-off-by: falkTX --- Makefile | 8 +++++++- carla | 2 +- dpf | 2 +- dpf-widgets | 2 +- plugins/Common/IldaeilBasePlugin.hpp | 1 + plugins/Common/IldaeilPlugin.cpp | 1 + plugins/Common/IldaeilUI.cpp | 28 ++++++++++++++++++++++------ plugins/Common/PluginHostWindow.cpp | 2 +- 8 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index b3a5fdf..f836c72 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,12 @@ ifneq ($(DEBUG),true) CARLA_EXTRA_ARGS += EXTERNAL_PLUGINS=true endif +CARLA_TARGETS = static-plugin + +ifneq ($(WASM),true) +CARLA_TARGETS += bridges-plugin bridges-ui +endif + # -------------------------------------------------------------- # Check for X11+OpenGL dependencies @@ -59,7 +65,7 @@ endif # -------------------------------------------------------------- carla: dgl - $(MAKE) bridges-plugin bridges-ui static-plugin -C carla $(CARLA_EXTRA_ARGS) + $(MAKE) -C carla $(CARLA_EXTRA_ARGS) $(CARLA_TARGETS) dgl: $(MAKE) -C dpf/dgl opengl diff --git a/carla b/carla index 33bd1f9..6ee0333 160000 --- a/carla +++ b/carla @@ -1 +1 @@ -Subproject commit 33bd1f94b33c53e208bb13d09a567a02976b9f1f +Subproject commit 6ee03336ab0a15dba4da78dbf7413624228c5db5 diff --git a/dpf b/dpf index 34bf2a4..b9e654c 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit 34bf2a4dfca724fc544f8ab0a15727ddf558d7d8 +Subproject commit b9e654c3d331933dbeae0413246be8dc2bd64a58 diff --git a/dpf-widgets b/dpf-widgets index 191da32..b0a1286 160000 --- a/dpf-widgets +++ b/dpf-widgets @@ -1 +1 @@ -Subproject commit 191da3265214af66fe9b12d0222a8296f8c61230 +Subproject commit b0a1286f7933dc5f6d33237e2dff7b64267c62ae diff --git a/plugins/Common/IldaeilBasePlugin.hpp b/plugins/Common/IldaeilBasePlugin.hpp index 39b5203..b2eca07 100644 --- a/plugins/Common/IldaeilBasePlugin.hpp +++ b/plugins/Common/IldaeilBasePlugin.hpp @@ -57,6 +57,7 @@ public: void ildaeilProjectLoadedFromDSP(void* ui); void ildaeilParameterChangeForUI(void* ui, uint32_t index, float value); +void ildaeilCloseUI(void* ui); const char* ildaeilOpenFileForUI(void* ui, bool isDir, const char* title, const char* filter); // -------------------------------------------------------------------------------------------------------------------- diff --git a/plugins/Common/IldaeilPlugin.cpp b/plugins/Common/IldaeilPlugin.cpp index 6c06cfd..2ff4e3d 100644 --- a/plugins/Common/IldaeilPlugin.cpp +++ b/plugins/Common/IldaeilPlugin.cpp @@ -533,6 +533,7 @@ static void host_ui_custom_data_changed(NativeHostHandle handle, const char* key static void host_ui_closed(NativeHostHandle handle) { d_stdout("%s %p", __FUNCTION__, handle); + ildaeilCloseUI(static_cast(handle)); } static const char* host_ui_open_file(const NativeHostHandle handle, const bool isDir, const char* const title, const char* const filter) diff --git a/plugins/Common/IldaeilUI.cpp b/plugins/Common/IldaeilUI.cpp index 923509f..cf4f700 100644 --- a/plugins/Common/IldaeilUI.cpp +++ b/plugins/Common/IldaeilUI.cpp @@ -302,10 +302,10 @@ public: if (carla_get_current_plugin_count(handle) != 0) { - #ifndef DISTRHO_OS_WASM // FIXME const uint hints = carla_get_plugin_info(handle, fPluginId)->hints; fPluginHasCustomUI = hints & PLUGIN_HAS_CUSTOM_UI; + #ifndef DISTRHO_OS_WASM fPluginHasEmbedUI = hints & PLUGIN_HAS_CUSTOM_EMBED_UI; #endif fPluginRunning = true; @@ -342,6 +342,12 @@ public: repaint(); } + void closeUI() + { + if (fIdleState == kIdleGiveIdleToUI) + fIdleState = kIdleNothing; + } + const char* openFileFromDSP(const bool /*isDir*/, const char* const title, const char* const /*filter*/) { DISTRHO_SAFE_ASSERT_RETURN(fPluginType == PLUGIN_INTERNAL || fPluginType == PLUGIN_LV2, nullptr); @@ -354,10 +360,10 @@ public: void showPluginUI(const CarlaHostHandle handle, const bool showIfNotEmbed) { + // FIXME #ifndef DISTRHO_OS_WASM const CarlaPluginInfo* const info = carla_get_plugin_info(handle, fPluginId); - // FIXME if (info->hints & PLUGIN_HAS_CUSTOM_EMBED_UI) { fDrawingState = kDrawingPluginEmbedUI; @@ -396,9 +402,9 @@ public: info = carla_get_plugin_info(handle, fPluginId); fDrawingState = kDrawingPluginGenericUI; - #ifndef DISTRHO_OS_WASM // FIXME fPluginHasCustomUI = info->hints & PLUGIN_HAS_CUSTOM_UI; + #ifndef DISTRHO_OS_WASM fPluginHasEmbedUI = info->hints & PLUGIN_HAS_CUSTOM_EMBED_UI; #endif @@ -613,7 +619,8 @@ protected: break; case kIdleGiveIdleToUI: - fPlugin->fCarlaPluginDescriptor->ui_idle(fPlugin->fCarlaPluginHandle); + if (fPlugin->fCarlaPluginDescriptor->ui_idle != nullptr) + fPlugin->fCarlaPluginDescriptor->ui_idle(fPlugin->fCarlaPluginHandle); fPluginHostWindow.idle(); break; @@ -745,7 +752,7 @@ protected: if (info->cvIns != 0 || info->cvOuts != 0) break; - #ifdef WASM_TESTING + #ifdef DISTRHO_OS_WASM if (info->midiIns != 0 && info->midiIns != 1) break; if (info->midiOuts != 0 && info->midiOuts != 1) @@ -782,7 +789,7 @@ protected: if (fPluginType == PLUGIN_INTERNAL) { - #ifndef WASM_TESTING + #ifndef DISTRHO_OS_WASM if (std::strcmp(info->label, "audiogain_s") == 0) break; #endif @@ -1263,10 +1270,19 @@ void ildaeilParameterChangeForUI(void* const ui, const uint32_t index, const flo static_cast(ui)->changeParameterFromDSP(index, value); } +void ildaeilCloseUI(void* ui) +{ + DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); + + d_stdout("%s %d", __PRETTY_FUNCTION__, __LINE__); + static_cast(ui)->closeUI(); +} + const char* ildaeilOpenFileForUI(void* const ui, const bool isDir, const char* const title, const char* const filter) { DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, nullptr); + d_stdout("%s %d", __PRETTY_FUNCTION__, __LINE__); return static_cast(ui)->openFileFromDSP(isDir, title, filter); } diff --git a/plugins/Common/PluginHostWindow.cpp b/plugins/Common/PluginHostWindow.cpp index 2d2aacc..91c1a4d 100644 --- a/plugins/Common/PluginHostWindow.cpp +++ b/plugins/Common/PluginHostWindow.cpp @@ -174,10 +174,10 @@ struct PluginHostWindow::PrivateData break; } } +#elif defined(DISTRHO_OS_WASM) #elif defined(DISTRHO_OS_WINDOWS) if (pluginWindow == nullptr) pluginWindow = FindWindowExA((::HWND)parentWindowId, nullptr, nullptr, nullptr); -#elif defined(DISTRHO_OS_WASM) #else if (display == nullptr) return;