From e081724910356d5bbb6fb5cc3b6dadc3d4503028 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 10:45:22 +0100 Subject: [PATCH 01/12] Revert "Same fix for removeInternal" This reverts commit 25bfde3a169546c70c43c163a12b5df6b0531a4c. --- source/modules/water/containers/Array.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/modules/water/containers/Array.h b/source/modules/water/containers/Array.h index a11c44356..a03857e55 100644 --- a/source/modules/water/containers/Array.h +++ b/source/modules/water/containers/Array.h @@ -1097,13 +1097,12 @@ private: { --numUsed; ElementType* const e = data.elements + indexToRemove; + e->~ElementType(); const int numberToShift = numUsed - indexToRemove; if (numberToShift > 0) data.moveMemory (e, e + 1, static_cast(numberToShift)); - e[numUsed].~ElementType(); - minimiseStorageAfterRemoval(); } From d87e6f87ab47d7ff647c6e8b2a22fdb52d2c3c23 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 15:08:44 +0100 Subject: [PATCH 02/12] Safer way to fetch X11 UI size Signed-off-by: falkTX --- source/utils/CarlaPluginUI.cpp | 69 ++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/source/utils/CarlaPluginUI.cpp b/source/utils/CarlaPluginUI.cpp index 1f5f2b1f8..4e2a943a1 100644 --- a/source/utils/CarlaPluginUI.cpp +++ b/source/utils/CarlaPluginUI.cpp @@ -48,6 +48,7 @@ typedef void (*EventProcPtr)(XEvent* ev); static const uint X11Key_Escape = 9; static bool gErrorTriggered = false; +static pthread_mutex_t gErrorMutex = PTHREAD_MUTEX_INITIALIZER; static int temporaryErrorHandler(Display*, XErrorEvent*) { @@ -153,47 +154,65 @@ public: { if (! fSetSizeCalledAtLeastOnce) { - XSizeHints hints; - carla_zeroStruct(hints); + int width = 0; + int height = 0; - if (XGetNormalHints(fDisplay, childWindow, &hints)) + XWindowAttributes attrs; + carla_zeroStruct(attrs); + + pthread_mutex_lock(&gErrorMutex); + const XErrorHandler oldErrorHandler = XSetErrorHandler(temporaryErrorHandler); + gErrorTriggered = false; + + if (XGetWindowAttributes(fDisplay, childWindow, &attrs)) { - int width = 0; - int height = 0; + width = attrs.width; + height = attrs.height; + } - if (hints.flags & PSize) - { - width = hints.width; - height = hints.height; - } - else if (hints.flags & PBaseSize) - { - width = hints.base_width; - height = hints.base_height; - } - else if (hints.flags & PMinSize) + XSetErrorHandler(oldErrorHandler); + pthread_mutex_unlock(&gErrorMutex); + + if (width == 0 && height == 0) + { + XSizeHints sizeHints; + carla_zeroStruct(sizeHints); + + if (XGetNormalHints(fDisplay, childWindow, &sizeHints)) { - width = hints.min_width; - height = hints.min_height; + if (sizeHints.flags & PSize) + { + width = sizeHints.width; + height = sizeHints.height; + } + else if (sizeHints.flags & PBaseSize) + { + width = sizeHints.base_width; + height = sizeHints.base_height; + } } - - if (width > 0 && height > 0) - setSize(static_cast(width), static_cast(height), false); } + + if (width > 1 && height > 1) + setSize(static_cast(width), static_cast(height), false); } const Atom _xevp = XInternAtom(fDisplay, "_XEventProc", False); - gErrorTriggered = false; + pthread_mutex_lock(&gErrorMutex); const XErrorHandler oldErrorHandler(XSetErrorHandler(temporaryErrorHandler)); + gErrorTriggered = false; Atom actualType; int actualFormat; ulong nitems, bytesAfter; uchar* data = nullptr; - XGetWindowProperty(fDisplay, childWindow, _xevp, 0, 1, False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesAfter, &data); + XGetWindowProperty(fDisplay, childWindow, _xevp, 0, 1, False, AnyPropertyType, + &actualType, &actualFormat, &nitems, &bytesAfter, &data); + XSetErrorHandler(oldErrorHandler); + pthread_mutex_unlock(&gErrorMutex); if (nitems == 1 && ! gErrorTriggered) { @@ -255,8 +274,9 @@ public: { if (! fChildWindowConfigured) { - gErrorTriggered = false; + pthread_mutex_lock(&gErrorMutex); const XErrorHandler oldErrorHandler = XSetErrorHandler(temporaryErrorHandler); + gErrorTriggered = false; XSizeHints sizeHints; carla_zeroStruct(sizeHints); @@ -273,6 +293,7 @@ public: fChildWindowConfigured = true; XSetErrorHandler(oldErrorHandler); + pthread_mutex_unlock(&gErrorMutex); } if (fChildWindow != 0) From 285984719c236696d5b9e16cf71cde5958c7ce27 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 15:32:27 +0100 Subject: [PATCH 03/12] Separate system and dependency checks to new file Signed-off-by: falkTX --- source/Makefile.deps.mk | 545 ++++++++++++++++++++++++++++++++++++++++ source/Makefile.mk | 509 +------------------------------------ 2 files changed, 547 insertions(+), 507 deletions(-) create mode 100644 source/Makefile.deps.mk diff --git a/source/Makefile.deps.mk b/source/Makefile.deps.mk new file mode 100644 index 000000000..c9642076b --- /dev/null +++ b/source/Makefile.deps.mk @@ -0,0 +1,545 @@ +#!/usr/bin/make -f +# Makefile for Carla C++ code # +# --------------------------- # +# Created by falkTX +# + +# --------------------------------------------------------------------------------------------------------------------- +# Auto-detect OS if not defined + +TARGET_MACHINE := $(shell $(CC) -dumpmachine) + +ifneq ($(BSD),true) +ifneq ($(HAIKU),true) +ifneq ($(HURD),true) +ifneq ($(LINUX),true) +ifneq ($(MACOS),true) +ifneq ($(WIN32),true) + +ifneq (,$(findstring bsd,$(TARGET_MACHINE))) +BSD=true +endif +ifneq (,$(findstring haiku,$(TARGET_MACHINE))) +HAIKU=true +endif +ifneq (,$(findstring gnu,$(TARGET_MACHINE))) +HURD=true +endif +ifneq (,$(findstring linux,$(TARGET_MACHINE))) +LINUX=true +endif +ifneq (,$(findstring apple,$(TARGET_MACHINE))) +MACOS=true +endif +ifneq (,$(findstring mingw,$(TARGET_MACHINE))) +WIN32=true +ifneq (,$(findstring x86_64,$(TARGET_MACHINE))) +WIN64=true +endif +endif +ifneq (,$(findstring msys,$(TARGET_MACHINE))) +WIN32=true +endif + +endif # WIN32 +endif # MACOS +endif # LINUX +endif # HURD +endif # HAIKU +endif # BSD + +# --------------------------------------------------------------------------------------------------------------------- +# Auto-detect the processor + +TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE))) + +ifneq (,$(filter i%86,$(TARGET_PROCESSOR))) +CPU_I386=true +CPU_I386_OR_X86_64=true +endif +ifneq (,$(filter x86_64,$(TARGET_PROCESSOR))) +CPU_X86_64=true +CPU_I386_OR_X86_64=true +endif +ifneq (,$(filter arm%,$(TARGET_PROCESSOR))) +CPU_ARM=true +CPU_ARM_OR_AARCH64=true +endif +ifneq (,$(filter arm64%,$(TARGET_PROCESSOR))) +CPU_ARM64=true +CPU_ARM_OR_AARCH64=true +endif +ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR))) +CPU_AARCH64=true +CPU_ARM_OR_AARCH64=true +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set wherever to build static binaries (Windows only) + +ifeq ($(WIN32),true) +ifneq ($(MSYSTEM),MINGW32) +ifneq ($(MSYSTEM),MINGW64) +STATIC_BINARIES = true +endif +endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set PKG_CONFIG (can be overridden by environment variable) + +PKG_CONFIG ?= pkg-config + +ifeq ($(STATIC_BINARIES),true) +PKG_CONFIG_FLAGS = --static +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set LINUX_OR_MACOS + +ifeq ($(LINUX),true) +LINUX_OR_MACOS=true +endif + +ifeq ($(MACOS),true) +LINUX_OR_MACOS=true +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set MACOS_OR_WIN32 and HAIKU_OR_MACOS_OR_WINDOWS + +ifeq ($(HAIKU),true) +HAIKU_OR_MACOS_OR_WIN32=true +endif + +ifeq ($(MACOS),true) +MACOS_OR_WIN32=true +HAIKU_OR_MACOS_OR_WIN32=true +endif + +ifeq ($(WIN32),true) +MACOS_OR_WIN32=true +HAIKU_OR_MACOS_OR_WIN32=true +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set UNIX + +ifeq ($(BSD),true) +UNIX=true +endif + +ifeq ($(HURD),true) +UNIX=true +endif + +ifeq ($(LINUX),true) +UNIX=true +endif + +ifeq ($(MACOS),true) +UNIX=true +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Check for optional libs (required by backend or bridges) + +ifeq ($(LINUX),true) +HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true) +HAVE_HYLIA = true +endif + +ifeq ($(MACOS),true) +ifneq ($(MACOS_OLD),true) +HAVE_HYLIA = true +endif +endif + +ifeq ($(WIN32),true) +HAVE_HYLIA = true +endif + +ifeq ($(MACOS_OR_WIN32),true) +HAVE_DGL = true +else +HAVE_DGL = $(shell $(PKG_CONFIG) --exists gl x11 && echo true) +HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true) +endif + +ifeq ($(UNIX),true) +ifneq ($(MACOS),true) +HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true) +endif +endif + +# ffmpeg values taken from https://ffmpeg.org/download.html (v2.8.15 maximum) +HAVE_FFMPEG = $(shell $(PKG_CONFIG) --max-version=56.60.100 libavcodec && \ + $(PKG_CONFIG) --max-version=56.40.101 libavformat && \ + $(PKG_CONFIG) --max-version=54.31.100 libavutil && echo true) +HAVE_FLUIDSYNTH = $(shell $(PKG_CONFIG) --atleast-version=1.1.7 fluidsynth && echo true) +HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true) +HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true) +HAVE_QT4 = $(shell $(PKG_CONFIG) --exists QtCore QtGui && echo true) +HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \ + $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true) +HAVE_QT5PKG = $(shell $(PKG_CONFIG) --silence-errors --variable=prefix Qt5OpenGLExtensions 1>/dev/null && echo true) +HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true) + +ifeq ($(HAVE_FLUIDSYNTH),true) +HAVE_FLUIDSYNTH_INSTPATCH = $(shell $(PKG_CONFIG) --atleast-version=2.1.0 fluidsynth && \ + $(PKG_CONFIG) --atleast-version=1.1.4 libinstpatch-1.0 && echo true) +endif + +ifeq ($(LINUX),true) +# juce only supports the most common architectures +ifneq (,$(findstring arm,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifneq (,$(findstring aarch64,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifneq (,$(findstring i486,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifneq (,$(findstring i586,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifneq (,$(findstring i686,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifneq (,$(findstring x86_64,$(TARGET_MACHINE))) +HAVE_JUCE_SUPPORTED_ARCH = true +endif +ifeq ($(HAVE_JUCE_SUPPORTED_ARCH),true) +HAVE_JUCE_LINUX_DEPS = $(shell $(PKG_CONFIG) --exists x11 xcursor xext freetype2 && echo true) +endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Check for optional libs (special non-pkgconfig tests) + +ifneq ($(WIN32),true) + +ifeq ($(shell $(PKG_CONFIG) --exists libmagic && echo true),true) +HAVE_LIBMAGIC = true +HAVE_LIBMAGICPKG = true +else +# old libmagic versions don't have a pkg-config file, so we need to call the compiler to test it +CFLAGS_WITHOUT_ARCH = $(subst -arch arm64,,$(CFLAGS)) +HAVE_LIBMAGIC = $(shell echo '\#include ' | $(CC) $(CFLAGS_WITHOUT_ARCH) -x c -w -c - -o /dev/null 2>/dev/null && echo true) +endif + +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set Qt tools + +ifeq ($(HAVE_QT4),true) +MOC_QT4 ?= $(shell $(PKG_CONFIG) --variable=moc_location QtCore) +RCC_QT4 ?= $(shell $(PKG_CONFIG) --variable=rcc_location QtCore) +UIC_QT4 ?= $(shell $(PKG_CONFIG) --variable=uic_location QtCore) +ifeq (,$(wildcard $(MOC_QT4))) +HAVE_QT4=false +endif +ifeq (,$(wildcard $(RCC_QT4))) +HAVE_QT4=false +endif +endif + +ifeq ($(HAVE_QT5),true) +QT5_HOSTBINS = $(shell $(PKG_CONFIG) --variable=host_bins Qt5Core) +MOC_QT5 ?= $(QT5_HOSTBINS)/moc +RCC_QT5 ?= $(QT5_HOSTBINS)/rcc +UIC_QT5 ?= $(QT5_HOSTBINS)/uic +ifeq (,$(wildcard $(MOC_QT5))) +HAVE_QT5=false +endif +ifeq (,$(wildcard $(RCC_QT5))) +HAVE_QT5=false +endif +endif + +ifeq ($(HAVE_QT4),true) +HAVE_QT=true +endif +ifeq ($(HAVE_QT5),true) +HAVE_QT=true +endif +ifeq ($(WIN32),true) +HAVE_QT=true +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set PyQt tools + +PYRCC5 ?= $(shell which pyrcc5 2>/dev/null) +PYUIC5 ?= $(shell which pyuic5 2>/dev/null) + +ifneq ($(PYUIC5),) +ifneq ($(PYRCC5),) +HAVE_PYQT = true +endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set PyQt tools, part2 + +PYRCC ?= $(PYRCC5) +PYUIC ?= $(PYUIC5) + +ifeq ($(HAVE_QT5),true) +HAVE_THEME = true +# else +# ifeq ($(MACOS),true) +# ifneq ($(MACOS_OLD),true) +# ifeq ($(HAVE_PYQT),true) +# HAVE_THEME = true +# MOC_QT5 ?= moc +# RCC_QT5 ?= rcc +# UIC_QT5 ?= uic +# endif +# endif +# endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set USING_JUCE + +ifeq ($(MACOS_OR_WIN32),true) +ifneq ($(MACOS_OLD),true) +USING_JUCE = true +USING_JUCE_AUDIO_DEVICES = true +endif +endif + +ifeq ($(HAVE_JUCE_LINUX_DEPS),true) +USING_JUCE = true +endif + +ifeq ($(USING_JUCE),true) +ifeq ($(LINUX_OR_MACOS),true) +USING_JUCE_GUI_EXTRA = true +endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set USING_RTAUDIO + +ifneq ($(HAIKU),true) +ifneq ($(USING_JUCE_AUDIO_DEVICES),true) +USING_RTAUDIO = true +endif +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set libs stuff (part 1) + +ifneq ($(HAIKU_OR_MACOS_OR_WIN32),true) +LIBDL_LIBS = -ldl +endif + +ifeq ($(HAVE_DGL),true) +ifeq ($(MACOS),true) +DGL_LIBS = -framework OpenGL -framework Cocoa +endif +ifeq ($(WIN32),true) +DGL_LIBS = -lopengl32 -lgdi32 +endif +ifneq ($(MACOS_OR_WIN32),true) +DGL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags gl x11) +DGL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs gl x11) +endif +endif + +ifeq ($(HAVE_LIBLO),true) +LIBLO_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags liblo) +LIBLO_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs liblo) +endif + +ifeq ($(HAVE_LIBMAGICPKG),true) +MAGIC_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libmagic) +# this is missing in upstream pkg-config +MAGIC_FLAGS += -I$(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --variable=includedir libmagic) +MAGIC_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libmagic) +else ifeq ($(HAVE_LIBMAGIC),true) +MAGIC_LIBS += -lmagic +ifeq ($(LINUX_OR_MACOS),true) +MAGIC_LIBS += -lz +endif +endif + +ifeq ($(HAVE_FFMPEG),true) +FFMPEG_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libavcodec libavformat libavutil) +FFMPEG_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libavcodec libavformat libavutil) +endif + +ifeq ($(HAVE_FLUIDSYNTH),true) +FLUIDSYNTH_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags fluidsynth) +FLUIDSYNTH_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs fluidsynth) +endif + +ifeq ($(HAVE_JACK),true) +JACK_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags jack) +JACK_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs jack) +JACK_LIBDIR = $(shell $(PKG_CONFIG) --variable=libdir jack)/jack +endif + +ifeq ($(HAVE_QT5),true) +QT5_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags Qt5Core Qt5Gui Qt5Widgets) +QT5_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs Qt5Core Qt5Gui Qt5Widgets) +endif + +ifeq ($(HAVE_SNDFILE),true) +SNDFILE_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sndfile) +SNDFILE_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sndfile) +endif + +ifeq ($(HAVE_X11),true) +X11_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags x11) +X11_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11) +endif + +# --------------------------------------------------------------------------------------------------------------------- +# Set libs stuff (part 2) + +ifeq ($(USING_RTAUDIO),true) + +RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY +RTMIDI_FLAGS = + +ifeq ($(DEBUG),true) +RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__ +RTMIDI_FLAGS += -D__RTMIDI_DEBUG__ +endif + +ifeq ($(LINUX),true) +ifeq ($(HAVE_ALSA),true) +RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__ +RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -pthread +RTMIDI_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__ +RTMIDI_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) +endif +endif + +ifeq ($(MACOS),true) +RTAUDIO_FLAGS += -D__MACOSX_CORE__ +RTAUDIO_LIBS += -framework CoreAudio +RTMIDI_FLAGS += -D__MACOSX_CORE__ +RTMIDI_LIBS += -framework CoreMIDI +endif + +ifeq ($(UNIX),true) +RTAUDIO_FLAGS += -D__UNIX_JACK__ +ifeq ($(HAVE_PULSEAUDIO),true) +RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libpulse-simple) -D__UNIX_PULSE__ +RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libpulse-simple) +endif +endif + +ifeq ($(WIN32),true) +RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__ +RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm +RTMIDI_FLAGS += -D__WINDOWS_MM__ +endif + +endif # USING_RTAUDIO + +ifeq ($(BSD),true) +JACKBRIDGE_LIBS = -pthread -lrt +LILV_LIBS = -lm -lrt +RTMEMPOOL_LIBS = -pthread +WATER_LIBS = -pthread -lrt +endif + +ifeq ($(HAIKU),true) +JACKBRIDGE_LIBS = -pthread +LILV_LIBS = -lm +RTMEMPOOL_LIBS = -pthread +WATER_LIBS = -pthread +endif + +ifeq ($(HURD),true) +JACKBRIDGE_LIBS = -ldl -pthread -lrt +LILV_LIBS = -ldl -lm -lrt +RTMEMPOOL_LIBS = -pthread -lrt +WATER_LIBS = -ldl -pthread -lrt +endif + +ifeq ($(LINUX),true) +HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1 +JACKBRIDGE_LIBS = -ldl -pthread -lrt +LILV_LIBS = -ldl -lm -lrt +RTMEMPOOL_LIBS = -pthread -lrt +WATER_LIBS = -ldl -pthread -lrt +ifeq ($(USING_JUCE),true) +JUCE_AUDIO_DEVICES_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) +JUCE_CORE_LIBS = -ldl -pthread -lrt +JUCE_EVENTS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11) +JUCE_GRAPHICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs freetype2) +JUCE_GUI_BASICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11 xext) +endif # USING_JUCE +endif # LINUX + +ifeq ($(MACOS),true) +HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1 +JACKBRIDGE_LIBS = -ldl -pthread +LILV_LIBS = -ldl -lm +RTMEMPOOL_LIBS = -pthread +WATER_LIBS = -framework AppKit +ifeq ($(USING_JUCE),true) +JUCE_AUDIO_BASICS_LIBS = -framework Accelerate +JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI +JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation +JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon +JUCE_CORE_LIBS = -framework AppKit +JUCE_EVENTS_LIBS = -framework AppKit +JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore +JUCE_GUI_BASICS_LIBS = -framework Cocoa +JUCE_GUI_EXTRA_LIBS = -framework IOKit +endif # USING_JUCE +endif # MACOS + +ifeq ($(WIN32),true) +HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1 +HYLIA_LIBS = -liphlpapi +JACKBRIDGE_LIBS = -pthread +LILV_LIBS = -lm +RTMEMPOOL_LIBS = -pthread +WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm +ifeq ($(USING_JUCE),true) +JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32 +JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm +JUCE_GRAPHICS_LIBS = -lgdi32 +JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32 +endif # USING_JUCE +endif # WIN32 + +# --------------------------------------------------------------------------------------------------------------------- + +AUDIO_DECODER_LIBS = $(FFMPEG_LIBS) +AUDIO_DECODER_LIBS += $(SNDFILE_LIBS) + +NATIVE_PLUGINS_LIBS += $(DGL_LIBS) +NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS) +NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS) + +STATIC_CARLA_PLUGIN_LIBS = $(AUDIO_DECODER_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(NATIVE_PLUGINS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(FLUIDSYNTH_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(HYLIA_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(LIBLO_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(LILV_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(MAGIC_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(RTMEMPOOL_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(WATER_LIBS) + +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_BASICS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_FORMATS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_PROCESSORS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_CORE_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_EVENTS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GRAPHICS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GUI_BASICS_LIBS) +STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GUI_EXTRA_LIBS) + +# --------------------------------------------------------------------------------------------------------------------- diff --git a/source/Makefile.mk b/source/Makefile.mk index 15962f099..d46890c62 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -19,141 +19,9 @@ WINECC ?= winegcc I18N_LANGUAGES := # --------------------------------------------------------------------------------------------------------------------- -# Auto-detect OS if not defined +# Base definitions for dependencies and system type -TARGET_MACHINE := $(shell $(CC) -dumpmachine) - -ifneq ($(BSD),true) -ifneq ($(HAIKU),true) -ifneq ($(HURD),true) -ifneq ($(LINUX),true) -ifneq ($(MACOS),true) -ifneq ($(WIN32),true) - -ifneq (,$(findstring bsd,$(TARGET_MACHINE))) -BSD=true -endif -ifneq (,$(findstring haiku,$(TARGET_MACHINE))) -HAIKU=true -endif -ifneq (,$(findstring gnu,$(TARGET_MACHINE))) -HURD=true -endif -ifneq (,$(findstring linux,$(TARGET_MACHINE))) -LINUX=true -endif -ifneq (,$(findstring apple,$(TARGET_MACHINE))) -MACOS=true -endif -ifneq (,$(findstring mingw,$(TARGET_MACHINE))) -WIN32=true -ifneq (,$(findstring x86_64,$(TARGET_MACHINE))) -WIN64=true -endif -endif -ifneq (,$(findstring msys,$(TARGET_MACHINE))) -WIN32=true -endif - -endif # WIN32 -endif # MACOS -endif # LINUX -endif # HURD -endif # HAIKU -endif # BSD - -# --------------------------------------------------------------------------------------------------------------------- -# Auto-detect the processor - -TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE))) - -ifneq (,$(filter i%86,$(TARGET_PROCESSOR))) -CPU_I386=true -CPU_I386_OR_X86_64=true -endif -ifneq (,$(filter x86_64,$(TARGET_PROCESSOR))) -CPU_X86_64=true -CPU_I386_OR_X86_64=true -endif -ifneq (,$(filter arm%,$(TARGET_PROCESSOR))) -CPU_ARM=true -CPU_ARM_OR_AARCH64=true -endif -ifneq (,$(filter arm64%,$(TARGET_PROCESSOR))) -CPU_ARM64=true -CPU_ARM_OR_AARCH64=true -endif -ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR))) -CPU_AARCH64=true -CPU_ARM_OR_AARCH64=true -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set wherever to build static binaries (Windows only) - -ifeq ($(WIN32),true) -ifneq ($(MSYSTEM),MINGW32) -ifneq ($(MSYSTEM),MINGW64) -STATIC_BINARIES = true -endif -endif -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set PKG_CONFIG (can be overridden by environment variable) - -PKG_CONFIG ?= pkg-config - -ifeq ($(STATIC_BINARIES),true) -PKG_CONFIG_FLAGS = --static -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set LINUX_OR_MACOS - -ifeq ($(LINUX),true) -LINUX_OR_MACOS=true -endif - -ifeq ($(MACOS),true) -LINUX_OR_MACOS=true -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set MACOS_OR_WIN32 and HAIKU_OR_MACOS_OR_WINDOWS - -ifeq ($(HAIKU),true) -HAIKU_OR_MACOS_OR_WIN32=true -endif - -ifeq ($(MACOS),true) -MACOS_OR_WIN32=true -HAIKU_OR_MACOS_OR_WIN32=true -endif - -ifeq ($(WIN32),true) -MACOS_OR_WIN32=true -HAIKU_OR_MACOS_OR_WIN32=true -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set UNIX - -ifeq ($(BSD),true) -UNIX=true -endif - -ifeq ($(HURD),true) -UNIX=true -endif - -ifeq ($(LINUX),true) -UNIX=true -endif - -ifeq ($(MACOS),true) -UNIX=true -endif +include $(CWD)/Makefile.deps.mk # --------------------------------------------------------------------------------------------------------------------- # Set build and link flags @@ -287,187 +155,6 @@ BASE_FLAGS += -Wno-tautological-pointer-compare endif endif -# --------------------------------------------------------------------------------------------------------------------- -# Check for optional libs (required by backend or bridges) - -ifeq ($(LINUX),true) -HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true) -HAVE_HYLIA = true -endif - -ifeq ($(MACOS),true) -ifneq ($(MACOS_OLD),true) -HAVE_HYLIA = true -endif -endif - -ifeq ($(WIN32),true) -HAVE_HYLIA = true -endif - -ifeq ($(MACOS_OR_WIN32),true) -HAVE_DGL = true -else -HAVE_DGL = $(shell $(PKG_CONFIG) --exists gl x11 && echo true) -HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true) -endif - -ifeq ($(UNIX),true) -ifneq ($(MACOS),true) -HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true) -endif -endif - -# ffmpeg values taken from https://ffmpeg.org/download.html (v2.8.15 maximum) -HAVE_FFMPEG = $(shell $(PKG_CONFIG) --max-version=56.60.100 libavcodec && \ - $(PKG_CONFIG) --max-version=56.40.101 libavformat && \ - $(PKG_CONFIG) --max-version=54.31.100 libavutil && echo true) -HAVE_FLUIDSYNTH = $(shell $(PKG_CONFIG) --atleast-version=1.1.7 fluidsynth && echo true) -HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true) -HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true) -HAVE_QT4 = $(shell $(PKG_CONFIG) --exists QtCore QtGui && echo true) -HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \ - $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true) -HAVE_QT5PKG = $(shell $(PKG_CONFIG) --silence-errors --variable=prefix Qt5OpenGLExtensions 1>/dev/null && echo true) -HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true) - -ifeq ($(HAVE_FLUIDSYNTH),true) -HAVE_FLUIDSYNTH_INSTPATCH = $(shell $(PKG_CONFIG) --atleast-version=2.1.0 fluidsynth && \ - $(PKG_CONFIG) --atleast-version=1.1.4 libinstpatch-1.0 && echo true) -endif - -ifeq ($(LINUX),true) -# juce only supports the most common architectures -ifneq (,$(findstring arm,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifneq (,$(findstring aarch64,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifneq (,$(findstring i486,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifneq (,$(findstring i586,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifneq (,$(findstring i686,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifneq (,$(findstring x86_64,$(TARGET_MACHINE))) -HAVE_JUCE_SUPPORTED_ARCH = true -endif -ifeq ($(HAVE_JUCE_SUPPORTED_ARCH),true) -HAVE_JUCE_LINUX_DEPS = $(shell $(PKG_CONFIG) --exists x11 xcursor xext freetype2 && echo true) -endif -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Check for optional libs (special non-pkgconfig tests) - -ifneq ($(WIN32),true) - -ifeq ($(shell $(PKG_CONFIG) --exists libmagic && echo true),true) -HAVE_LIBMAGIC = true -HAVE_LIBMAGICPKG = true -else -# old libmagic versions don't have a pkg-config file, so we need to call the compiler to test it -CFLAGS_WITHOUT_ARCH = $(subst -arch arm64,,$(CFLAGS)) -HAVE_LIBMAGIC = $(shell echo '\#include ' | $(CC) $(CFLAGS_WITHOUT_ARCH) -x c -w -c - -o /dev/null 2>/dev/null && echo true) -endif - -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set Qt tools - -ifeq ($(HAVE_QT4),true) -MOC_QT4 ?= $(shell $(PKG_CONFIG) --variable=moc_location QtCore) -RCC_QT4 ?= $(shell $(PKG_CONFIG) --variable=rcc_location QtCore) -UIC_QT4 ?= $(shell $(PKG_CONFIG) --variable=uic_location QtCore) -ifeq (,$(wildcard $(MOC_QT4))) -HAVE_QT4=false -endif -ifeq (,$(wildcard $(RCC_QT4))) -HAVE_QT4=false -endif -endif - -ifeq ($(HAVE_QT5),true) -QT5_HOSTBINS = $(shell $(PKG_CONFIG) --variable=host_bins Qt5Core) -MOC_QT5 ?= $(QT5_HOSTBINS)/moc -RCC_QT5 ?= $(QT5_HOSTBINS)/rcc -UIC_QT5 ?= $(QT5_HOSTBINS)/uic -ifeq (,$(wildcard $(MOC_QT5))) -HAVE_QT5=false -endif -ifeq (,$(wildcard $(RCC_QT5))) -HAVE_QT5=false -endif -endif - -ifeq ($(HAVE_QT4),true) -HAVE_QT=true -endif -ifeq ($(HAVE_QT5),true) -HAVE_QT=true -endif -ifeq ($(WIN32),true) -HAVE_QT=true -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set PyQt tools - -PYRCC5 ?= $(shell which pyrcc5 2>/dev/null) -PYUIC5 ?= $(shell which pyuic5 2>/dev/null) - -ifneq ($(PYUIC5),) -ifneq ($(PYRCC5),) -HAVE_PYQT = true -endif -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set PyQt tools, part2 - -PYRCC ?= $(PYRCC5) -PYUIC ?= $(PYUIC5) - -ifeq ($(HAVE_QT5),true) -HAVE_THEME = true -# else -# ifeq ($(MACOS),true) -# ifneq ($(MACOS_OLD),true) -# ifeq ($(HAVE_PYQT),true) -# HAVE_THEME = true -# MOC_QT5 ?= moc -# RCC_QT5 ?= rcc -# UIC_QT5 ?= uic -# endif -# endif -# endif -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set USING_JUCE - -ifeq ($(MACOS_OR_WIN32),true) -ifneq ($(MACOS_OLD),true) -USING_JUCE = true -USING_JUCE_AUDIO_DEVICES = true -endif -endif - -ifeq ($(HAVE_JUCE_LINUX_DEPS),true) -USING_JUCE = true -endif - -ifeq ($(USING_JUCE),true) -ifeq ($(LINUX_OR_MACOS),true) -USING_JUCE_GUI_EXTRA = true -endif -endif - # --------------------------------------------------------------------------------------------------------------------- # Set base defines @@ -531,198 +218,6 @@ ifeq ($(USING_JUCE_GUI_EXTRA),true) BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA endif -# --------------------------------------------------------------------------------------------------------------------- -# Set libs stuff (part 1) - -ifeq ($(LINUX_OR_MACOS),true) -LIBDL_LIBS = -ldl -endif - -ifeq ($(HAVE_DGL),true) -ifeq ($(MACOS),true) -DGL_LIBS = -framework OpenGL -framework Cocoa -endif -ifeq ($(WIN32),true) -DGL_LIBS = -lopengl32 -lgdi32 -endif -ifneq ($(MACOS_OR_WIN32),true) -DGL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags gl x11) -DGL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs gl x11) -endif -endif - -ifeq ($(HAVE_LIBLO),true) -LIBLO_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags liblo) -LIBLO_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs liblo) -endif - -ifeq ($(HAVE_LIBMAGICPKG),true) -MAGIC_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libmagic) -# this is missing in upstream pkg-config -MAGIC_FLAGS += -I$(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --variable=includedir libmagic) -MAGIC_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libmagic) -else ifeq ($(HAVE_LIBMAGIC),true) -MAGIC_LIBS += -lmagic -ifeq ($(LINUX_OR_MACOS),true) -MAGIC_LIBS += -lz -endif -endif - -ifeq ($(HAVE_FFMPEG),true) -FFMPEG_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libavcodec libavformat libavutil) -FFMPEG_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libavcodec libavformat libavutil) -endif - -ifeq ($(HAVE_FLUIDSYNTH),true) -FLUIDSYNTH_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags fluidsynth) -FLUIDSYNTH_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs fluidsynth) -endif - -ifeq ($(HAVE_JACK),true) -JACK_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags jack) -JACK_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs jack) -JACK_LIBDIR = $(shell $(PKG_CONFIG) --variable=libdir jack)/jack -endif - -ifeq ($(HAVE_QT5),true) -QT5_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags Qt5Core Qt5Gui Qt5Widgets) -QT5_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs Qt5Core Qt5Gui Qt5Widgets) -endif - -ifeq ($(HAVE_SNDFILE),true) -SNDFILE_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sndfile) -SNDFILE_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sndfile) -endif - -ifeq ($(HAVE_X11),true) -X11_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags x11) -X11_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11) -endif - -# --------------------------------------------------------------------------------------------------------------------- -# Set libs stuff (part 2) - -ifneq ($(USING_JUCE_AUDIO_DEVICES),true) - -RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -RTMIDI_FLAGS = - -ifeq ($(DEBUG),true) -RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__ -RTMIDI_FLAGS += -D__RTMIDI_DEBUG__ -endif - -ifeq ($(LINUX),true) -ifeq ($(HAVE_ALSA),true) -RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__ -RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -pthread -RTMIDI_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__ -RTMIDI_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -endif -endif - -ifeq ($(MACOS),true) -RTAUDIO_FLAGS += -D__MACOSX_CORE__ -RTAUDIO_LIBS += -framework CoreAudio -RTMIDI_FLAGS += -D__MACOSX_CORE__ -RTMIDI_LIBS += -framework CoreMIDI -endif - -ifeq ($(UNIX),true) -RTAUDIO_FLAGS += -D__UNIX_JACK__ -ifeq ($(HAVE_PULSEAUDIO),true) -RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libpulse-simple) -D__UNIX_PULSE__ -RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libpulse-simple) -endif -endif - -ifeq ($(WIN32),true) -RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__ -RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm -RTMIDI_FLAGS += -D__WINDOWS_MM__ -endif - -endif # USING_JUCE_AUDIO_DEVICES - -ifeq ($(BSD),true) -JACKBRIDGE_LIBS = -pthread -lrt -LILV_LIBS = -lm -lrt -RTMEMPOOL_LIBS = -pthread -WATER_LIBS = -pthread -lrt -endif - -ifeq ($(HAIKU),true) -JACKBRIDGE_LIBS = -pthread -LILV_LIBS = -lm -RTMEMPOOL_LIBS = -pthread -WATER_LIBS = -pthread -endif - -ifeq ($(HURD),true) -JACKBRIDGE_LIBS = -ldl -pthread -lrt -LILV_LIBS = -ldl -lm -lrt -RTMEMPOOL_LIBS = -pthread -lrt -WATER_LIBS = -ldl -pthread -lrt -endif - -ifeq ($(LINUX),true) -HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1 -JACKBRIDGE_LIBS = -ldl -pthread -lrt -LILV_LIBS = -ldl -lm -lrt -RTMEMPOOL_LIBS = -pthread -lrt -WATER_LIBS = -ldl -pthread -lrt -ifeq ($(USING_JUCE),true) -JUCE_AUDIO_DEVICES_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -JUCE_CORE_LIBS = -ldl -pthread -lrt -JUCE_EVENTS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11) -JUCE_GRAPHICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs freetype2) -JUCE_GUI_BASICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11 xext) -endif # USING_JUCE -endif # LINUX - -ifeq ($(MACOS),true) -HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1 -JACKBRIDGE_LIBS = -ldl -pthread -LILV_LIBS = -ldl -lm -RTMEMPOOL_LIBS = -pthread -WATER_LIBS = -framework AppKit -ifeq ($(USING_JUCE),true) -JUCE_AUDIO_BASICS_LIBS = -framework Accelerate -JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI -JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation -JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon -JUCE_CORE_LIBS = -framework AppKit -JUCE_EVENTS_LIBS = -framework AppKit -JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore -JUCE_GUI_BASICS_LIBS = -framework Cocoa -JUCE_GUI_EXTRA_LIBS = -framework IOKit -endif # USING_JUCE -endif # MACOS - -ifeq ($(WIN32),true) -HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1 -HYLIA_LIBS = -liphlpapi -JACKBRIDGE_LIBS = -pthread -LILV_LIBS = -lm -RTMEMPOOL_LIBS = -pthread -WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm -ifeq ($(USING_JUCE),true) -JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32 -JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm -JUCE_GRAPHICS_LIBS = -lgdi32 -JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32 -endif # USING_JUCE -endif # WIN32 - -# --------------------------------------------------------------------------------------------------------------------- - -AUDIO_DECODER_LIBS = $(FFMPEG_LIBS) -AUDIO_DECODER_LIBS += $(SNDFILE_LIBS) - -NATIVE_PLUGINS_LIBS += $(DGL_LIBS) -NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS) -NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS) - # --------------------------------------------------------------------------------------------------------------------- # Set app extension From 30ddf5885fa4995e87a73b6568ec53a3e614a56d Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 16:25:05 +0100 Subject: [PATCH 04/12] Lead by example Signed-off-by: falkTX --- source/Makefile.deps.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/Makefile.deps.mk b/source/Makefile.deps.mk index c9642076b..b3a000a79 100644 --- a/source/Makefile.deps.mk +++ b/source/Makefile.deps.mk @@ -533,6 +533,7 @@ STATIC_CARLA_PLUGIN_LIBS += $(MAGIC_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(RTMEMPOOL_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(WATER_LIBS) +ifeq ($(USING_JUCE),true) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_BASICS_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_FORMATS_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_AUDIO_PROCESSORS_LIBS) @@ -540,6 +541,9 @@ STATIC_CARLA_PLUGIN_LIBS += $(JUCE_CORE_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_EVENTS_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GRAPHICS_LIBS) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GUI_BASICS_LIBS) +ifeq ($(USING_JUCE_GUI_EXTRA),true) STATIC_CARLA_PLUGIN_LIBS += $(JUCE_GUI_EXTRA_LIBS) +endif +endif # --------------------------------------------------------------------------------------------------------------------- From 5db3077f25ac7436855f70e7dfd4d4df4cc5ef29 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 17:10:04 +0100 Subject: [PATCH 05/12] Start using USING_RTAUDIO macro Signed-off-by: falkTX --- source/backend/Makefile | 4 ++-- source/backend/engine/Makefile | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/backend/Makefile b/source/backend/Makefile index f1305439f..06423ebbc 100644 --- a/source/backend/Makefile +++ b/source/backend/Makefile @@ -58,7 +58,7 @@ STANDALONE_LIBS += $(MODULEDIR)/juce_gui_extra.a endif endif -ifneq ($(USING_JUCE_AUDIO_DEVICES),true) +ifeq ($(USING_RTAUDIO),true) STANDALONE_LIBS += $(MODULEDIR)/rtaudio.a STANDALONE_LIBS += $(MODULEDIR)/rtmidi.a endif @@ -93,7 +93,7 @@ STANDALONE_LINK_FLAGS += $(JUCE_GUI_EXTRA_LIBS) endif endif -ifneq ($(USING_JUCE_AUDIO_DEVICES),true) +ifeq ($(USING_RTAUDIO),true) STANDALONE_LINK_FLAGS += $(RTAUDIO_LIBS) STANDALONE_LINK_FLAGS += $(RTMIDI_LIBS) endif diff --git a/source/backend/engine/Makefile b/source/backend/engine/Makefile index 75bd0fb79..e034f0e7c 100644 --- a/source/backend/engine/Makefile +++ b/source/backend/engine/Makefile @@ -42,7 +42,9 @@ OBJSa = $(OBJS) \ ifeq ($(USING_JUCE_AUDIO_DEVICES),true) OBJSa += \ $(OBJDIR)/CarlaEngineJuce.cpp.o -else +endif + +ifeq ($(USING_RTAUDIO),true) OBJSa += \ $(OBJDIR)/CarlaEngineRtAudio.cpp.o endif From 93cbcaf9cbbd5e608d72795cb46ef2abbf5657e3 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 17:19:00 +0100 Subject: [PATCH 06/12] More USING_RTAUDIO setup, build jackbridge.min.a Signed-off-by: falkTX --- Makefile | 2 +- source/Makefile.mk | 4 ++++ source/backend/engine/CarlaEngine.cpp | 18 ++++++++++++------ source/jackbridge/Makefile | 9 ++++++++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index af8f7b257..68297618e 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ ifeq ($(USING_JUCE_GUI_EXTRA),true) endif endif -ifneq ($(USING_JUCE_AUDIO_DEVICES),true) +ifeq ($(USING_RTAUDIO),true) 3RD_LIBS += $(MODULEDIR)/rtaudio.a 3RD_LIBS += $(MODULEDIR)/rtmidi.a endif diff --git a/source/Makefile.mk b/source/Makefile.mk index d46890c62..3f8bce4fb 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -218,6 +218,10 @@ ifeq ($(USING_JUCE_GUI_EXTRA),true) BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA endif +ifeq ($(USING_RTAUDIO),true) +BASE_FLAGS += -DUSING_RTAUDIO +endif + # --------------------------------------------------------------------------------------------------------------------- # Set app extension diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index d9f021fe0..505dd70c9 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -101,7 +101,8 @@ uint CarlaEngine::getDriverCount() #ifndef BUILD_BRIDGE # ifdef USING_JUCE_AUDIO_DEVICES count += getJuceApiCount(); -# else +# endif +# ifdef USING_RTAUDIO count += getRtAudioApiCount(); # endif #endif @@ -127,7 +128,8 @@ const char* CarlaEngine::getDriverName(const uint index2) return getJuceApiName(index); index -= count; } -# else +# endif +# ifdef USING_RTAUDIO if (const uint count = getRtAudioApiCount()) { if (index < count) @@ -161,7 +163,8 @@ const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) return getJuceApiDeviceNames(index); index -= count; } -# else +# endif +# ifdef USING_RTAUDIO if (const uint count = getRtAudioApiCount()) { if (index < count) @@ -198,7 +201,8 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 return getJuceDeviceInfo(index, deviceName); index -= count; } -# else +# endif +# ifdef USING_RTAUDIO if (const uint count = getRtAudioApiCount()) { if (index < count) @@ -231,7 +235,8 @@ bool CarlaEngine::showDriverDeviceControlPanel(const uint index2, const char* co return showJuceDeviceControlPanel(index, deviceName); index -= count; } -# else +# endif +# ifdef USING_RTAUDIO if (const uint count = getRtAudioApiCount()) { if (index < count) @@ -281,7 +286,8 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) return newJuce(AUDIO_API_DIRECTSOUND); if (std::strcmp(driverName, "WASAPI") == 0 || std::strcmp(driverName, "Windows Audio") == 0) return newJuce(AUDIO_API_WASAPI); -# else +# endif +# ifdef USING_RTAUDIO // ------------------------------------------------------------------- // common diff --git a/source/jackbridge/Makefile b/source/jackbridge/Makefile index 9a54d4f9e..d070b96e3 100644 --- a/source/jackbridge/Makefile +++ b/source/jackbridge/Makefile @@ -54,6 +54,7 @@ endif # --------------------------------------------------------------------------------------------------------------------- OBJS = $(OBJDIR)/JackBridge1.cpp.o $(OBJDIR)/JackBridge2.cpp.o +OBJS_min = $(OBJDIR)/JackBridge2.cpp.o OBJS_arm32 = $(OBJDIR)/JackBridge1.cpp.arm32.o $(OBJDIR)/JackBridge2.cpp.arm32.o OBJS_posix32 = $(OBJDIR)/JackBridge1.cpp.posix32.o $(OBJDIR)/JackBridge2.cpp.posix32.o OBJS_posix64 = $(OBJDIR)/JackBridge1.cpp.posix64.o $(OBJDIR)/JackBridge2.cpp.posix64.o @@ -69,7 +70,7 @@ OBJS_win32e = $(OBJDIR)/JackBridgeExport.cpp.win32e.o # --------------------------------------------------------------------------------------------------------------------- -all: $(MODULEDIR)/$(MODULENAME).a +all: $(MODULEDIR)/$(MODULENAME).a $(MODULEDIR)/$(MODULENAME).min.a ifeq ($(WIN32),true) posix32: @@ -112,6 +113,12 @@ $(MODULEDIR)/$(MODULENAME).a: $(OBJS) @rm -f $@ @$(AR) crs $@ $^ +$(MODULEDIR)/$(MODULENAME).min.a: $(OBJS_min) + -@mkdir -p $(MODULEDIR) + @echo "Creating $(MODULENAME).min.a" + @rm -f $@ + @$(AR) crs $@ $^ + $(MODULEDIR)/$(MODULENAME).arm32.a: $(OBJS_arm32) -@mkdir -p $(MODULEDIR) @echo "Creating $(MODULENAME).arm32.a" From f9d0e062608f4fea99598faac1cb034d56eaea22 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 21:13:11 +0100 Subject: [PATCH 07/12] Add carla_get_plugin_latency host function Signed-off-by: falkTX --- source/backend/CarlaHost.h | 7 +++++++ source/backend/CarlaStandalone.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 86c255c67..32339c4ae 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -893,6 +893,13 @@ CARLA_EXPORT float carla_get_current_parameter_value(CarlaHostHandle handle, uin */ CARLA_EXPORT float carla_get_internal_parameter_value(CarlaHostHandle handle, uint pluginId, int32_t parameterId); +/*! + * Get a plugin's internal latency, in samples. + * @param pluginId Plugin + * @see InternalParameterIndex + */ +CARLA_EXPORT uint32_t carla_get_plugin_latency(CarlaHostHandle handle, uint pluginId); + /*! * Get a plugin's peak values. * @param pluginId Plugin diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 96e2be2d3..1d9427073 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -1960,6 +1960,18 @@ float carla_get_internal_parameter_value(CarlaHostHandle handle, uint pluginId, // -------------------------------------------------------------------------------------------------------------------- +uint32_t carla_get_plugin_latency(CarlaHostHandle handle, uint pluginId) +{ + CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0); + + if (const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId)) + return plugin->getLatency(); + + return 0; +} + +// -------------------------------------------------------------------------------------------------------------------- + const float* carla_get_peak_values(CarlaHostHandle handle, uint pluginId) { CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, nullptr); From 73cf85350955d5d985712513ccecb0d7f33c1df7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 21:19:40 +0100 Subject: [PATCH 08/12] Correct last commit Signed-off-by: falkTX --- source/backend/CarlaStandalone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 1d9427073..9c29e20fa 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -1965,7 +1965,7 @@ uint32_t carla_get_plugin_latency(CarlaHostHandle handle, uint pluginId) CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0); if (const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId)) - return plugin->getLatency(); + return plugin->getLatencyInFrames(); return 0; } From 183fc4e23689db7eb9f851ba70345f8bbf852461 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 13 Oct 2021 22:36:56 +0100 Subject: [PATCH 09/12] Tweaks for Ildaeil, MemoryOutputStream::getDataAndRelease() Signed-off-by: falkTX --- source/backend/CarlaEngine.hpp | 2 + source/modules/water/memory/HeapBlock.h | 8 +++ source/modules/water/memory/MemoryBlock.cpp | 7 ++ source/modules/water/memory/MemoryBlock.h | 4 ++ .../water/streams/MemoryOutputStream.cpp | 68 +++++++------------ .../water/streams/MemoryOutputStream.h | 17 ++--- source/modules/water/streams/OutputStream.h | 1 + 7 files changed, 55 insertions(+), 52 deletions(-) diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 8fa7624d6..8e571f81a 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -1341,6 +1341,7 @@ protected: */ void setPluginPeaksRT(uint pluginId, float const inPeaks[2], float const outPeaks[2]) noexcept; +public: /*! * Common save project function for main engine and plugin. */ @@ -1351,6 +1352,7 @@ protected: */ bool loadProjectInternal(water::XmlDocument& xmlDoc, bool alwaysLoadConnections); +protected: // ------------------------------------------------------------------- // Helper functions diff --git a/source/modules/water/memory/HeapBlock.h b/source/modules/water/memory/HeapBlock.h index 0540f5daa..b8c232e11 100644 --- a/source/modules/water/memory/HeapBlock.h +++ b/source/modules/water/memory/HeapBlock.h @@ -253,6 +253,14 @@ public: zeromem (data, sizeof (ElementType) * numElements); } + /** Release this object's data ownership, returning the data pointer. */ + ElementType* release() noexcept + { + ElementType* const r = data; + data = nullptr; + return r; + } + /** This typedef can be used to get the type of the heapblock's elements. */ typedef ElementType Type; diff --git a/source/modules/water/memory/MemoryBlock.cpp b/source/modules/water/memory/MemoryBlock.cpp index d587d1a8d..6e83b8dfc 100644 --- a/source/modules/water/memory/MemoryBlock.cpp +++ b/source/modules/water/memory/MemoryBlock.cpp @@ -167,6 +167,13 @@ void MemoryBlock::swapWith (MemoryBlock& other) noexcept data.swapWith (other.data); } +//============================================================================== +void* MemoryBlock::release () noexcept +{ + size = 0; + return data.release(); +} + //============================================================================== void MemoryBlock::fillWith (const uint8 value) noexcept { diff --git a/source/modules/water/memory/MemoryBlock.h b/source/modules/water/memory/MemoryBlock.h index 68ea518fd..4383139d6 100644 --- a/source/modules/water/memory/MemoryBlock.h +++ b/source/modules/water/memory/MemoryBlock.h @@ -197,6 +197,10 @@ public: */ void swapWith (MemoryBlock& other) noexcept; + //============================================================================== + /** Release this object's data ownership, returning the data pointer. */ + void* release () noexcept; + //============================================================================== /** Attempts to parse the contents of the block as a zero-terminated UTF8 string. */ String toString() const; diff --git a/source/modules/water/streams/MemoryOutputStream.cpp b/source/modules/water/streams/MemoryOutputStream.cpp index ff18d5a5f..ac01071d3 100644 --- a/source/modules/water/streams/MemoryOutputStream.cpp +++ b/source/modules/water/streams/MemoryOutputStream.cpp @@ -29,28 +29,21 @@ namespace water { MemoryOutputStream::MemoryOutputStream (const size_t initialSize) - : blockToUse (&internalBlock), externalData (nullptr), - position (0), size (0), availableSize (0) + : internalBlock(), blockToUse (internalBlock), + position (0), size (0) { internalBlock.setSize (initialSize, false); } MemoryOutputStream::MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, const bool appendToExistingBlockContent) - : blockToUse (&memoryBlockToWriteTo), externalData (nullptr), - position (0), size (0), availableSize (0) + : internalBlock(), blockToUse (memoryBlockToWriteTo), + position (0), size (0) { if (appendToExistingBlockContent) position = size = memoryBlockToWriteTo.getSize(); } -MemoryOutputStream::MemoryOutputStream (void* destBuffer, size_t destBufferSize) - : blockToUse (nullptr), externalData (destBuffer), - position (0), size (0), availableSize (destBufferSize) -{ - wassert (externalData != nullptr); // This must be a valid pointer. -} - MemoryOutputStream::~MemoryOutputStream() { trimExternalBlockSize(); @@ -63,14 +56,13 @@ void MemoryOutputStream::flush() void MemoryOutputStream::trimExternalBlockSize() { - if (blockToUse != &internalBlock && blockToUse != nullptr) - blockToUse->setSize (size, false); + if (blockToUse != internalBlock) + blockToUse.setSize (size, false); } void MemoryOutputStream::preallocate (const size_t bytesToPreallocate) { - if (blockToUse != nullptr) - blockToUse->ensureSize (bytesToPreallocate + 1); + blockToUse.ensureSize (bytesToPreallocate + 1); } void MemoryOutputStream::reset() noexcept @@ -81,26 +73,14 @@ void MemoryOutputStream::reset() noexcept char* MemoryOutputStream::prepareToWrite (size_t numBytes) { - wassert ((ssize_t) numBytes >= 0); - size_t storageNeeded = position + numBytes; + CARLA_SAFE_ASSERT_RETURN ((ssize_t) numBytes >= 0, nullptr); - char* data; + const size_t storageNeeded = position + numBytes; - if (blockToUse != nullptr) - { - if (storageNeeded >= blockToUse->getSize()) - blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u); - - data = static_cast (blockToUse->getData()); - } - else - { - if (storageNeeded > availableSize) - return nullptr; - - data = static_cast (externalData); - } + if (storageNeeded >= blockToUse.getSize()) + blockToUse.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u); + char* const data = static_cast (blockToUse.getData()); char* const writePointer = data + position; position += numBytes; size = jmax (size, position); @@ -109,14 +89,14 @@ char* MemoryOutputStream::prepareToWrite (size_t numBytes) bool MemoryOutputStream::write (const void* const buffer, size_t howMany) { - wassert (buffer != nullptr); + CARLA_SAFE_ASSERT_RETURN (buffer != nullptr, false); if (howMany == 0) return true; - if (char* dest = prepareToWrite (howMany)) + if (char* const dest = prepareToWrite (howMany)) { - memcpy (dest, buffer, howMany); + std::memcpy (dest, buffer, howMany); return true; } @@ -155,13 +135,18 @@ MemoryBlock MemoryOutputStream::getMemoryBlock() const const void* MemoryOutputStream::getData() const noexcept { - if (blockToUse == nullptr) - return externalData; + if (blockToUse.getSize() > size) + static_cast (blockToUse.getData()) [size] = 0; - if (blockToUse->getSize() > size) - static_cast (blockToUse->getData()) [size] = 0; + return blockToUse.getData(); +} + +void* MemoryOutputStream::getDataAndRelease() noexcept +{ + if (blockToUse.getSize() > size) + static_cast (blockToUse.getData()) [size] = 0; - return blockToUse->getData(); + return blockToUse.release(); } bool MemoryOutputStream::setPosition (int64 newPosition) @@ -187,8 +172,7 @@ int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNu if (maxNumBytesToWrite > availableData || maxNumBytesToWrite < 0) maxNumBytesToWrite = availableData; - if (blockToUse != nullptr) - preallocate (blockToUse->getSize() + (size_t) maxNumBytesToWrite); + preallocate (blockToUse.getSize() + (size_t) maxNumBytesToWrite); } return OutputStream::writeFromInputStream (source, maxNumBytesToWrite); diff --git a/source/modules/water/streams/MemoryOutputStream.h b/source/modules/water/streams/MemoryOutputStream.h index 11d644bf5..812372fba 100644 --- a/source/modules/water/streams/MemoryOutputStream.h +++ b/source/modules/water/streams/MemoryOutputStream.h @@ -62,13 +62,6 @@ public: MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, bool appendToExistingBlockContent); - /** Creates a MemoryOutputStream that will write into a user-supplied, fixed-size - block of memory. - When using this mode, the stream will write directly into this memory area until - it's full, at which point write operations will fail. - */ - MemoryOutputStream (void* destBuffer, size_t destBufferSize); - /** Destructor. This will free any data that was written to it. */ @@ -80,6 +73,11 @@ public: */ const void* getData() const noexcept; + /** Returns a pointer to the data that has been written to the stream and releases the buffer pointer. + @see getDataSize + */ + void* getDataAndRelease() noexcept; + /** Returns the number of bytes of data that have been written to the stream. @see getData */ @@ -122,10 +120,9 @@ public: private: //============================================================================== - MemoryBlock* const blockToUse; MemoryBlock internalBlock; - void* externalData; - size_t position, size, availableSize; + MemoryBlock& blockToUse; + size_t position, size; void trimExternalBlockSize(); char* prepareToWrite (size_t); diff --git a/source/modules/water/streams/OutputStream.h b/source/modules/water/streams/OutputStream.h index b8a0e963d..0a81aa0ce 100644 --- a/source/modules/water/streams/OutputStream.h +++ b/source/modules/water/streams/OutputStream.h @@ -27,6 +27,7 @@ #define WATER_OUTPUTSTREAM_H_INCLUDED #include "../water.h" +#include "../text/String.h" namespace water { From dc6fdacf68fd8b1b0155050cf85ed67b091713f2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 01:40:34 +0100 Subject: [PATCH 10/12] 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: From 01db5f4b7e7ece89b31dd068d79d668cd7f41da3 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 02:02:12 +0100 Subject: [PATCH 11/12] Update LV2 UI parameter values after embedding Signed-off-by: falkTX --- source/backend/plugin/CarlaPluginLV2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index d3bf825fd..2add93542 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -2049,6 +2049,8 @@ public: fUI.handle = fUI.descriptor->instantiate(fUI.descriptor, fRdfDescriptor->URI, fUI.rdfDescriptor->Bundle, carla_lv2_ui_write_function, this, &fUI.widget, fFeatures); + updateUi(); + return fUI.widget; } #endif From d61f507e726b2939802c146d668ebabd3d887a33 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 03:14:16 +0100 Subject: [PATCH 12/12] Add NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED, for special hosts Signed-off-by: falkTX --- source/backend/engine/CarlaEngineNative.cpp | 12 +++++++++--- source/includes/CarlaNative.h | 3 ++- source/includes/CarlaNative.hpp | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 8ca275a82..04b0c1faf 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -160,6 +160,7 @@ public: kHasMidiOut(withMidiOut), fIsActive(false), fIsRunning(false), + fUsesEmbed(false), fUiServer(this), fLastScaleFactor(1.0f), fLastProjectFolder(), @@ -346,7 +347,7 @@ public: { fParameters[rindex] = valuef; - if (fUiServer.isPipeRunning()) + if (fUsesEmbed || fUiServer.isPipeRunning()) { pHost->ui_parameter_changed(pHost->handle, rindex, valuef); } @@ -1701,6 +1702,9 @@ public: return 0; case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT: return 0; + case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED: + handlePtr->fUsesEmbed = true; + return 0; } return 0; @@ -1766,7 +1770,7 @@ private: const bool kIsPatchbay; // rack if false const bool kHasMidiOut; - bool fIsActive, fIsRunning; + bool fIsActive, fIsRunning, fUsesEmbed; CarlaEngineNativeUI fUiServer; float fParameters[kNumInParams+kNumOutParams]; @@ -2881,7 +2885,9 @@ const char* getJuceApiName(const uint) { return nullptr; } const char* const* getJuceApiDeviceNames(const uint) { return nullptr; } const EngineDriverDeviceInfo* getJuceDeviceInfo(const uint, const char* const) { return nullptr; } bool showJuceDeviceControlPanel(const uint, const char* const) { return false; } -#else +#endif + +#ifdef USING_RTAUDIO CarlaEngine* newRtAudio(const AudioApi) { return nullptr; } uint getRtAudioApiCount() { return 0; } const char* getRtAudioApiName(const uint) { return nullptr; } diff --git a/source/includes/CarlaNative.h b/source/includes/CarlaNative.h index 4d967ddf5..357e236e5 100644 --- a/source/includes/CarlaNative.h +++ b/source/includes/CarlaNative.h @@ -106,7 +106,8 @@ typedef enum { NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED = 4, /** uses ptr */ NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE = 5, /** nothing */ NATIVE_PLUGIN_OPCODE_IDLE = 6, /** nothing */ - NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT = 7 /** uses ptr */ + NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT = 7, /** uses ptr */ + NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED = 8 /** nothing */ } NativePluginDispatcherOpcode; typedef enum { diff --git a/source/includes/CarlaNative.hpp b/source/includes/CarlaNative.hpp index 292678395..f21183a25 100644 --- a/source/includes/CarlaNative.hpp +++ b/source/includes/CarlaNative.hpp @@ -566,6 +566,8 @@ public: CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0); return handlePtr->uiMIDIEvent(static_cast(index), static_cast(ptr)); + case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED: + return 0; } return 0;