| @@ -358,6 +358,10 @@ X11_FLAGS = $(shell pkg-config --cflags x11) | |||
| X11_LIBS = $(shell pkg-config --libs x11) | |||
| endif | |||
| ifeq ($(HAVE_LIBMAGIC),true) | |||
| MAGIC_LIBS += -lmagic | |||
| endif | |||
| # -------------------------------------------------------------- | |||
| # Set libs stuff (part 2) | |||
| @@ -476,6 +480,8 @@ ifeq ($(WIN32),true) | |||
| LIB_EXT = .dll | |||
| endif | |||
| BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\" | |||
| # -------------------------------------------------------------- | |||
| # Set static libs start & end | |||
| @@ -635,6 +635,7 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| // Plugin processing | |||
| protected: | |||
| /*! | |||
| * Plugin activate call. | |||
| */ | |||
| @@ -645,6 +646,7 @@ public: | |||
| */ | |||
| virtual void deactivate() noexcept; | |||
| public: | |||
| /*! | |||
| * Plugin process call. | |||
| */ | |||
| @@ -100,7 +100,7 @@ STANDALONE_LINK_FLAGS += $(LIBLO_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_LIBMAGIC),true) | |||
| STANDALONE_LINK_FLAGS += -lmagic | |||
| STANDALONE_LINK_FLAGS += $(MAGIC_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_FLUIDSYNTH),true) | |||
| @@ -382,19 +382,17 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| }; | |||
| CarlaPlugin* plugin = nullptr; | |||
| #ifndef BUILD_BRIDGE | |||
| CarlaString bridgeBinary(pData->options.binaryDir); | |||
| if (bridgeBinary.isNotEmpty()) | |||
| { | |||
| if (btype == BINARY_NATIVE) | |||
| { | |||
| # ifdef CARLA_OS_WIN | |||
| #ifdef CARLA_OS_WIN | |||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native.exe"; | |||
| # else | |||
| #else | |||
| bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native"; | |||
| # endif | |||
| #endif | |||
| } | |||
| else | |||
| { | |||
| @@ -425,7 +423,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| // Prefer bridges for some specific plugins | |||
| bool preferBridges = pData->options.preferPluginBridges; | |||
| # ifdef CARLA_OS_LINUX | |||
| #ifndef BUILD_BRIDGE | |||
| if (! preferBridges) | |||
| { | |||
| if (ptype == PLUGIN_LV2 && label != nullptr) | |||
| @@ -437,7 +435,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| preferBridges = true; | |||
| } | |||
| } | |||
| #if 0 | |||
| # if 0 | |||
| else if (ptype == PLUGIN_VST2) | |||
| { | |||
| /* | |||
| @@ -507,7 +505,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| else if (uniqueId == 1397573722 && std::strstr(filename, "/ZebraHZ.") != nullptr) | |||
| preferBridges = true; | |||
| } | |||
| #endif | |||
| # endif | |||
| // FIXME: linuxsampler inside carla-rack/patchbay plugin has some issues (only last kit makes noise) | |||
| else if (getType() == kEngineTypePlugin && (ptype == PLUGIN_GIG || ptype == PLUGIN_SFZ)) | |||
| { | |||
| @@ -524,7 +522,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| preferBridges = true; | |||
| } | |||
| } | |||
| # endif | |||
| #endif // ! BUILD_BRIDGE | |||
| if (ptype != PLUGIN_INTERNAL && (btype != BINARY_NATIVE || (preferBridges && bridgeBinary.isNotEmpty()))) | |||
| { | |||
| @@ -539,7 +537,6 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| } | |||
| } | |||
| else | |||
| #endif // ! BUILD_BRIDGE | |||
| { | |||
| bool use16Outs; | |||
| setLastError("Invalid or unsupported plugin type"); | |||
| @@ -623,6 +620,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| case PLUGIN_JACK: | |||
| #ifndef BUILD_BRIDGE | |||
| plugin = CarlaPlugin::newJackApp(initializer); | |||
| #else | |||
| setLastError("Do not use jack applications as bridges, too much experimental stuff together!"); | |||
| #endif | |||
| break; | |||
| } | |||
| @@ -633,6 +632,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| plugin->reload(); | |||
| #ifndef BUILD_BRIDGE | |||
| bool canRun = true; | |||
| /**/ if (pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) | |||
| @@ -668,11 +668,13 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
| return false; | |||
| } | |||
| #if defined(HAVE_LIBLO) && ! defined(BUILD_BRIDGE) | |||
| # ifdef HAVE_LIBLO | |||
| plugin->registerToOscClient(); | |||
| # endif | |||
| #endif | |||
| EnginePluginData& pluginData(pData->plugins[id]); | |||
| carla_stdout("stored plugin ptr %p", plugin); | |||
| pluginData.plugin = plugin; | |||
| pluginData.insPeak[0] = 0.0f; | |||
| pluginData.insPeak[1] = 0.0f; | |||
| @@ -2196,7 +2198,11 @@ bool CarlaEngine::loadProjectInternal(juce::XmlDocument& xmlDoc) | |||
| if (addPlugin(getBinaryTypeFromFile(stateSave.binary), ptype, stateSave.binary, | |||
| stateSave.name, stateSave.label, stateSave.uniqueId, extraStuff, stateSave.options)) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| const uint pluginId = pData->curPluginCount; | |||
| #else | |||
| const uint pluginId = 0; | |||
| #endif | |||
| if (CarlaPlugin* const plugin = pData->plugins[pluginId].plugin) | |||
| { | |||
| @@ -2205,11 +2211,10 @@ bool CarlaEngine::loadProjectInternal(juce::XmlDocument& xmlDoc) | |||
| if (pData->aboutToClose) | |||
| return true; | |||
| #ifndef BUILD_BRIDGE | |||
| // deactivate bridge client-side ping check, since some plugins block during load | |||
| if ((plugin->getHints() & PLUGIN_IS_BRIDGE) != 0 && ! isPreset) | |||
| plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "__CarlaPingOnOff__", "false", false); | |||
| #endif | |||
| plugin->loadStateSave(stateSave); | |||
| /* NOTE: The following code is the same as the end of addPlugin(). | |||
| @@ -2218,10 +2223,11 @@ bool CarlaEngine::loadProjectInternal(juce::XmlDocument& xmlDoc) | |||
| */ | |||
| #ifdef BUILD_BRIDGE | |||
| plugin->setActive(true, true, false); | |||
| #else | |||
| ++pData->curPluginCount; | |||
| #endif | |||
| plugin->setEnabled(true); | |||
| ++pData->curPluginCount; | |||
| plugin->setEnabled(true); | |||
| callback(ENGINE_CALLBACK_PLUGIN_ADDED, pluginId, 0, 0, 0.0f, plugin->getName()); | |||
| #ifndef BUILD_BRIDGE | |||
| @@ -970,12 +970,12 @@ bool CarlaPlugin::exportAsLV2(const char* const lv2path) | |||
| manifestStream << "\n"; | |||
| manifestStream << "<" << symbol.buffer() << ".ttl>\n"; | |||
| manifestStream << " a lv2:Plugin ;\n"; | |||
| manifestStream << " lv2:binary <" << symbol.buffer() << ".so> ;\n"; | |||
| manifestStream << " lv2:binary <" << symbol.buffer() << CARLA_LIB_EXT "> ;\n"; | |||
| manifestStream << " rdfs:seeAlso <" << symbol.buffer() << ".ttl> .\n"; | |||
| manifestStream << "\n"; | |||
| manifestStream << "<ext-ui>\n"; | |||
| manifestStream << " a <http://kxstudio.sf.net/ns/lv2ext/external-ui#Widget> ;\n"; | |||
| manifestStream << " ui:binary <" << symbol.buffer() << ".so> ;\n"; | |||
| manifestStream << " ui:binary <" << symbol.buffer() << CARLA_LIB_EXT "> ;\n"; | |||
| manifestStream << " lv2:extensionData <http://lv2plug.in/ns/extensions/ui#idleInterface> ,\n"; | |||
| manifestStream << " <http://lv2plug.in/ns/extensions/ui#showInterface> ;\n"; | |||
| manifestStream << " lv2:requiredFeature <http://lv2plug.in/ns/ext/instance-access> .\n"; | |||
| @@ -1123,9 +1123,9 @@ bool CarlaPlugin::exportAsLV2(const char* const lv2path) | |||
| } | |||
| } | |||
| const CarlaString binaryFilename(bundlepath + CARLA_OS_SEP_STR + symbol + ".so"); | |||
| const CarlaString binaryFilename(bundlepath + CARLA_OS_SEP_STR + symbol + CARLA_LIB_EXT); | |||
| const File binaryFileSource(File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("carla-bridge-lv2.so")); | |||
| const File binaryFileSource(File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("carla-bridge-lv2" CARLA_LIB_EXT)); | |||
| const File binaryFileTarget(binaryFilename.buffer()); | |||
| if (! binaryFileSource.createSymbolicLink(binaryFileTarget, true)) | |||
| @@ -15,10 +15,6 @@ | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #ifdef BUILD_BRIDGE | |||
| # error This file should be used under bridge mode | |||
| #endif | |||
| #include "CarlaPluginInternal.hpp" | |||
| #include "CarlaBackendUtils.hpp" | |||
| @@ -2382,4 +2378,8 @@ CARLA_BACKEND_END_NAMESPACE | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| #include "CarlaBridgeUtils.cpp" | |||
| #ifndef BUILD_BRIDGE | |||
| # include "CarlaBridgeUtils.cpp" | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -15,7 +15,9 @@ | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| // #define BUILD_BRIDGE | |||
| #ifndef BUILD_BRIDGE | |||
| # error This file should not be compiled if not building bridge | |||
| #endif | |||
| #include "engine/CarlaEngineInternal.hpp" | |||
| #include "CarlaPlugin.hpp" | |||
| @@ -47,13 +49,16 @@ class CarlaEngineLV2Single : public CarlaEngine, | |||
| public: | |||
| CarlaEngineLV2Single(const uint32_t bufferSize, const double sampleRate, const char* const bundlePath, const LV2_URID_Map* uridMap) | |||
| : fPlugin(nullptr), | |||
| fIsRunning(false), | |||
| fIsActive(false), | |||
| fIsOffline(false) | |||
| { | |||
| run = extui_run; | |||
| show = extui_show; | |||
| hide = extui_hide; | |||
| CARLA_SAFE_ASSERT_RETURN(pData->curPluginCount == 0,) | |||
| CARLA_SAFE_ASSERT_RETURN(pData->plugins[0].plugin == nullptr,); | |||
| // xxxxx | |||
| CarlaString binaryDir(bundlePath); | |||
| binaryDir += CARLA_OS_SEP_STR "bin" CARLA_OS_SEP_STR; | |||
| @@ -102,6 +107,9 @@ public: | |||
| ~CarlaEngineLV2Single() | |||
| { | |||
| if (fPlugin != nullptr && fIsActive) | |||
| fPlugin->setActive(false, false, false); | |||
| close(); | |||
| } | |||
| @@ -120,18 +128,18 @@ public: | |||
| void lv2_activate() | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(! fIsRunning,); | |||
| CARLA_SAFE_ASSERT_RETURN(! fIsActive,); | |||
| fPlugin->activate(); | |||
| fIsRunning = true; | |||
| fPlugin->setActive(true, false, false); | |||
| fIsActive = true; | |||
| } | |||
| void lv2_deactivate() | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(fIsRunning,); | |||
| CARLA_SAFE_ASSERT_RETURN(fIsActive,); | |||
| fIsRunning = false; | |||
| fPlugin->deactivate(); | |||
| fIsActive = false; | |||
| fPlugin->setActive(false, false, false); | |||
| } | |||
| void lv2_run(const uint32_t frames) | |||
| @@ -297,16 +305,9 @@ protected: | |||
| return true; | |||
| } | |||
| bool close() override | |||
| { | |||
| fIsRunning = false; | |||
| CarlaEngine::close(); | |||
| return true; | |||
| } | |||
| bool isRunning() const noexcept override | |||
| { | |||
| return fIsRunning; | |||
| return fIsActive; | |||
| } | |||
| bool isOffline() const noexcept override | |||
| @@ -376,9 +377,9 @@ protected: | |||
| private: | |||
| CarlaPlugin* fPlugin; | |||
| bool fIsRunning; | |||
| // Lv2 host data | |||
| bool fIsActive; | |||
| bool fIsOffline; | |||
| struct Ports { | |||
| @@ -119,7 +119,13 @@ LINK_FLAGS += $(JUCE_GUI_EXTRA_LIBS) | |||
| endif | |||
| endif | |||
| ifeq ($(HAVE_LIBLO),true) | |||
| LINK_FLAGS += $(LIBLO_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_LIBMAGIC),true) | |||
| LINK_FLAGS += $(MAGIC_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_X11),true) | |||
| LINK_FLAGS += $(X11_LIBS) | |||
| @@ -169,6 +175,7 @@ OBJS_native = \ | |||
| $(OBJDIR)/CarlaEngineJack.cpp.o \ | |||
| $(OBJDIR)/CarlaEngineBridge.cpp.o \ | |||
| $(OBJDIR)/CarlaPlugin.cpp.o \ | |||
| $(OBJDIR)/CarlaPluginBridge.cpp.o \ | |||
| $(OBJDIR)/CarlaPluginInternal.cpp.o \ | |||
| $(OBJDIR)/CarlaPluginNative.cpp.o \ | |||
| $(OBJDIR)/CarlaPluginLADSPA.cpp.o \ | |||
| @@ -198,6 +205,7 @@ OBJS_arch = \ | |||
| $(OBJDIR)/CarlaEngineJack.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaEngineBridge.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaPlugin.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaPluginBridge.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaPluginInternal.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaPluginLADSPA.cpp.arch.o \ | |||
| $(OBJDIR)/CarlaPluginDSSI.cpp.arch.o \ | |||
| @@ -248,7 +256,7 @@ $(BINDIR)/$(MODULENAME)-native$(APP_EXT): $(OBJS_native) $(LIBS_native) | |||
| $(BINDIR)/$(MODULENAME)-lv2$(LIB_EXT): $(OBJS_lv2) $(LIBS_native) | |||
| -@mkdir -p $(BINDIR) | |||
| @echo "Linking $(MODULENAME)-lv2$(LIB_EXT)" | |||
| @$(CXX) $(OBJS_lv2) $(LIBS_START) $(LIBS_native) $(LIBS_END) $(LINK_FLAGS) $(NATIVE_LINK_FLAGS) -o $@ | |||
| @$(CXX) $(OBJS_lv2) $(LIBS_START) $(LIBS_native) $(LIBS_END) $(SHARED) $(LINK_FLAGS) $(NATIVE_LINK_FLAGS) -o $@ | |||
| $(BINDIR)/$(MODULENAME)-posix32: $(OBJS_posix32) $(LIBS_posix32) | |||
| -@mkdir -p $(BINDIR) | |||
| @@ -101,7 +101,7 @@ LINK_FLAGS += $(LIBLO_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_LIBMAGIC),true) | |||
| LINK_FLAGS += -lmagic | |||
| LINK_FLAGS += $(MAGIC_LIBS) | |||
| endif | |||
| ifeq ($(HAVE_FLUIDSYNTH),true) | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Carla binary utils | |||
| * Copyright (C) 2014 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2014-2017 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -21,17 +21,15 @@ | |||
| #include "CarlaBackend.h" | |||
| #include "CarlaUtils.hpp" | |||
| #ifndef BUILD_BRIDGE | |||
| # if defined(CARLA_OS_WIN) | |||
| # include "juce_core/juce_core.h" | |||
| # elif defined(HAVE_LIBMAGIC) | |||
| # include <magic.h> | |||
| # endif | |||
| #if defined(CARLA_OS_WIN) | |||
| # include "juce_core/juce_core.h" | |||
| #elif defined(HAVE_LIBMAGIC) | |||
| # include <magic.h> | |||
| #endif | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| #if defined(HAVE_LIBMAGIC) && ! defined(BUILD_BRIDGE) | |||
| #ifdef HAVE_LIBMAGIC | |||
| // ----------------------------------------------------------------------- | |||
| class CarlaMagic | |||
| @@ -76,8 +74,7 @@ BinaryType getBinaryTypeFromFile(const char* const filename) | |||
| if (filename == nullptr || filename[0] == '\0') | |||
| return BINARY_NATIVE; | |||
| #ifndef BUILD_BRIDGE | |||
| # if defined(CARLA_OS_WIN) | |||
| #if defined(CARLA_OS_WIN) | |||
| using juce::File; | |||
| using juce::FileInputStream; | |||
| using juce::ScopedPointer; | |||
| @@ -122,7 +119,7 @@ BinaryType getBinaryTypeFromFile(const char* const filename) | |||
| default: | |||
| return BINARY_NATIVE; | |||
| } | |||
| # elif defined(HAVE_LIBMAGIC) | |||
| #elif defined(HAVE_LIBMAGIC) | |||
| static const CarlaMagic magic; | |||
| const char* const output(magic.getFileDescription(filename)); | |||
| @@ -136,7 +133,6 @@ BinaryType getBinaryTypeFromFile(const char* const filename) | |||
| if (std::strstr(output, "ELF") != nullptr) | |||
| return (std::strstr(output, "x86-64") != nullptr || std::strstr(output, "aarch64") != nullptr) ? BINARY_POSIX64 : BINARY_POSIX32; | |||
| # endif | |||
| #endif | |||
| return BINARY_NATIVE; | |||
| @@ -16,10 +16,7 @@ | |||
| */ | |||
| #include "CarlaBridgeUtils.hpp" | |||
| #ifndef BUILD_BRIDGE | |||
| # include "CarlaShmUtils.hpp" | |||
| #endif | |||
| #include "CarlaShmUtils.hpp" | |||
| // must be last | |||
| #include "jackbridge/JackBridge.hpp" | |||
| @@ -50,7 +47,8 @@ bool jackbridge_shm_map2(void* shm, T*& value) noexcept | |||
| BridgeAudioPool::BridgeAudioPool() noexcept | |||
| : data(nullptr), | |||
| dataSize(0), | |||
| filename() | |||
| filename(), | |||
| isServer(false) | |||
| { | |||
| carla_zeroChars(shm, 64); | |||
| jackbridge_shm_init(shm); | |||
| @@ -66,7 +64,6 @@ BridgeAudioPool::~BridgeAudioPool() noexcept | |||
| bool BridgeAudioPool::initializeServer() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| char tmpFileBase[64]; | |||
| std::sprintf(tmpFileBase, PLUGIN_BRIDGE_NAMEPREFIX_AUDIO_POOL "XXXXXX"); | |||
| @@ -78,17 +75,14 @@ bool BridgeAudioPool::initializeServer() noexcept | |||
| carla_copyStruct(shm1, shm2); | |||
| filename = tmpFileBase; | |||
| isServer = true; | |||
| return true; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| bool BridgeAudioPool::attachClient(const char* const basename) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(basename != nullptr && basename[0] != '\0', false); | |||
| #ifdef BUILD_BRIDGE | |||
| // must be invalid right now | |||
| CARLA_SAFE_ASSERT_RETURN(! jackbridge_shm_is_valid(shm), false); | |||
| @@ -98,9 +92,6 @@ bool BridgeAudioPool::attachClient(const char* const basename) noexcept | |||
| jackbridge_shm_attach(shm, filename); | |||
| return jackbridge_shm_is_valid(shm); | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| void BridgeAudioPool::clear() noexcept | |||
| @@ -115,9 +106,8 @@ void BridgeAudioPool::clear() noexcept | |||
| if (data != nullptr) | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| jackbridge_shm_unmap(shm, data); | |||
| #endif | |||
| if (isServer) | |||
| jackbridge_shm_unmap(shm, data); | |||
| data = nullptr; | |||
| } | |||
| @@ -126,10 +116,10 @@ void BridgeAudioPool::clear() noexcept | |||
| jackbridge_shm_init(shm); | |||
| } | |||
| #ifndef BUILD_BRIDGE | |||
| void BridgeAudioPool::resize(const uint32_t bufferSize, const uint32_t audioPortCount, const uint32_t cvPortCount) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(jackbridge_shm_is_valid(shm),); | |||
| CARLA_SAFE_ASSERT_RETURN(isServer,); | |||
| if (data != nullptr) | |||
| jackbridge_shm_unmap(shm, data); | |||
| @@ -144,14 +134,14 @@ void BridgeAudioPool::resize(const uint32_t bufferSize, const uint32_t audioPort | |||
| std::memset(data, 0, dataSize); | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| BridgeRtClientControl::BridgeRtClientControl() noexcept | |||
| : data(nullptr), | |||
| filename(), | |||
| needsSemDestroy(false) | |||
| needsSemDestroy(false), | |||
| isServer(false) | |||
| { | |||
| carla_zeroChars(shm, 64); | |||
| jackbridge_shm_init(shm); | |||
| @@ -167,7 +157,6 @@ BridgeRtClientControl::~BridgeRtClientControl() noexcept | |||
| bool BridgeRtClientControl::initializeServer() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| char tmpFileBase[64]; | |||
| std::sprintf(tmpFileBase, PLUGIN_BRIDGE_NAMEPREFIX_RT_CLIENT "XXXXXX"); | |||
| @@ -207,18 +196,15 @@ bool BridgeRtClientControl::initializeServer() noexcept | |||
| // NEW | |||
| filename = tmpFileBase; | |||
| isServer = true; | |||
| needsSemDestroy = true; | |||
| return true; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| bool BridgeRtClientControl::attachClient(const char* const basename) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(basename != nullptr && basename[0] != '\0', false); | |||
| #ifdef BUILD_BRIDGE | |||
| // must be invalid right now | |||
| CARLA_SAFE_ASSERT_RETURN(! jackbridge_shm_is_valid(shm), false); | |||
| @@ -228,9 +214,6 @@ bool BridgeRtClientControl::attachClient(const char* const basename) noexcept | |||
| jackbridge_shm_attach(shm, filename); | |||
| return jackbridge_shm_is_valid(shm); | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| void BridgeRtClientControl::clear() noexcept | |||
| @@ -258,41 +241,43 @@ bool BridgeRtClientControl::mapData() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT(data == nullptr); | |||
| if (jackbridge_shm_map2<BridgeRtClientData>(shm, data)) | |||
| if (! jackbridge_shm_map2<BridgeRtClientData>(shm, data)) | |||
| return false; | |||
| if (isServer) | |||
| { | |||
| std::memset(data, 0, sizeof(BridgeRtClientData)); | |||
| setRingBuffer(&data->ringBuffer, true); | |||
| } | |||
| else | |||
| { | |||
| #ifdef BUILD_BRIDGE | |||
| CARLA_SAFE_ASSERT(data->midiOut[0] == 0); | |||
| setRingBuffer(&data->ringBuffer, false); | |||
| CARLA_SAFE_ASSERT_RETURN(jackbridge_sem_connect(&data->sem.server), false); | |||
| CARLA_SAFE_ASSERT_RETURN(jackbridge_sem_connect(&data->sem.client), false); | |||
| #else | |||
| std::memset(data, 0, sizeof(BridgeRtClientData)); | |||
| setRingBuffer(&data->ringBuffer, true); | |||
| #endif | |||
| return true; | |||
| } | |||
| return false; | |||
| return true; | |||
| } | |||
| void BridgeRtClientControl::unmapData() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| #endif | |||
| if (isServer) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| } | |||
| data = nullptr; | |||
| setRingBuffer(nullptr, false); | |||
| } | |||
| #ifndef BUILD_BRIDGE | |||
| bool BridgeRtClientControl::waitForClient(const uint msecs) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(msecs > 0, false); | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr, false); | |||
| CARLA_SAFE_ASSERT_RETURN(isServer, false); | |||
| jackbridge_sem_post(&data->sem.server, true); | |||
| @@ -304,9 +289,11 @@ void BridgeRtClientControl::writeOpcode(const PluginBridgeRtClientOpcode opcode) | |||
| { | |||
| writeUInt(static_cast<uint32_t>(opcode)); | |||
| } | |||
| #else | |||
| PluginBridgeRtClientOpcode BridgeRtClientControl::readOpcode() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(! isServer, kPluginBridgeRtClientNull); | |||
| return static_cast<PluginBridgeRtClientOpcode>(readUInt()); | |||
| } | |||
| @@ -319,14 +306,14 @@ BridgeRtClientControl::WaitHelper::~WaitHelper() noexcept | |||
| if (ok) | |||
| jackbridge_sem_post(&data->sem.client, false); | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| BridgeNonRtClientControl::BridgeNonRtClientControl() noexcept | |||
| : data(nullptr), | |||
| filename(), | |||
| mutex() | |||
| mutex(), | |||
| isServer(false) | |||
| { | |||
| carla_zeroChars(shm, 64); | |||
| jackbridge_shm_init(shm); | |||
| @@ -342,7 +329,6 @@ BridgeNonRtClientControl::~BridgeNonRtClientControl() noexcept | |||
| bool BridgeNonRtClientControl::initializeServer() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| char tmpFileBase[64]; | |||
| std::sprintf(tmpFileBase, PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_CLIENT "XXXXXX"); | |||
| @@ -363,17 +349,14 @@ bool BridgeNonRtClientControl::initializeServer() noexcept | |||
| CARLA_SAFE_ASSERT(data != nullptr); | |||
| filename = tmpFileBase; | |||
| isServer = true; | |||
| return true; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| bool BridgeNonRtClientControl::attachClient(const char* const basename) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(basename != nullptr && basename[0] != '\0', false); | |||
| #ifdef BUILD_BRIDGE | |||
| // must be invalid right now | |||
| CARLA_SAFE_ASSERT_RETURN(! jackbridge_shm_is_valid(shm), false); | |||
| @@ -383,9 +366,6 @@ bool BridgeNonRtClientControl::attachClient(const char* const basename) noexcept | |||
| jackbridge_shm_attach(shm, filename); | |||
| return jackbridge_shm_is_valid(shm); | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| void BridgeNonRtClientControl::clear() noexcept | |||
| @@ -397,9 +377,9 @@ void BridgeNonRtClientControl::clear() noexcept | |||
| if (! jackbridge_shm_is_valid(shm)) | |||
| { | |||
| #ifdef BUILD_BRIDGE | |||
| CARLA_SAFE_ASSERT(data == nullptr); | |||
| #endif | |||
| if (! isServer) { | |||
| CARLA_SAFE_ASSERT(data == nullptr); | |||
| } | |||
| return; | |||
| } | |||
| @@ -413,11 +393,7 @@ bool BridgeNonRtClientControl::mapData() noexcept | |||
| if (jackbridge_shm_map2<BridgeNonRtClientData>(shm, data)) | |||
| { | |||
| #ifdef BUILD_BRIDGE | |||
| setRingBuffer(&data->ringBuffer, false); | |||
| #else | |||
| setRingBuffer(&data->ringBuffer, true); | |||
| #endif | |||
| setRingBuffer(&data->ringBuffer, isServer); | |||
| return true; | |||
| } | |||
| @@ -426,19 +402,20 @@ bool BridgeNonRtClientControl::mapData() noexcept | |||
| void BridgeNonRtClientControl::unmapData() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| #endif | |||
| if (isServer) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| } | |||
| data = nullptr; | |||
| setRingBuffer(nullptr, false); | |||
| } | |||
| #ifndef BUILD_BRIDGE | |||
| void BridgeNonRtClientControl::waitIfDataIsReachingLimit() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(isServer,); | |||
| if (getAvailableDataSize() < BigStackBuffer::size/4) | |||
| return; | |||
| @@ -458,22 +435,25 @@ void BridgeNonRtClientControl::waitIfDataIsReachingLimit() noexcept | |||
| void BridgeNonRtClientControl::writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(isServer,); | |||
| writeUInt(static_cast<uint32_t>(opcode)); | |||
| } | |||
| #else | |||
| PluginBridgeNonRtClientOpcode BridgeNonRtClientControl::readOpcode() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(! isServer, kPluginBridgeNonRtClientNull); | |||
| return static_cast<PluginBridgeNonRtClientOpcode>(readUInt()); | |||
| return kPluginBridgeNonRtClientNull; | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| BridgeNonRtServerControl::BridgeNonRtServerControl() noexcept | |||
| : data(nullptr), | |||
| filename(), | |||
| mutex() | |||
| mutex(), | |||
| isServer(false) | |||
| { | |||
| carla_zeroChars(shm, 64); | |||
| jackbridge_shm_init(shm); | |||
| @@ -489,7 +469,6 @@ BridgeNonRtServerControl::~BridgeNonRtServerControl() noexcept | |||
| bool BridgeNonRtServerControl::initializeServer() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| char tmpFileBase[64]; | |||
| std::sprintf(tmpFileBase, PLUGIN_BRIDGE_NAMEPREFIX_NON_RT_SERVER "XXXXXX"); | |||
| @@ -510,17 +489,14 @@ bool BridgeNonRtServerControl::initializeServer() noexcept | |||
| CARLA_SAFE_ASSERT(data != nullptr); | |||
| filename = tmpFileBase; | |||
| isServer = true; | |||
| return true; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| bool BridgeNonRtServerControl::attachClient(const char* const basename) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(basename != nullptr && basename[0] != '\0', false); | |||
| #ifdef BUILD_BRIDGE | |||
| // must be invalid right now | |||
| CARLA_SAFE_ASSERT_RETURN(! jackbridge_shm_is_valid(shm), false); | |||
| @@ -530,9 +506,6 @@ bool BridgeNonRtServerControl::attachClient(const char* const basename) noexcept | |||
| jackbridge_shm_attach(shm, filename); | |||
| return jackbridge_shm_is_valid(shm); | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| void BridgeNonRtServerControl::clear() noexcept | |||
| @@ -558,11 +531,7 @@ bool BridgeNonRtServerControl::mapData() noexcept | |||
| if (jackbridge_shm_map2<BridgeNonRtServerData>(shm, data)) | |||
| { | |||
| #ifdef BUILD_BRIDGE | |||
| setRingBuffer(&data->ringBuffer, false); | |||
| #else | |||
| setRingBuffer(&data->ringBuffer, true); | |||
| #endif | |||
| setRingBuffer(&data->ringBuffer, isServer); | |||
| return true; | |||
| } | |||
| @@ -571,24 +540,27 @@ bool BridgeNonRtServerControl::mapData() noexcept | |||
| void BridgeNonRtServerControl::unmapData() noexcept | |||
| { | |||
| #ifndef BUILD_BRIDGE | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| #endif | |||
| if (isServer) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(data != nullptr,); | |||
| jackbridge_shm_unmap(shm, data); | |||
| } | |||
| data = nullptr; | |||
| setRingBuffer(nullptr, false); | |||
| } | |||
| #ifndef BUILD_BRIDGE | |||
| PluginBridgeNonRtServerOpcode BridgeNonRtServerControl::readOpcode() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(isServer, kPluginBridgeNonRtServerNull); | |||
| return static_cast<PluginBridgeNonRtServerOpcode>(readUInt()); | |||
| } | |||
| #else | |||
| void BridgeNonRtServerControl::waitIfDataIsReachingLimit() noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(! isServer,); | |||
| if (getAvailableDataSize() < HugeStackBuffer::size/4) | |||
| return; | |||
| @@ -608,8 +580,9 @@ void BridgeNonRtServerControl::waitIfDataIsReachingLimit() noexcept | |||
| void BridgeNonRtServerControl::writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(! isServer,); | |||
| writeUInt(static_cast<uint32_t>(opcode)); | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -204,6 +204,7 @@ struct BridgeAudioPool { | |||
| std::size_t dataSize; | |||
| CarlaString filename; | |||
| char shm[64]; | |||
| bool isServer; | |||
| BridgeAudioPool() noexcept; | |||
| ~BridgeAudioPool() noexcept; | |||
| @@ -212,9 +213,7 @@ struct BridgeAudioPool { | |||
| bool attachClient(const char* const fname) noexcept; | |||
| void clear() noexcept; | |||
| #ifndef BUILD_BRIDGE | |||
| void resize(const uint32_t bufferSize, const uint32_t audioPortCount, const uint32_t cvPortCount) noexcept; | |||
| #endif | |||
| CARLA_DECLARE_NON_COPY_STRUCT(BridgeAudioPool) | |||
| }; | |||
| @@ -226,6 +225,7 @@ struct BridgeRtClientControl : public CarlaRingBufferControl<SmallStackBuffer> { | |||
| CarlaString filename; | |||
| bool needsSemDestroy; // client only | |||
| char shm[64]; | |||
| bool isServer; | |||
| BridgeRtClientControl() noexcept; | |||
| ~BridgeRtClientControl() noexcept override; | |||
| @@ -237,11 +237,10 @@ struct BridgeRtClientControl : public CarlaRingBufferControl<SmallStackBuffer> { | |||
| bool mapData() noexcept; | |||
| void unmapData() noexcept; | |||
| #ifndef BUILD_BRIDGE | |||
| // non-bridge, server | |||
| bool waitForClient(const uint msecs) noexcept; | |||
| void writeOpcode(const PluginBridgeRtClientOpcode opcode) noexcept; | |||
| #else | |||
| // bridge, client | |||
| PluginBridgeRtClientOpcode readOpcode() noexcept; | |||
| @@ -255,7 +254,6 @@ struct BridgeRtClientControl : public CarlaRingBufferControl<SmallStackBuffer> { | |||
| CARLA_DECLARE_NON_COPY_STRUCT(WaitHelper) | |||
| }; | |||
| #endif | |||
| CARLA_DECLARE_NON_COPY_STRUCT(BridgeRtClientControl) | |||
| }; | |||
| @@ -267,6 +265,7 @@ struct BridgeNonRtClientControl : public CarlaRingBufferControl<BigStackBuffer> | |||
| CarlaString filename; | |||
| CarlaMutex mutex; | |||
| char shm[64]; | |||
| bool isServer; | |||
| BridgeNonRtClientControl() noexcept; | |||
| ~BridgeNonRtClientControl() noexcept override; | |||
| @@ -278,14 +277,12 @@ struct BridgeNonRtClientControl : public CarlaRingBufferControl<BigStackBuffer> | |||
| bool mapData() noexcept; | |||
| void unmapData() noexcept; | |||
| #ifndef BUILD_BRIDGE | |||
| // non-bridge, server | |||
| void waitIfDataIsReachingLimit() noexcept; | |||
| void writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept; | |||
| #else | |||
| // bridge, client | |||
| PluginBridgeNonRtClientOpcode readOpcode() noexcept; | |||
| #endif | |||
| CARLA_DECLARE_NON_COPY_STRUCT(BridgeNonRtClientControl) | |||
| }; | |||
| @@ -297,6 +294,7 @@ struct BridgeNonRtServerControl : public CarlaRingBufferControl<HugeStackBuffer> | |||
| CarlaString filename; | |||
| CarlaMutex mutex; | |||
| char shm[64]; | |||
| bool isServer; | |||
| BridgeNonRtServerControl() noexcept; | |||
| ~BridgeNonRtServerControl() noexcept override; | |||
| @@ -308,14 +306,12 @@ struct BridgeNonRtServerControl : public CarlaRingBufferControl<HugeStackBuffer> | |||
| bool mapData() noexcept; | |||
| void unmapData() noexcept; | |||
| #ifndef BUILD_BRIDGE | |||
| // non-bridge, server | |||
| PluginBridgeNonRtServerOpcode readOpcode() noexcept; | |||
| #else | |||
| // bridge, client | |||
| void waitIfDataIsReachingLimit() noexcept; | |||
| void writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept; | |||
| #endif | |||
| CARLA_DECLARE_NON_COPY_STRUCT(BridgeNonRtServerControl) | |||
| }; | |||