From d91b48e908db00d40b63441048e86140dee3da77 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 22 Apr 2020 03:26:10 +0100 Subject: [PATCH] Use JUCE by default on linux if supported; Cleanup config a bit Signed-off-by: falkTX --- Makefile | 22 +++-- source/Makefile.mk | 51 +++++++---- source/backend/CarlaEngine.hpp | 56 ------------- source/backend/CarlaEngineInit.hpp | 84 +++++++++++++++++++ source/backend/CarlaStandalone.cpp | 10 +-- source/backend/Makefile | 16 +++- source/backend/engine/CarlaEngine.cpp | 19 +++-- source/backend/engine/CarlaEngineBridge.cpp | 12 ++- source/backend/engine/CarlaEngineDummy.cpp | 10 ++- source/backend/engine/CarlaEngineJack.cpp | 9 +- source/backend/engine/CarlaEngineJuce.cpp | 27 +++--- source/backend/engine/CarlaEngineNative.cpp | 39 +++++---- source/backend/engine/CarlaEngineRtAudio.cpp | 17 ++-- source/backend/engine/Makefile | 4 +- source/backend/plugin/CarlaPluginJuce.cpp | 9 -- source/backend/plugin/Makefile | 2 + source/bridges-plugin/Makefile | 4 +- source/discovery/Makefile | 13 ++- source/discovery/carla-discovery.cpp | 9 ++ source/modules/AppConfig.h | 12 +-- .../juce_audio_basics/midi/juce_MidiMessage.h | 2 +- source/plugin/Makefile | 4 +- 22 files changed, 270 insertions(+), 161 deletions(-) create mode 100644 source/backend/CarlaEngineInit.hpp diff --git a/Makefile b/Makefile index a6d5764bf..ab8e35f26 100644 --- a/Makefile +++ b/Makefile @@ -59,17 +59,21 @@ endif ifeq ($(USING_JUCE),true) 3RD_LIBS += $(MODULEDIR)/juce_audio_basics.a +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) 3RD_LIBS += $(MODULEDIR)/juce_audio_devices.a +endif 3RD_LIBS += $(MODULEDIR)/juce_audio_processors.a 3RD_LIBS += $(MODULEDIR)/juce_core.a 3RD_LIBS += $(MODULEDIR)/juce_data_structures.a 3RD_LIBS += $(MODULEDIR)/juce_events.a 3RD_LIBS += $(MODULEDIR)/juce_graphics.a 3RD_LIBS += $(MODULEDIR)/juce_gui_basics.a -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) 3RD_LIBS += $(MODULEDIR)/juce_gui_extra.a endif -else +endif + +ifneq ($(USING_JUCE_AUDIO_DEVICES),true) 3RD_LIBS += $(MODULEDIR)/rtaudio.a 3RD_LIBS += $(MODULEDIR)/rtmidi.a endif @@ -261,11 +265,9 @@ LIBS_POSIX32 += $(MODULEDIR)/juce_audio_processors.posix32.a LIBS_POSIX32 += $(MODULEDIR)/juce_data_structures.posix32.a LIBS_POSIX32 += $(MODULEDIR)/juce_core.posix32.a LIBS_POSIX32 += $(MODULEDIR)/juce_events.posix32.a -ifeq ($(MACOS_OR_WIN32),true) LIBS_POSIX32 += $(MODULEDIR)/juce_graphics.posix32.a LIBS_POSIX32 += $(MODULEDIR)/juce_gui_basics.posix32.a -endif -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LIBS_POSIX32 += $(MODULEDIR)/juce_gui_extra.posix32.a endif endif @@ -288,11 +290,9 @@ LIBS_POSIX64 += $(MODULEDIR)/juce_audio_processors.posix64.a LIBS_POSIX64 += $(MODULEDIR)/juce_data_structures.posix64.a LIBS_POSIX64 += $(MODULEDIR)/juce_core.posix64.a LIBS_POSIX64 += $(MODULEDIR)/juce_events.posix64.a -ifeq ($(MACOS_OR_WIN32),true) LIBS_POSIX64 += $(MODULEDIR)/juce_graphics.posix64.a LIBS_POSIX64 += $(MODULEDIR)/juce_gui_basics.posix64.a -endif -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LIBS_POSIX64 += $(MODULEDIR)/juce_gui_extra.posix64.a endif endif @@ -321,6 +321,9 @@ LIBS_WIN32 += $(MODULEDIR)/juce_core.win32.a LIBS_WIN32 += $(MODULEDIR)/juce_events.win32.a LIBS_WIN32 += $(MODULEDIR)/juce_graphics.win32.a LIBS_WIN32 += $(MODULEDIR)/juce_gui_basics.win32.a +ifeq ($(USING_JUCE_GUI_EXTRA),true) +LIBS_WIN32 += $(MODULEDIR)/juce_gui_extra.win32.a +endif endif win32: $(LIBS_WIN32) @@ -347,6 +350,9 @@ LIBS_WIN64 += $(MODULEDIR)/juce_core.win64.a LIBS_WIN64 += $(MODULEDIR)/juce_events.win64.a LIBS_WIN64 += $(MODULEDIR)/juce_graphics.win64.a LIBS_WIN64 += $(MODULEDIR)/juce_gui_basics.win64.a +ifeq ($(USING_JUCE_GUI_EXTRA),true) +LIBS_WIN64 += $(MODULEDIR)/juce_gui_extra.win64.a +endif endif win64: $(LIBS_WIN64) diff --git a/source/Makefile.mk b/source/Makefile.mk index 876dc5c9a..4c74a9b26 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -92,13 +92,6 @@ ifeq ($(MACOS),true) UNIX=true endif -# --------------------------------------------------------------------------------------------------------------------- -# Set USING_JUCE - -ifeq ($(MACOS_OR_WIN32),true) -USING_JUCE=true -endif - # --------------------------------------------------------------------------------------------------------------------- # Set build and link flags @@ -251,12 +244,8 @@ HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \ $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true) HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true) -ifeq ($(JACKBRIDGE_DIRECT),true) -ifeq ($(HAVE_JACK),true) -BASE_FLAGS += -DJACKBRIDGE_DIRECT -else -$(error jackbridge direct mode requested, but jack not available) -endif +ifeq ($(LINUX),true) +HAVE_JUCE_LINUX_DEPS = $(shell $(PKG_CONFIG) --exists x11 xext freetype2 && echo true) endif # --------------------------------------------------------------------------------------------------------------------- @@ -335,9 +324,33 @@ endif endif endif +# --------------------------------------------------------------------------------------------------------------------- +# Set USING_JUCE + +ifeq ($(MACOS_OR_WIN32),true) +USING_JUCE=true +USING_JUCE_AUDIO_DEVICES=true +endif + +ifeq ($(HAVE_JUCE_LINUX_DEPS),true) +USING_JUCE=true +endif + +ifeq ($(LINUX_OR_MACOS),true) +USING_JUCE_GUI_EXTRA=true +endif + # --------------------------------------------------------------------------------------------------------------------- # Set base defines +ifeq ($(JACKBRIDGE_DIRECT),true) +ifeq ($(HAVE_JACK),true) +BASE_FLAGS += -DJACKBRIDGE_DIRECT +else +$(error jackbridge direct mode requested, but jack not available) +endif +endif + ifeq ($(HAVE_DGL),true) BASE_FLAGS += -DHAVE_DGL BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL -DDGL_FILE_BROWSER_DISABLED -DDGL_NO_SHARED_RESOURCES @@ -379,6 +392,14 @@ ifeq ($(USING_JUCE),true) BASE_FLAGS += -DUSING_JUCE endif +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) +BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES +endif + +ifeq ($(USING_JUCE_GUI_EXTRA),true) +BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA +endif + # --------------------------------------------------------------------------------------------------------------------- # Set libs stuff (part 1) @@ -449,7 +470,7 @@ endif # --------------------------------------------------------------------------------------------------------------------- # Set libs stuff (part 2) -ifneq ($(USING_JUCE),true) +ifneq ($(USING_JUCE_AUDIO_DEVICES),true) RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY RTMIDI_FLAGS = @@ -467,7 +488,7 @@ RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libpulse-sim endif endif -endif # USING_JUCE +endif # USING_JUCE_AUDIO_DEVICES ifeq ($(BSD),true) JACKBRIDGE_LIBS = -lpthread -lrt diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 8faa2b18d..c1fdfc279 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -1362,62 +1362,6 @@ protected: // ------------------------------------------------------------------- -public: - /*! - * Native audio APIs. - */ - enum AudioApi { - AUDIO_API_NULL, - // common - AUDIO_API_JACK, - AUDIO_API_OSS, - // linux - AUDIO_API_ALSA, - AUDIO_API_PULSEAUDIO, - // macos - AUDIO_API_COREAUDIO, - // windows - AUDIO_API_ASIO, - AUDIO_API_DIRECTSOUND, - AUDIO_API_WASAPI - }; - - // ------------------------------------------------------------------- - // Engine initializers - - // JACK - static CarlaEngine* newJack(); - -#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH - // Dummy - static CarlaEngine* newDummy(); -#endif - -#ifdef BUILD_BRIDGE - // Bridge - static CarlaEngine* newBridge(const char* audioPoolBaseName, - const char* rtClientBaseName, - const char* nonRtClientBaseName, - const char* nonRtServerBaseName); -#else -# ifdef USING_JUCE - // Juce - static CarlaEngine* newJuce(AudioApi api); - static uint getJuceApiCount(); - static const char* getJuceApiName(uint index); - static const char* const* getJuceApiDeviceNames(uint index); - static const EngineDriverDeviceInfo* getJuceDeviceInfo(uint index, const char* deviceName); - static bool showJuceDeviceControlPanel(uint index, const char* deviceName); -# else - // RtAudio - static CarlaEngine* newRtAudio(AudioApi api); - static uint getRtAudioApiCount(); - static const char* getRtAudioApiName(uint index); - static const char* const* getRtAudioApiDeviceNames(uint index); - static const EngineDriverDeviceInfo* getRtAudioDeviceInfo(uint index, const char* deviceName); -# endif -#endif - CARLA_DECLARE_NON_COPY_CLASS(CarlaEngine) }; diff --git a/source/backend/CarlaEngineInit.hpp b/source/backend/CarlaEngineInit.hpp new file mode 100644 index 000000000..7a9cb28d8 --- /dev/null +++ b/source/backend/CarlaEngineInit.hpp @@ -0,0 +1,84 @@ +/* + * Carla Plugin Host + * Copyright (C) 2011-2020 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the doc/GPL.txt file. + */ + +#ifndef CARLA_ENGINE_INIT_HPP_INCLUDED +#define CARLA_ENGINE_INIT_HPP_INCLUDED + +#include "CarlaEngine.hpp" + +CARLA_BACKEND_START_NAMESPACE + +// ------------------------------------------------------------------- + +/*! + * Native audio APIs. + */ +enum AudioApi { + AUDIO_API_NULL, + // common + AUDIO_API_JACK, + AUDIO_API_OSS, + // linux + AUDIO_API_ALSA, + AUDIO_API_PULSEAUDIO, + // macos + AUDIO_API_COREAUDIO, + // windows + AUDIO_API_ASIO, + AUDIO_API_DIRECTSOUND, + AUDIO_API_WASAPI +}; + +// ------------------------------------------------------------------- +// Engine initializers + +namespace EngineInit { + +// JACK +CarlaEngine* newJack(); + +// Dummy +CarlaEngine* newDummy(); + +// Bridge +CarlaEngine* newBridge(const char* audioPoolBaseName, + const char* rtClientBaseName, + const char* nonRtClientBaseName, + const char* nonRtServerBaseName); + +// Juce +CarlaEngine* newJuce(AudioApi api); +uint getJuceApiCount(); +const char* getJuceApiName(uint index); +const char* const* getJuceApiDeviceNames(uint index); +const EngineDriverDeviceInfo* getJuceDeviceInfo(uint index, const char* deviceName); +bool showJuceDeviceControlPanel(uint index, const char* deviceName); + +// RtAudio +CarlaEngine* newRtAudio(AudioApi api); +uint getRtAudioApiCount(); +const char* getRtAudioApiName(uint index); +const char* const* getRtAudioApiDeviceNames(uint index); +const EngineDriverDeviceInfo* getRtAudioDeviceInfo(uint index, const char* deviceName); + +} + +// ----------------------------------------------------------------------- + +CARLA_BACKEND_END_NAMESPACE + +#endif // CARLA_ENGINE_INIT_HPP_INCLUDED diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 030449a57..3e00e143e 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -21,7 +21,7 @@ #include "CarlaHostImpl.hpp" #include "CarlaMIDI.h" -#include "CarlaEngine.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaPlugin.hpp" #include "CarlaBackendUtils.hpp" @@ -399,10 +399,10 @@ bool carla_engine_init_bridge(CarlaHostHandle handle, CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(handle->isStandalone, "Must be a standalone host handle", false); CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(handle->engine == nullptr, "Engine is already initialized", false); - CarlaScopedPointer engine(CarlaEngine::newBridge(audioBaseName, - rtClientBaseName, - nonRtClientBaseName, - nonRtServerBaseName)); + CarlaScopedPointer engine(CB::EngineInit::newBridge(audioBaseName, + rtClientBaseName, + nonRtClientBaseName, + nonRtServerBaseName)); CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(engine != nullptr, "The selected audio driver is not available", false); diff --git a/source/backend/Makefile b/source/backend/Makefile index 9fc142eec..142b1c2fa 100644 --- a/source/backend/Makefile +++ b/source/backend/Makefile @@ -39,17 +39,21 @@ endif ifeq ($(USING_JUCE),true) STANDALONE_LIBS += $(MODULEDIR)/juce_audio_basics.a +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) STANDALONE_LIBS += $(MODULEDIR)/juce_audio_devices.a +endif STANDALONE_LIBS += $(MODULEDIR)/juce_audio_processors.a STANDALONE_LIBS += $(MODULEDIR)/juce_core.a STANDALONE_LIBS += $(MODULEDIR)/juce_data_structures.a STANDALONE_LIBS += $(MODULEDIR)/juce_events.a STANDALONE_LIBS += $(MODULEDIR)/juce_graphics.a STANDALONE_LIBS += $(MODULEDIR)/juce_gui_basics.a -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) STANDALONE_LIBS += $(MODULEDIR)/juce_gui_extra.a endif -else +endif + +ifneq ($(USING_JUCE_AUDIO_DEVICES),true) STANDALONE_LIBS += $(MODULEDIR)/rtaudio.a STANDALONE_LIBS += $(MODULEDIR)/rtmidi.a endif @@ -70,17 +74,21 @@ STANDALONE_LINK_FLAGS += $(X11_LIBS) ifeq ($(USING_JUCE),true) STANDALONE_LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS) +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) STANDALONE_LINK_FLAGS += $(JUCE_AUDIO_DEVICES_LIBS) +endif STANDALONE_LINK_FLAGS += $(JUCE_AUDIO_PROCESSORS_LIBS) STANDALONE_LINK_FLAGS += $(JUCE_CORE_LIBS) STANDALONE_LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS) STANDALONE_LINK_FLAGS += $(JUCE_EVENTS_LIBS) STANDALONE_LINK_FLAGS += $(JUCE_GRAPHICS_LIBS) STANDALONE_LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) STANDALONE_LINK_FLAGS += $(JUCE_GUI_EXTRA_LIBS) endif -else +endif + +ifneq ($(USING_JUCE_AUDIO_DEVICES),true) STANDALONE_LINK_FLAGS += $(RTAUDIO_LIBS) STANDALONE_LINK_FLAGS += $(RTMIDI_LIBS) endif diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 8157adbc7..1c20cf1e9 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -23,6 +23,7 @@ */ #include "CarlaEngineClient.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include "CarlaPlugin.hpp" @@ -79,6 +80,7 @@ CarlaEngine::~CarlaEngine() uint CarlaEngine::getDriverCount() { carla_debug("CarlaEngine::getDriverCount()"); + using namespace EngineInit; uint count = 0; @@ -86,7 +88,7 @@ uint CarlaEngine::getDriverCount() count += 1; #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES count += getJuceApiCount(); # else count += getRtAudioApiCount(); @@ -99,6 +101,7 @@ uint CarlaEngine::getDriverCount() const char* CarlaEngine::getDriverName(const uint index2) { carla_debug("CarlaEngine::getDriverName(%i)", index2); + using namespace EngineInit; uint index = index2; @@ -106,7 +109,7 @@ const char* CarlaEngine::getDriverName(const uint index2) return "JACK"; #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES if (const uint count = getJuceApiCount()) { if (index < count) @@ -129,6 +132,7 @@ const char* CarlaEngine::getDriverName(const uint index2) const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) { carla_debug("CarlaEngine::getDriverDeviceNames(%i)", index2); + using namespace EngineInit; uint index = index2; @@ -139,7 +143,7 @@ const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) } #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES if (const uint count = getJuceApiCount()) { if (index < count) @@ -162,6 +166,7 @@ const char* const* CarlaEngine::getDriverDeviceNames(const uint index2) const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2, const char* const deviceName) { carla_debug("CarlaEngine::getDriverDeviceInfo(%i, \"%s\")", index2, deviceName); + using namespace EngineInit; uint index = index2; @@ -175,7 +180,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 } #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES if (const uint count = getJuceApiCount()) { if (index < count) @@ -198,6 +203,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 bool CarlaEngine::showDriverDeviceControlPanel(const uint index2, const char* const deviceName) { carla_debug("CarlaEngine::showDriverDeviceControlPanel(%i, \"%s\")", index2, deviceName); + using namespace EngineInit; uint index = index2; @@ -207,7 +213,7 @@ bool CarlaEngine::showDriverDeviceControlPanel(const uint index2, const char* co } #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES if (const uint count = getJuceApiCount()) { if (index < count) @@ -231,6 +237,7 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) { CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', nullptr); carla_debug("CarlaEngine::newDriverByName(\"%s\")", driverName); + using namespace EngineInit; if (std::strcmp(driverName, "JACK") == 0) return newJack(); @@ -241,7 +248,7 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) #endif #ifndef BUILD_BRIDGE -# ifdef USING_JUCE +# ifdef USING_JUCE_AUDIO_DEVICES // ------------------------------------------------------------------- // linux diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index f32fd2cc5..efe0cf9d9 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,6 +20,7 @@ #endif #include "CarlaEngineClient.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaPlugin.hpp" #include "CarlaBackendUtils.hpp" @@ -1513,11 +1514,18 @@ private: // ----------------------------------------------------------------------- -CarlaEngine* CarlaEngine::newBridge(const char* const audioPoolBaseName, const char* const rtClientBaseName, const char* const nonRtClientBaseName, const char* const nonRtServerBaseName) +namespace EngineInit { + +CarlaEngine* newBridge(const char* const audioPoolBaseName, + const char* const rtClientBaseName, + const char* const nonRtClientBaseName, + const char* const nonRtServerBaseName) { return new CarlaEngineBridge(audioPoolBaseName, rtClientBaseName, nonRtClientBaseName, nonRtServerBaseName); } +} + // ----------------------------------------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/CarlaEngineDummy.cpp b/source/backend/engine/CarlaEngineDummy.cpp index cc9b5e44a..c6e17dde4 100644 --- a/source/backend/engine/CarlaEngineDummy.cpp +++ b/source/backend/engine/CarlaEngineDummy.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,6 +16,7 @@ */ #include "CarlaEngineGraph.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include @@ -279,11 +280,16 @@ private: // ----------------------------------------- -CarlaEngine* CarlaEngine::newDummy() +namespace EngineInit { + +CarlaEngine* newDummy() { + carla_debug("EngineInit::newDummy()"); return new CarlaEngineDummy(); } +} + // ----------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 73cb9344f..a492a1527 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -16,6 +16,7 @@ */ #include "CarlaEngineClient.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include "CarlaPlugin.hpp" @@ -3537,12 +3538,16 @@ private: // ----------------------------------------------------------------------- -CarlaEngine* CarlaEngine::newJack() +namespace EngineInit { + +CarlaEngine* newJack() { - carla_debug("CarlaEngine::newJack()"); + carla_debug("EngineInit::newJack()"); return new CarlaEngineJack(); } +} + // ----------------------------------------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/CarlaEngineJuce.cpp b/source/backend/engine/CarlaEngineJuce.cpp index 30fe7d1b5..76a4d1b6c 100644 --- a/source/backend/engine/CarlaEngineJuce.cpp +++ b/source/backend/engine/CarlaEngineJuce.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,6 +16,7 @@ */ #include "CarlaEngineGraph.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include "CarlaBackendUtils.hpp" #include "CarlaStringList.hpp" @@ -24,17 +25,9 @@ #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wcast-qual" -# pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wdouble-promotion" # pragma GCC diagnostic ignored "-Weffc++" # pragma GCC diagnostic ignored "-Wfloat-equal" -# pragma GCC diagnostic ignored "-Wsign-conversion" -# pragma GCC diagnostic ignored "-Wundef" -# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" -# if __GNUC__ > 7 -# pragma GCC diagnostic ignored "-Wclass-memaccess" -# endif #endif #include "AppConfig.h" @@ -903,7 +896,9 @@ private: // ----------------------------------------- -CarlaEngine* CarlaEngine::newJuce(const AudioApi api) +namespace EngineInit { + +CarlaEngine* newJuce(const AudioApi api) { initJuceDevicesIfNeeded(); @@ -956,14 +951,14 @@ CarlaEngine* CarlaEngine::newJuce(const AudioApi api) return new CarlaEngineJuce(deviceType); } -uint CarlaEngine::getJuceApiCount() +uint getJuceApiCount() { initJuceDevicesIfNeeded(); return static_cast(gDeviceTypes.size()); } -const char* CarlaEngine::getJuceApiName(const uint uindex) +const char* getJuceApiName(const uint uindex) { initJuceDevicesIfNeeded(); @@ -977,7 +972,7 @@ const char* CarlaEngine::getJuceApiName(const uint uindex) return deviceType->getTypeName().toRawUTF8(); } -const char* const* CarlaEngine::getJuceApiDeviceNames(const uint uindex) +const char* const* getJuceApiDeviceNames(const uint uindex) { initJuceDevicesIfNeeded(); @@ -1006,7 +1001,7 @@ const char* const* CarlaEngine::getJuceApiDeviceNames(const uint uindex) return gDeviceNames; } -const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const uint uindex, const char* const deviceName) +const EngineDriverDeviceInfo* getJuceDeviceInfo(const uint uindex, const char* const deviceName) { initJuceDevicesIfNeeded(); @@ -1082,7 +1077,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const uint uindex, return &devInfo; } -bool CarlaEngine::showJuceDeviceControlPanel(const uint uindex, const char* const deviceName) +bool showJuceDeviceControlPanel(const uint uindex, const char* const deviceName) { const int index(static_cast(uindex)); @@ -1099,6 +1094,8 @@ bool CarlaEngine::showJuceDeviceControlPanel(const uint uindex, const char* cons return device->showControlPanel(); } +} + // ----------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 8238b3b6f..4d7afa48c 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,6 +21,7 @@ # error This file should not be compiled if building alternative-arch bridges #endif +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include "CarlaPlugin.hpp" @@ -2720,22 +2721,26 @@ const NativePluginDescriptor* carla_get_native_patchbay_cv_plugin() CARLA_BACKEND_START_NAMESPACE -CarlaEngine* CarlaEngine::newJack() { return nullptr; } - -# ifdef USING_JUCE -CarlaEngine* CarlaEngine::newJuce(const AudioApi) { return nullptr; } -uint CarlaEngine::getJuceApiCount() { return 0; } -const char* CarlaEngine::getJuceApiName(const uint) { return nullptr; } -const char* const* CarlaEngine::getJuceApiDeviceNames(const uint) { return nullptr; } -const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const uint, const char* const) { return nullptr; } -bool CarlaEngine::showJuceDeviceControlPanel(const uint, const char* const) { return false; } -# else -CarlaEngine* CarlaEngine::newRtAudio(const AudioApi) { return nullptr; } -uint CarlaEngine::getRtAudioApiCount() { return 0; } -const char* CarlaEngine::getRtAudioApiName(const uint) { return nullptr; } -const char* const* CarlaEngine::getRtAudioApiDeviceNames(const uint) { return nullptr; } -const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint, const char* const) { return nullptr; } -# endif +namespace EngineInit { + +CarlaEngine* newJack() { return nullptr; } + +#ifdef USING_JUCE_AUDIO_DEVICES +CarlaEngine* newJuce(const AudioApi) { return nullptr; } +uint getJuceApiCount() { return 0; } +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 +CarlaEngine* newRtAudio(const AudioApi) { return nullptr; } +uint getRtAudioApiCount() { return 0; } +const char* getRtAudioApiName(const uint) { return nullptr; } +const char* const* getRtAudioApiDeviceNames(const uint) { return nullptr; } +const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const uint, const char* const) { return nullptr; } +#endif + +} CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/CarlaEngineRtAudio.cpp b/source/backend/engine/CarlaEngineRtAudio.cpp index c7f36dd8b..94a75e36b 100644 --- a/source/backend/engine/CarlaEngineRtAudio.cpp +++ b/source/backend/engine/CarlaEngineRtAudio.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,6 +16,7 @@ */ #include "CarlaEngineGraph.hpp" +#include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" #include "CarlaBackendUtils.hpp" #include "CarlaMathUtils.hpp" @@ -1134,7 +1135,9 @@ private: // ----------------------------------------- -CarlaEngine* CarlaEngine::newRtAudio(const AudioApi api) +namespace EngineInit { + +CarlaEngine* newRtAudio(const AudioApi api) { initRtAudioAPIsIfNeeded(); @@ -1174,14 +1177,14 @@ CarlaEngine* CarlaEngine::newRtAudio(const AudioApi api) return new CarlaEngineRtAudio(rtApi); } -uint CarlaEngine::getRtAudioApiCount() +uint getRtAudioApiCount() { initRtAudioAPIsIfNeeded(); return static_cast(gRtAudioApis.size()); } -const char* CarlaEngine::getRtAudioApiName(const uint index) +const char* getRtAudioApiName(const uint index) { initRtAudioAPIsIfNeeded(); @@ -1190,7 +1193,7 @@ const char* CarlaEngine::getRtAudioApiName(const uint index) return CarlaBackend::getRtAudioApiName(gRtAudioApis[index]); } -const char* const* CarlaEngine::getRtAudioApiDeviceNames(const uint index) +const char* const* getRtAudioApiDeviceNames(const uint index) { initRtAudioAPIsIfNeeded(); @@ -1223,7 +1226,7 @@ const char* const* CarlaEngine::getRtAudioApiDeviceNames(const uint index) return gDeviceNames; } -const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint index, const char* const deviceName) +const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const uint index, const char* const deviceName) { initRtAudioAPIsIfNeeded(); @@ -1316,6 +1319,8 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const uint index return &devInfo; } +} + // ----------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/engine/Makefile b/source/backend/engine/Makefile index 413454124..00c3ffb1b 100644 --- a/source/backend/engine/Makefile +++ b/source/backend/engine/Makefile @@ -9,7 +9,7 @@ include ../Makefile.mk # Workaround GCC bug ifeq ($(TESTBUILD),true) -ifeq ($(USING_JUCE),true) +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) BUILD_CXX_FLAGS += -Wno-undef endif endif @@ -37,7 +37,7 @@ OBJSa = $(OBJS) \ $(OBJDIR)/CarlaEngineJack.cpp.o \ $(OBJDIR)/CarlaEngineNative.cpp.o -ifeq ($(USING_JUCE),true) +ifeq ($(USING_JUCE_AUDIO_DEVICES),true) OBJSa += \ $(OBJDIR)/CarlaEngineJuce.cpp.o else diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index 99426b2ec..f0739e3d4 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -26,18 +26,9 @@ #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) # pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wcast-qual" -# pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wdouble-promotion" # pragma GCC diagnostic ignored "-Weffc++" # pragma GCC diagnostic ignored "-Wfloat-equal" -# pragma GCC diagnostic ignored "-Woverloaded-virtual" -# pragma GCC diagnostic ignored "-Wsign-conversion" -# pragma GCC diagnostic ignored "-Wundef" -# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" -# if __GNUC__ > 7 -# pragma GCC diagnostic ignored "-Wclass-memaccess" -# endif #endif #define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1 diff --git a/source/backend/plugin/Makefile b/source/backend/plugin/Makefile index 8c147ef4b..b576b7fef 100644 --- a/source/backend/plugin/Makefile +++ b/source/backend/plugin/Makefile @@ -11,6 +11,8 @@ include ../Makefile.mk ifeq ($(TESTBUILD),true) ifeq ($(USING_JUCE),true) BUILD_CXX_FLAGS += -Wno-undef +# FIXME +BUILD_CXX_FLAGS += -Wno-deprecated-declarations endif endif diff --git a/source/bridges-plugin/Makefile b/source/bridges-plugin/Makefile index 6e9e9966f..a5f73a6b9 100644 --- a/source/bridges-plugin/Makefile +++ b/source/bridges-plugin/Makefile @@ -12,6 +12,8 @@ include $(CWD)/Makefile.mk ifeq ($(TESTBUILD),true) ifeq ($(USING_JUCE),true) BUILD_CXX_FLAGS += -Wno-undef +# FIXME +BUILD_CXX_FLAGS += -Wno-deprecated-declarations endif endif @@ -125,7 +127,7 @@ LIBS_win32 += $(MODULEDIR)/juce_gui_basics.win32.a LIBS_win64 += $(MODULEDIR)/juce_gui_basics.win64.a LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LIBS_native += $(MODULEDIR)/juce_gui_extra.a LIBS_posix32 += $(MODULEDIR)/juce_gui_extra.posix32.a LIBS_posix64 += $(MODULEDIR)/juce_gui_extra.posix64.a diff --git a/source/discovery/Makefile b/source/discovery/Makefile index dd205495b..e3b4a1760 100644 --- a/source/discovery/Makefile +++ b/source/discovery/Makefile @@ -14,6 +14,13 @@ CWD=.. MODULENAME=carla-discovery include $(CWD)/Makefile.mk +# Workaround GCC bug +ifeq ($(TESTBUILD),true) +ifeq ($(USING_JUCE),true) +BUILD_CXX_FLAGS += -Wno-undef +endif +endif + # --------------------------------------------------------------------------------------------------------------------- BINDIR := $(CWD)/../bin @@ -117,12 +124,14 @@ LIBS_win32 += $(MODULEDIR)/juce_gui_basics.win32.a LIBS_win64 += $(MODULEDIR)/juce_gui_basics.win64.a LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LIBS_native += $(MODULEDIR)/juce_gui_extra.a LIBS_posix32 += $(MODULEDIR)/juce_gui_extra.posix32.a LIBS_posix64 += $(MODULEDIR)/juce_gui_extra.posix64.a +LIBS_win32 += $(MODULEDIR)/juce_gui_extra.win32.a +LIBS_win64 += $(MODULEDIR)/juce_gui_extra.win64.a LINK_FLAGS += $(JUCE_GUI_EXTRA_LIBS) -endif # MACOS +endif # USING_JUCE_GUI_EXTRA endif # USING_JUCE # --------------------------------------------------------------------------------------------------------------------- diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index a83f72ee0..10afeee99 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -26,11 +26,20 @@ #endif #ifdef USING_JUCE +# if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdouble-promotion" +# pragma GCC diagnostic ignored "-Weffc++" +# pragma GCC diagnostic ignored "-Wfloat-equal" +# endif # include "AppConfig.h" # include "juce_audio_processors/juce_audio_processors.h" # if JUCE_PLUGINHOST_VST # define USING_JUCE_FOR_VST2 # endif +# if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +# endif #endif #include "CarlaLadspaUtils.hpp" diff --git a/source/modules/AppConfig.h b/source/modules/AppConfig.h index 046c59dfe..8b752a754 100644 --- a/source/modules/AppConfig.h +++ b/source/modules/AppConfig.h @@ -59,16 +59,16 @@ #define JUCE_MODULE_AVAILABLE_juce_video 0 // conditional -#ifdef APPCONFIG_OS_MAC -# define JUCE_MODULE_AVAILABLE_juce_gui_extra 1 +#if defined(USING_JUCE_AUDIO_DEVICES) && !defined(BUILD_BRIDGE) +# define JUCE_MODULE_AVAILABLE_juce_audio_devices 1 #else -# define JUCE_MODULE_AVAILABLE_juce_gui_extra 0 +# define JUCE_MODULE_AVAILABLE_juce_audio_devices 0 #endif -#ifndef BUILD_BRIDGE -# define JUCE_MODULE_AVAILABLE_juce_audio_devices 1 +#ifdef USING_JUCE_GUI_EXTRA +# define JUCE_MODULE_AVAILABLE_juce_gui_extra 1 #else -# define JUCE_MODULE_AVAILABLE_juce_audio_devices 0 +# define JUCE_MODULE_AVAILABLE_juce_gui_extra 0 #endif // misc diff --git a/source/modules/juce_audio_basics/midi/juce_MidiMessage.h b/source/modules/juce_audio_basics/midi/juce_MidiMessage.h index 5628c3ae9..207bb9a0b 100644 --- a/source/modules/juce_audio_basics/midi/juce_MidiMessage.h +++ b/source/modules/juce_audio_basics/midi/juce_MidiMessage.h @@ -945,7 +945,7 @@ private: #endif inline bool isHeapAllocated() const noexcept { return size > (int) sizeof (packedData); } - inline uint8* getData() const noexcept { return isHeapAllocated() ? packedData.allocatedData : (uint8*) packedData.asBytes; } + inline uint8* getData() const noexcept { return isHeapAllocated() ? packedData.allocatedData : const_cast(packedData.asBytes); } uint8* allocateSpace (int); }; diff --git a/source/plugin/Makefile b/source/plugin/Makefile index d82ff9349..7d56a4f0a 100644 --- a/source/plugin/Makefile +++ b/source/plugin/Makefile @@ -81,7 +81,7 @@ LIBS += $(MODULEDIR)/juce_data_structures.a LIBS += $(MODULEDIR)/juce_events.a LIBS += $(MODULEDIR)/juce_graphics.a LIBS += $(MODULEDIR)/juce_gui_basics.a -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LIBS += $(MODULEDIR)/juce_gui_extra.a endif endif @@ -110,7 +110,7 @@ LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS) LINK_FLAGS += $(JUCE_EVENTS_LIBS) LINK_FLAGS += $(JUCE_GRAPHICS_LIBS) LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS) -ifeq ($(LINUX_OR_MACOS),true) +ifeq ($(USING_JUCE_GUI_EXTRA),true) LINK_FLAGS += $(JUCE_GUI_EXTRA_LIBS) endif endif