From dc6fdacf68fd8b1b0155050cf85ed67b091713f2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 01:40:34 +0100 Subject: [PATCH] Add STATIC_PLUGIN_TARGET macro; Fix wrong memory reads on lv2 list Signed-off-by: falkTX --- Makefile | 6 ++++++ source/Makefile.deps.mk | 17 +++++++++++++++++ source/Makefile.mk | 4 ++++ source/backend/Makefile | 2 ++ source/backend/engine/CarlaEngine.cpp | 10 ++++++++++ source/backend/utils/CachedPlugins.cpp | 16 ++++++++++++---- source/jackbridge/Makefile | 3 ++- 7 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 68297618e..a29bf5be5 100644 --- a/Makefile +++ b/Makefile @@ -33,10 +33,16 @@ all: backend discovery bridges-plugin bridges-ui frontend interposer libjack plu # --------------------------------------------------------------------------------------------------------------------- # Binaries (native) +ifneq ($(STATIC_PLUGIN_TARGET),true) ALL_LIBS += $(MODULEDIR)/carla_engine.a +endif ALL_LIBS += $(MODULEDIR)/carla_engine_plugin.a ALL_LIBS += $(MODULEDIR)/carla_plugin.a +ifneq ($(STATIC_PLUGIN_TARGET),true) ALL_LIBS += $(MODULEDIR)/jackbridge.a +else +ALL_LIBS += $(MODULEDIR)/jackbridge.min.a +endif ALL_LIBS += $(MODULEDIR)/native-plugins.a ALL_LIBS += $(MODULEDIR)/rtmempool.a diff --git a/source/Makefile.deps.mk b/source/Makefile.deps.mk index b3a000a79..99de45838 100644 --- a/source/Makefile.deps.mk +++ b/source/Makefile.deps.mk @@ -516,6 +516,23 @@ endif # WIN32 # --------------------------------------------------------------------------------------------------------------------- +ifeq ($(STATIC_PLUGIN_TARGET),true) +HAVE_ALSA = false +HAVE_DGL = false +HAVE_HYLIA = false +HAVE_JACK = false +HAVE_LIBLO = false +HAVE_PYQT = false +HAVE_QT4 = false +HAVE_QT5 = false +HAVE_QT5PKG = false +HAVE_PULSEAUDIO = false +USING_JUCE_AUDIO_DEVICES = false +USING_RTAUDIO = false +endif + +# --------------------------------------------------------------------------------------------------------------------- + AUDIO_DECODER_LIBS = $(FFMPEG_LIBS) AUDIO_DECODER_LIBS += $(SNDFILE_LIBS) diff --git a/source/Makefile.mk b/source/Makefile.mk index 3f8bce4fb..02a134789 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -222,6 +222,10 @@ ifeq ($(USING_RTAUDIO),true) BASE_FLAGS += -DUSING_RTAUDIO endif +ifeq ($(STATIC_PLUGIN_TARGET),true) +BASE_FLAGS += -DSTATIC_PLUGIN_TARGET +endif + # --------------------------------------------------------------------------------------------------------------------- # Set app extension diff --git a/source/backend/Makefile b/source/backend/Makefile index 06423ebbc..61c8369f3 100644 --- a/source/backend/Makefile +++ b/source/backend/Makefile @@ -13,8 +13,10 @@ OBJS_standalone = \ $(OBJDIR)/CarlaStandalone.cpp.o \ $(OBJDIR)/CarlaStandaloneNSM.cpp.o +ifneq ($(STATIC_PLUGIN_TARGET),true) TARGETS = \ $(BINDIR)/libcarla_standalone2$(LIB_EXT) +endif # --------------------------------------------------------------------------------------------------------------------- diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 505dd70c9..94317a43f 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -95,8 +95,10 @@ uint CarlaEngine::getDriverCount() uint count = 0; +#ifndef STATIC_PLUGIN_TARGET if (jackbridge_is_ok()) count += 1; +#endif #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES @@ -115,10 +117,12 @@ const char* CarlaEngine::getDriverName(const uint index2) carla_debug("CarlaEngine::getDriverName(%i)", index2); using namespace EngineInit; +#ifndef STATIC_PLUGIN_TARGET uint index = index2; if (jackbridge_is_ok() && index-- == 0) return "JACK"; +#endif #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES @@ -147,6 +151,7 @@ const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) carla_debug("CarlaEngine::getDriverDeviceNames(%i)", index2); using namespace EngineInit; +#ifndef STATIC_PLUGIN_TARGET uint index = index2; if (jackbridge_is_ok() && index-- == 0) @@ -154,6 +159,7 @@ const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) static const char* ret[3] = { "Auto-Connect ON", "Auto-Connect OFF", nullptr }; return ret; } +#endif #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES @@ -182,6 +188,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 carla_debug("CarlaEngine::getDriverDeviceInfo(%i, \"%s\")", index2, deviceName); using namespace EngineInit; +#ifndef STATIC_PLUGIN_TARGET uint index = index2; if (jackbridge_is_ok() && index-- == 0) @@ -192,6 +199,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 devInfo.sampleRates = nullptr; return &devInfo; } +#endif #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES @@ -220,12 +228,14 @@ bool CarlaEngine::showDriverDeviceControlPanel(const uint index2, const char* co carla_debug("CarlaEngine::showDriverDeviceControlPanel(%i, \"%s\")", index2, deviceName); using namespace EngineInit; +#ifndef STATIC_PLUGIN_TARGET uint index = index2; if (jackbridge_is_ok() && index-- == 0) { return false; } +#endif #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES diff --git a/source/backend/utils/CachedPlugins.cpp b/source/backend/utils/CachedPlugins.cpp index f00e887e0..f0c38049b 100644 --- a/source/backend/utils/CachedPlugins.cpp +++ b/source/backend/utils/CachedPlugins.cpp @@ -178,15 +178,23 @@ static const CarlaCachedPluginInfo* get_cached_plugin_lv2(Lv2WorldClass& lv2Worl lilv_node_free(nameNode); } - if (const char* const author = lilvPlugin.get_author_name().as_string()) - smaker = author; + if (LilvNode* const authorNode = lilv_plugin_get_author_name(lilvPlugin.me)) + { + if (const char* const author = lilv_node_as_string(authorNode)) + smaker = author; + lilv_node_free(authorNode); + } Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license)); if (licenseNodes.size() > 0) { - if (const char* const license = licenseNodes.get_first().as_string()) - slicense = license; + if (LilvNode* const licenseNode = lilv_nodes_get_first(licenseNodes.me)) + { + if (const char* const license = lilv_node_as_string(licenseNode)) + slicense = license; + // lilv_node_free(licenseNode); + } } lilv_nodes_free(const_cast(licenseNodes.me)); diff --git a/source/jackbridge/Makefile b/source/jackbridge/Makefile index d070b96e3..958a9954b 100644 --- a/source/jackbridge/Makefile +++ b/source/jackbridge/Makefile @@ -70,7 +70,8 @@ OBJS_win32e = $(OBJDIR)/JackBridgeExport.cpp.win32e.o # --------------------------------------------------------------------------------------------------------------------- -all: $(MODULEDIR)/$(MODULENAME).a $(MODULEDIR)/$(MODULENAME).min.a +all: $(MODULEDIR)/$(MODULENAME).a +min: $(MODULEDIR)/$(MODULENAME).min.a ifeq ($(WIN32),true) posix32: