Browse Source

Merge branch 'falkTX:main' into explicit-casting

pull/1492/head
mkohlhaas GitHub 4 years ago
parent
commit
035efecb3c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 763 additions and 599 deletions
  1. +7
    -1
      Makefile
  2. +566
    -0
      source/Makefile.deps.mk
  3. +6
    -503
      source/Makefile.mk
  4. +2
    -0
      source/backend/CarlaEngine.hpp
  5. +7
    -0
      source/backend/CarlaHost.h
  6. +12
    -0
      source/backend/CarlaStandalone.cpp
  7. +4
    -2
      source/backend/Makefile
  8. +22
    -6
      source/backend/engine/CarlaEngine.cpp
  9. +9
    -3
      source/backend/engine/CarlaEngineNative.cpp
  10. +3
    -1
      source/backend/engine/Makefile
  11. +2
    -0
      source/backend/plugin/CarlaPluginLV2.cpp
  12. +12
    -4
      source/backend/utils/CachedPlugins.cpp
  13. +2
    -1
      source/includes/CarlaNative.h
  14. +2
    -0
      source/includes/CarlaNative.hpp
  15. +8
    -0
      source/jackbridge/Makefile
  16. +1
    -2
      source/modules/water/containers/Array.h
  17. +8
    -0
      source/modules/water/memory/HeapBlock.h
  18. +7
    -0
      source/modules/water/memory/MemoryBlock.cpp
  19. +4
    -0
      source/modules/water/memory/MemoryBlock.h
  20. +26
    -42
      source/modules/water/streams/MemoryOutputStream.cpp
  21. +7
    -10
      source/modules/water/streams/MemoryOutputStream.h
  22. +1
    -0
      source/modules/water/streams/OutputStream.h
  23. +45
    -24
      source/utils/CarlaPluginUI.cpp

+ 7
- 1
Makefile View File

@@ -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

@@ -78,7 +84,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


+ 566
- 0
source/Makefile.deps.mk View File

@@ -0,0 +1,566 @@
#!/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 <magic.h>' | $(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

# ---------------------------------------------------------------------------------------------------------------------

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)

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)

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)
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

# ---------------------------------------------------------------------------------------------------------------------

+ 6
- 503
source/Makefile.mk View File

@@ -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 <magic.h>' | $(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,14 @@ 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)
ifeq ($(USING_RTAUDIO),true)
BASE_FLAGS += -DUSING_RTAUDIO
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)
ifeq ($(STATIC_PLUGIN_TARGET),true)
BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
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



+ 2
- 0
source/backend/CarlaEngine.hpp View File

@@ -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



+ 7
- 0
source/backend/CarlaHost.h View File

@@ -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


+ 12
- 0
source/backend/CarlaStandalone.cpp View File

@@ -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->getLatencyInFrames();

return 0;
}

// --------------------------------------------------------------------------------------------------------------------

const float* carla_get_peak_values(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, nullptr);


+ 4
- 2
source/backend/Makefile View File

@@ -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

# ---------------------------------------------------------------------------------------------------------------------

@@ -58,7 +60,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 +95,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


+ 22
- 6
source/backend/engine/CarlaEngine.cpp View File

@@ -95,13 +95,16 @@ 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
count += getJuceApiCount();
# else
# endif
# ifdef USING_RTAUDIO
count += getRtAudioApiCount();
# endif
#endif
@@ -114,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
@@ -127,7 +132,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)
@@ -145,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)
@@ -152,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
@@ -161,7 +169,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)
@@ -179,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)
@@ -189,6 +199,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2
devInfo.sampleRates = nullptr;
return &devInfo;
}
#endif

#ifndef BUILD_BRIDGE
# ifdef USING_JUCE_AUDIO_DEVICES
@@ -198,7 +209,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)
@@ -216,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
@@ -231,7 +245,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 +296,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



+ 9
- 3
source/backend/engine/CarlaEngineNative.cpp View File

@@ -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; }


+ 3
- 1
source/backend/engine/Makefile View File

@@ -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


+ 2
- 0
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -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


+ 12
- 4
source/backend/utils/CachedPlugins.cpp View File

@@ -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<LilvNodes*>(licenseNodes.me));


+ 2
- 1
source/includes/CarlaNative.h View File

@@ -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 {


+ 2
- 0
source/includes/CarlaNative.hpp View File

@@ -566,6 +566,8 @@ public:
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0);
return handlePtr->uiMIDIEvent(static_cast<uint8_t>(index),
static_cast<uint8_t*>(ptr));
case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED:
return 0;
}

return 0;


+ 8
- 0
source/jackbridge/Makefile View File

@@ -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
@@ -70,6 +71,7 @@ OBJS_win32e = $(OBJDIR)/JackBridgeExport.cpp.win32e.o
# ---------------------------------------------------------------------------------------------------------------------

all: $(MODULEDIR)/$(MODULENAME).a
min: $(MODULEDIR)/$(MODULENAME).min.a

ifeq ($(WIN32),true)
posix32:
@@ -112,6 +114,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"


+ 1
- 2
source/modules/water/containers/Array.h View File

@@ -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<size_t>(numberToShift));
e[numUsed].~ElementType();
minimiseStorageAfterRemoval();
}


+ 8
- 0
source/modules/water/memory/HeapBlock.h View File

@@ -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;


+ 7
- 0
source/modules/water/memory/MemoryBlock.cpp View File

@@ -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
{


+ 4
- 0
source/modules/water/memory/MemoryBlock.h View File

@@ -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;


+ 26
- 42
source/modules/water/streams/MemoryOutputStream.cpp View File

@@ -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<char*> (blockToUse->getData());
}
else
{
if (storageNeeded > availableSize)
return nullptr;
data = static_cast<char*> (externalData);
}
if (storageNeeded >= blockToUse.getSize())
blockToUse.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u);
char* const data = static_cast<char*> (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<char*> (blockToUse.getData()) [size] = 0;
if (blockToUse->getSize() > size)
static_cast<char*> (blockToUse->getData()) [size] = 0;
return blockToUse.getData();
}
void* MemoryOutputStream::getDataAndRelease() noexcept
{
if (blockToUse.getSize() > size)
static_cast<char*> (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);


+ 7
- 10
source/modules/water/streams/MemoryOutputStream.h View File

@@ -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);


+ 1
- 0
source/modules/water/streams/OutputStream.h View File

@@ -27,6 +27,7 @@
#define WATER_OUTPUTSTREAM_H_INCLUDED
#include "../water.h"
#include "../text/String.h"
namespace water {


+ 45
- 24
source/utils/CarlaPluginUI.cpp View File

@@ -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<uint>(width), static_cast<uint>(height), false);
}

if (width > 1 && height > 1)
setSize(static_cast<uint>(width), static_cast<uint>(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)


Loading…
Cancel
Save