diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index bcacb3176..918a6b92a 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2022 Filipe Coelho + * Copyright (C) 2011-2023 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 @@ -112,6 +112,7 @@ public: fClosingDown(false), fIsOffline(false), fFirstIdle(true), + fBridgeVersion(0), fLastPingTime(-1) { carla_debug("CarlaEngineBridge::CarlaEngineBridge(\"%s\", \"%s\", \"%s\", \"%s\")", audioPoolBaseName, rtClientBaseName, nonRtClientBaseName, nonRtServerBaseName); @@ -396,6 +397,8 @@ public: fShmNonRtServerControl.commitWrite(); } + fShmNonRtServerControl.waitIfDataIsReachingLimit(); + // kPluginBridgeNonRtServerAudioCount { const uint32_t aIns = plugin->getAudioInCount(); @@ -790,9 +793,9 @@ public: break; case kPluginBridgeNonRtClientVersion: { - const uint apiVersion = fShmNonRtServerControl.readUInt(); - CARLA_SAFE_ASSERT_UINT2(apiVersion >= CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM, - apiVersion, CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM); + fBridgeVersion = fShmNonRtServerControl.readUInt(); + CARLA_SAFE_ASSERT_UINT2(fBridgeVersion >= CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM, + fBridgeVersion, CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM); } break; case kPluginBridgeNonRtClientPing: { @@ -878,6 +881,8 @@ public: } case kPluginBridgeNonRtClientSetCustomData: { + const uint32_t maxLocalValueLen = fBridgeVersion >= 10 ? 4096 : 16384; + // type const uint32_t typeSize = fShmNonRtClientControl.readUInt(); char typeStr[typeSize+1]; @@ -895,7 +900,7 @@ public: if (valueSize > 0) { - if (valueSize > 16384) + if (valueSize > maxLocalValueLen) { const uint32_t bigValueFilePathSize = fShmNonRtClientControl.readUInt(); char bigValueFilePathTry[bigValueFilePathSize+1]; @@ -1059,6 +1064,8 @@ public: plugin->prepareForSave(false); + const uint32_t maxLocalValueLen = fBridgeVersion >= 10 ? 4096 : 16384; + for (uint32_t i=0, count=plugin->getCustomDataCount(); igetCustomData(i)); @@ -1070,12 +1077,12 @@ public: const uint32_t keyLen = static_cast(std::strlen(cdata.key)); const uint32_t valueLen = static_cast(std::strlen(cdata.value)); - if (valueLen > 16384) - fShmNonRtServerControl.waitIfDataIsReachingLimit(); - { const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex); + if (valueLen > maxLocalValueLen) + fShmNonRtServerControl.waitIfDataIsReachingLimit(); + fShmNonRtServerControl.writeOpcode(kPluginBridgeNonRtServerSetCustomData); fShmNonRtServerControl.writeUInt(typeLen); @@ -1088,7 +1095,7 @@ public: if (valueLen > 0) { - if (valueLen > 16384) + if (valueLen > maxLocalValueLen) { String filePath(File::getSpecialLocation(File::tempDirectory).getFullPathName()); @@ -1114,9 +1121,8 @@ public: } fShmNonRtServerControl.commitWrite(); + fShmNonRtServerControl.waitIfDataIsReachingLimit(); } - - fShmNonRtServerControl.waitIfDataIsReachingLimit(); } if (plugin->getOptionsEnabled() & PLUGIN_OPTION_USE_CHUNKS) @@ -1648,6 +1654,7 @@ private: bool fClosingDown; bool fIsOffline; bool fFirstIdle; + uint32_t fBridgeVersion; int64_t fLastPingTime; CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineBridge) diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index d4132f132..332d26be4 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Bridge - * Copyright (C) 2011-2022 Filipe Coelho + * Copyright (C) 2011-2023 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 @@ -930,18 +930,18 @@ public: return; } + const uint32_t maxLocalValueLen = fBridgeVersion >= 10 ? 4096 : 16384; + const uint32_t typeLen = static_cast(std::strlen(type)); const uint32_t keyLen = static_cast(std::strlen(key)); const uint32_t valueLen = static_cast(std::strlen(value)); - /* - if (valueLen > 16384) - fShmNonRtClientControl.waitIfDataIsReachingLimit(); - */ - { const CarlaMutexLocker _cml(fShmNonRtClientControl.mutex); + if (valueLen > maxLocalValueLen) + fShmNonRtClientControl.waitIfDataIsReachingLimit(); + fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientSetCustomData); fShmNonRtClientControl.writeUInt(typeLen); @@ -954,7 +954,7 @@ public: if (valueLen > 0) { - if (valueLen > 16384) + if (valueLen > maxLocalValueLen) { String filePath(File::getSpecialLocation(File::tempDirectory).getFullPathName()); @@ -2508,6 +2508,7 @@ public: case kPluginBridgeNonRtServerSetCustomData: { // uint/size, str[], uint/size, str[], uint/size, str[] + const uint32_t maxLocalValueLen = fBridgeVersion >= 10 ? 4096 : 16384; // type const uint32_t typeSize = fShmNonRtServerControl.readUInt(); @@ -2525,7 +2526,7 @@ public: const uint32_t valueSize = fShmNonRtServerControl.readUInt(); // special case for big values - if (valueSize > 16384) + if (valueSize > maxLocalValueLen) { const uint32_t bigValueFilePathSize = fShmNonRtServerControl.readUInt(); char bigValueFilePath[bigValueFilePathSize+1]; diff --git a/source/utils/CarlaBridgeDefines.hpp b/source/utils/CarlaBridgeDefines.hpp index c502650e3..36eae00dd 100644 --- a/source/utils/CarlaBridgeDefines.hpp +++ b/source/utils/CarlaBridgeDefines.hpp @@ -24,7 +24,7 @@ #define CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM 6 // current API version, bumped when something is added -#define CARLA_PLUGIN_BRIDGE_API_VERSION_CURRENT 9 +#define CARLA_PLUGIN_BRIDGE_API_VERSION_CURRENT 10 // -------------------------------------------------------------------------------------------------------------------