diff --git a/Makefile b/Makefile index 69d02e6dd..e60aa21c9 100644 --- a/Makefile +++ b/Makefile @@ -15,15 +15,7 @@ PYRCC ?= pyrcc4 -py3 # ------------------------------------------------------------------------------------------------------------------------------------- -# HAVE_LIBS = $(shell pkg-config --exists freetype2 x11 && echo true) - -# ifneq ($(HAVE_LIBS),true) -# all -# @echo Error Missing libraries or pkg-config, cannot build -# @exit 1 -# else all: CPP RES UI WIDGETS -# endif # ------------------------------------------------------------------------------------------------------------------------------------- # C++ code @@ -182,11 +174,10 @@ install: # Install binaries install -m 755 \ source/backend/*.so \ + source/bridges/carla-bridge-* \ source/discovery/carla-discovery-* \ $(DESTDIR)$(PREFIX)/lib/carla/ -# source/bridges/carla-bridge-* - # Install python code install -m 755 source/*.py $(DESTDIR)$(PREFIX)/share/carla/ diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 58ce86c83..04c3cc6a2 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -19,7 +19,7 @@ #include "CarlaBackendUtils.hpp" #include "CarlaMIDI.h" -#ifdef BUILD_BRIDGE +#ifdef JACKBRIDGE_EXPORT # include "jackbridge/JackBridge.hpp" #else # include "jackbridge/JackBridge.cpp" @@ -739,6 +739,7 @@ public: return new CarlaEngineJackClient(kEngineTypeJack, fOptions.processMode, client); } +#ifndef BUILD_BRIDGE const char* renamePlugin(const unsigned int id, const char* const newName) override { CARLA_ASSERT(kData->curPluginCount > 0); @@ -796,7 +797,6 @@ public: return name; } -#ifndef BUILD_BRIDGE // ------------------------------------------------------------------- // Patchbay diff --git a/source/backend/plugin/BridgePlugin.cpp b/source/backend/plugin/BridgePlugin.cpp index e013a2484..7e3831584 100644 --- a/source/backend/plugin/BridgePlugin.cpp +++ b/source/backend/plugin/BridgePlugin.cpp @@ -130,6 +130,8 @@ public: carla_debug("BridgePlugin::BridgePlugin(%p, %i, %s, %s)", engine, id, BinaryType2Str(btype), PluginType2Str(ptype)); kData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_BRIDGE); + + fHints |= PLUGIN_IS_BRIDGE; } ~BridgePlugin() override diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 3ae0fa3f5..0c14d9189 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -353,30 +353,32 @@ public: kData->osc.thread.terminate(); } } + else + { + if (fFeatures[kFeatureIdUiDataAccess] != nullptr && fFeatures[kFeatureIdUiDataAccess]->data != nullptr) + delete (LV2_Extension_Data_Feature*)fFeatures[kFeatureIdUiDataAccess]->data; - if (fFeatures[kFeatureIdUiDataAccess] != nullptr && fFeatures[kFeatureIdUiDataAccess]->data != nullptr) - delete (LV2_Extension_Data_Feature*)fFeatures[kFeatureIdUiDataAccess]->data; + if (fFeatures[kFeatureIdUiPortMap] != nullptr && fFeatures[kFeatureIdUiPortMap]->data != nullptr) + delete (LV2UI_Port_Map*)fFeatures[kFeatureIdUiPortMap]->data; - if (fFeatures[kFeatureIdUiPortMap] != nullptr && fFeatures[kFeatureIdUiPortMap]->data != nullptr) - delete (LV2UI_Port_Map*)fFeatures[kFeatureIdUiPortMap]->data; + if (fFeatures[kFeatureIdUiResize] != nullptr && fFeatures[kFeatureIdUiResize]->data != nullptr) + delete (LV2UI_Resize*)fFeatures[kFeatureIdUiResize]->data; - if (fFeatures[kFeatureIdUiResize] != nullptr && fFeatures[kFeatureIdUiResize]->data != nullptr) - delete (LV2UI_Resize*)fFeatures[kFeatureIdUiResize]->data; + if (fFeatures[kFeatureIdExternalUi] != nullptr && fFeatures[kFeatureIdExternalUi]->data != nullptr) + { + const LV2_External_UI_Host* const uiHost((const LV2_External_UI_Host*)fFeatures[kFeatureIdExternalUi]->data); - if (fFeatures[kFeatureIdExternalUi] != nullptr && fFeatures[kFeatureIdExternalUi]->data != nullptr) - { - const LV2_External_UI_Host* const uiHost((const LV2_External_UI_Host*)fFeatures[kFeatureIdExternalUi]->data); + if (uiHost->plugin_human_id != nullptr) + delete[] uiHost->plugin_human_id; - if (uiHost->plugin_human_id != nullptr) - delete[] uiHost->plugin_human_id; + delete uiHost; + } - delete uiHost; + fUi.descriptor = nullptr; + kData->uiLibClose(); } - fUi.descriptor = nullptr; fUi.rdfDescriptor = nullptr; - - kData->uiLibClose(); } kData->singleMutex.lock(); @@ -3307,6 +3309,31 @@ protected: // ------------------------------------------------------------------- + const char* getUiBridgePath(const LV2_Property type) + { + const EngineOptions& options(kData->engine->getOptions()); + + switch (type) + { + case LV2_UI_GTK2: + return options.bridge_lv2Gtk2; + case LV2_UI_GTK3: + return options.bridge_lv2Gtk3; + case LV2_UI_QT4: + return options.bridge_lv2Qt4; + case LV2_UI_QT5: + return options.bridge_lv2Qt5; + case LV2_UI_COCOA: + return options.bridge_lv2Cocoa; + case LV2_UI_WINDOWS: + return options.bridge_lv2Win; + case LV2_UI_X11: + return options.bridge_lv2X11; + default: + return nullptr; + } + } + bool isUiBridgeable(const uint32_t uiId) { const LV2_RDF_UI& rdfUi(fRdfDescriptor->UIs[uiId]); @@ -3725,13 +3752,11 @@ public: int eQt4, eQt5, eCocoa, eWindows, eX11, eGtk2, eGtk3, iCocoa, iWindows, iX11, iQt4, iQt5, iExt, iFinal; eQt4 = eQt5 = eCocoa = eWindows = eX11 = eGtk2 = eGtk3 = iQt4 = iQt5 = iCocoa = iWindows = iX11 = iExt = iFinal = -1; -//#ifdef BUILD_BRIDGE -// const bool preferUiBridges(kData->engine->getOptions().preferUiBridges); -//#else -// const bool preferUiBridges(kData->engine->getOptions().preferUiBridges && (fHints & PLUGIN_IS_BRIDGE) == 0); -//#endif - // TODO - const bool preferUiBridges(false); +#ifdef BUILD_BRIDGE + const bool preferUiBridges(kData->engine->getOptions().preferUiBridges); +#else + const bool preferUiBridges(kData->engine->getOptions().preferUiBridges && (fHints & PLUGIN_IS_BRIDGE) == 0); +#endif for (uint32_t i=0; i < fRdfDescriptor->UICount; ++i) { @@ -3844,9 +3869,6 @@ public: else if (iExt >= 0) iFinal = iExt; - // TODO - const bool isBridged(false); - if (iFinal < 0) { carla_stderr("Failed to find an appropriate LV2 UI for this plugin"); @@ -3876,65 +3898,64 @@ public: return true; } - // ------------------------------------------------------- - // open UI DLL - - if (! kData->uiLibOpen(fUi.rdfDescriptor->Binary)) - { - carla_stderr2("Could not load UI library, error was:\n%s", kData->libError(fUi.rdfDescriptor->Binary)); - fUi.rdfDescriptor = nullptr; - return true; - } - - // ------------------------------------------------------- - // get UI DLL main entry - - LV2UI_DescriptorFunction uiDescFn = (LV2UI_DescriptorFunction)kData->uiLibSymbol("lv2ui_descriptor"); - - if (uiDescFn == nullptr) - { - carla_stderr2("Could not find the LV2UI Descriptor in the UI library"); - kData->uiLibClose(); - fUi.rdfDescriptor = nullptr; - return true; - } - - // ------------------------------------------------------- - // get UI descriptor that matches UI URI - - uint32_t i = 0; - while ((fUi.descriptor = uiDescFn(i++))) - { - if (std::strcmp(fUi.descriptor->URI, fUi.rdfDescriptor->URI) == 0) - break; - } - - if (fUi.descriptor == nullptr) - { - carla_stderr2("Could not find the requested GUI in the plugin UI library"); - kData->uiLibClose(); - fUi.rdfDescriptor = nullptr; - return true; - } - // ----------------------------------------------------------- // initialize ui according to type const LV2_Property uiType(fUi.rdfDescriptor->Type); - if (isBridged) + if (iFinal == eQt4 || iFinal == eQt5 || iFinal == eCocoa || iFinal == eWindows || iFinal == eX11 || iFinal == eGtk2 || iFinal == eGtk3) { // ------------------------------------------------------- // initialize ui bridge - if (const char* const oscBinary = nullptr /*getUiBridgePath(uiType)*/) + if (const char* const oscBinary = getUiBridgePath(uiType)) { fUi.type = PLUGIN_UI_OSC; - kData->osc.thread.setOscData(oscBinary, fDescriptor->URI, fUi.descriptor->URI); + kData->osc.thread.setOscData(oscBinary, fDescriptor->URI, fUi.rdfDescriptor->URI); } } else { + // ------------------------------------------------------- + // open UI DLL + + if (! kData->uiLibOpen(fUi.rdfDescriptor->Binary)) + { + carla_stderr2("Could not load UI library, error was:\n%s", kData->libError(fUi.rdfDescriptor->Binary)); + fUi.rdfDescriptor = nullptr; + return true; + } + + // ------------------------------------------------------- + // get UI DLL main entry + + LV2UI_DescriptorFunction uiDescFn = (LV2UI_DescriptorFunction)kData->uiLibSymbol("lv2ui_descriptor"); + + if (uiDescFn == nullptr) + { + carla_stderr2("Could not find the LV2UI Descriptor in the UI library"); + kData->uiLibClose(); + fUi.rdfDescriptor = nullptr; + return true; + } + + // ------------------------------------------------------- + // get UI descriptor that matches UI URI + + uint32_t i = 0; + while ((fUi.descriptor = uiDescFn(i++))) + { + if (std::strcmp(fUi.descriptor->URI, fUi.rdfDescriptor->URI) == 0) + break; + } + + if (fUi.descriptor == nullptr) + { + carla_stderr2("Could not find the requested GUI in the plugin UI library"); + kData->uiLibClose(); + fUi.rdfDescriptor = nullptr; + return true; + } // ------------------------------------------------------- // check if ui is usable