From f96380f06e2cf3fc33ccf85519111f079c3de586 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 26 Jan 2015 02:41:47 +0000 Subject: [PATCH] Temporary workaround to fix win bridges for carla-single --- data/carla-single | 6 +++- source/backend/CarlaStandalone.cpp | 1 - source/backend/engine/CarlaEngine.cpp | 6 +++- source/backend/plugin/CarlaPluginBridge.cpp | 14 +++++++-- source/bridges-plugin/CarlaBridgePlugin.cpp | 16 ++++++++++- source/bridges-plugin/Makefile | 1 + source/utils/CarlaBackendUtils.hpp | 32 +++++++++++++++++++++ 7 files changed, 70 insertions(+), 6 deletions(-) diff --git a/data/carla-single b/data/carla-single index e3d872481..9091df9ea 100755 --- a/data/carla-single +++ b/data/carla-single @@ -245,7 +245,11 @@ else: command = [] if ARCH in ("win32", "win64"): - command.append("wine") + # FIXME win bridges don't work nicely with JACK right now + #command.append("wine") + + BRIDGE = BRIDGE.replace("%s.exe" % ARCH, "native") + os.environ["CARLA_BRIDGE_PLUGIN_BINARY_TYPE"] = ARCH command.append(BRIDGE) command.append(FORMAT) diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index a053dd021..eb8b7abe3 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -1070,7 +1070,6 @@ uint32_t carla_get_max_plugin_number() bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr, uint options) { - CARLA_SAFE_ASSERT_RETURN(label != nullptr /*&& label[0] != '\0'*/, false); carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p, %u)", btype, CB::BinaryType2Str(btype), ptype, CB::PluginType2Str(ptype), filename, name, label, uniqueId, extraPtr, options); if (gStandalone.engine != nullptr) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 74b57026b..552e439fd 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -370,7 +370,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, CarlaPlugin* plugin = nullptr; -#ifndef BUILD_BRIDGE +#ifndef BRIDGE_PLUGIN CarlaString bridgeBinary(pData->options.binaryDir); if (bridgeBinary.isNotEmpty()) @@ -1233,7 +1233,11 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch break; case ENGINE_OPTION_PREFER_PLUGIN_BRIDGES: +#ifdef BUILD_BRIDGE + CARLA_SAFE_ASSERT_RETURN(value == 0,); +#else CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,); +#endif pData->options.preferPluginBridges = (value != 0); break; diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index afab19240..b2d5a64da 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -15,7 +15,7 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifdef BUILD_BRIDGE +#if defined(BUILD_BRIDGE) && defined(BRIDGE_PLUGIN) # error This file should be used under bridge mode #endif @@ -1172,6 +1172,7 @@ public: fShmNonRtClientControl.commitWrite(); } +#ifndef BUILD_BRIDGE if (yesNo) { pData->tryTransient(); @@ -1180,6 +1181,7 @@ public: { pData->transientTryCounter = 0; } +#endif } void idle() override @@ -1462,7 +1464,9 @@ public: // ---------------------------------------------------------------------------------------------------- // Event Input (System) +#ifndef BUILD_BRIDGE bool allNotesOffSent = false; +#endif for (uint32_t i=0, numEvents=pData->event.portIn->getEventCount(); i < numEvents; ++i) { @@ -1483,6 +1487,7 @@ public: break; case kEngineControlEventTypeParameter: +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == pData->ctrlChannel) { @@ -1532,7 +1537,7 @@ public: break; } } - +#endif fShmRtClientControl.writeOpcode(kPluginBridgeRtClientControlEventParameter); fShmRtClientControl.writeUInt(event.time); fShmRtClientControl.writeByte(event.channel); @@ -1576,11 +1581,13 @@ public: case kEngineControlEventTypeAllNotesOff: if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { +#ifndef BUILD_BRIDGE if (event.channel == pData->ctrlChannel && ! allNotesOffSent) { allNotesOffSent = true; sendMidiAllNotesOffToCallback(); } +#endif fShmRtClientControl.writeOpcode(kPluginBridgeRtClientControlEventAllNotesOff); fShmRtClientControl.writeUInt(event.time); @@ -1783,6 +1790,7 @@ public: for (uint32_t i=0; i < fInfo.aOuts; ++i) FloatVectorOperations::copy(audioOut[i], fShmAudioPool.data + ((i + fInfo.aIns) * frames), static_cast(frames)); +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -1847,6 +1855,8 @@ public: } // End of Post-processing +#endif // BUILD_BRIDGE + // -------------------------------------------------------------------------------------------------------- pData->singleMutex.unlock(); diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index d3268a8e1..04e19bd15 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -309,6 +309,20 @@ int main(int argc, char* argv[]) if (label[0] == '\0' || std::strcmp(label, "(none)") == 0) label = nullptr; + // --------------------------------------------------------------------- + // Check binary type + + CarlaBackend::BinaryType btype = CarlaBackend::BINARY_NATIVE; + + if (const char* const binaryTypeStr = std::getenv("CARLA_BRIDGE_PLUGIN_BINARY_TYPE")) + btype = CarlaBackend::getBinaryTypeFromString(binaryTypeStr); + + if (btype == CarlaBackend::BINARY_NONE) + { + carla_stderr("Invalid binary type '%i'", btype); + return 1; + } + // --------------------------------------------------------------------- // Check plugin type @@ -409,7 +423,7 @@ int main(int argc, char* argv[]) int ret; - if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, uniqueId, extraStuff, 0x0)) + if (carla_add_plugin(btype, itype, filename, name, label, uniqueId, extraStuff, 0x0)) { ret = 0; diff --git a/source/bridges-plugin/Makefile b/source/bridges-plugin/Makefile index 23906113c..716e9ab76 100644 --- a/source/bridges-plugin/Makefile +++ b/source/bridges-plugin/Makefile @@ -172,6 +172,7 @@ OBJS_native = \ $(OBJDIR)/CarlaEngineBridge.cpp.o \ $(OBJDIR)/CarlaPlugin.cpp.o \ $(OBJDIR)/CarlaPluginInternal.cpp.o \ + $(OBJDIR)/CarlaPluginBridge.cpp.o \ $(OBJDIR)/CarlaPluginNative.cpp.o \ $(OBJDIR)/CarlaPluginLADSPA.cpp.o \ $(OBJDIR)/CarlaPluginDSSI.cpp.o \ diff --git a/source/utils/CarlaBackendUtils.hpp b/source/utils/CarlaBackendUtils.hpp index 8783aa421..651539c92 100644 --- a/source/utils/CarlaBackendUtils.hpp +++ b/source/utils/CarlaBackendUtils.hpp @@ -415,6 +415,38 @@ const char* PatchbayIcon2Str(const PatchbayIcon icon) noexcept // ----------------------------------------------------------------------- +static inline +BinaryType getBinaryTypeFromString(const char* const ctype) noexcept +{ + CARLA_SAFE_ASSERT_RETURN(ctype != nullptr && ctype[0] != '\0', BINARY_NONE); + carla_debug("CarlaBackend::getBinaryTypeFromString(\"%s\")", ctype); + + CarlaString stype(ctype); + + if (stype.isEmpty()) + return BINARY_NONE; + + stype.toLower(); + + if (stype == "none") + return BINARY_NONE; + if (stype == "native") + return BINARY_NATIVE; + if (stype == "posix32" || stype == "linux32" || stype == "mac32") + return BINARY_POSIX32; + if (stype == "posix64" || stype == "linux64" || stype == "mac64") + return BINARY_POSIX64; + if (stype == "win32") + return BINARY_WIN32; + if (stype == "win64") + return BINARY_WIN64; + + carla_stderr("CarlaBackend::getBinaryTypeFromString(\"%s\") - invalid string type", ctype); + return BINARY_NONE; +} + +// ----------------------------------------------------------------------- + static inline const char* getPluginTypeAsString(const PluginType type) noexcept {