Browse Source

Add API version to bridges, to detect future breakage

tags/1.9.8
falkTX 7 years ago
parent
commit
8daecf54b3
6 changed files with 44 additions and 11 deletions
  1. +19
    -6
      source/backend/engine/CarlaEngineBridge.cpp
  2. +3
    -1
      source/backend/plugin/CarlaPluginBridge.cpp
  3. +3
    -1
      source/backend/plugin/CarlaPluginJack.cpp
  4. +14
    -3
      source/libjack/libjack.cpp
  5. +3
    -0
      source/utils/CarlaBridgeDefines.hpp
  6. +2
    -0
      source/utils/CarlaBridgeUtils.hpp

+ 19
- 6
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -171,7 +171,10 @@ public:
PluginBridgeNonRtClientOpcode opcode;

opcode = fShmNonRtClientControl.readOpcode();
CARLA_SAFE_ASSERT_INT(opcode == kPluginBridgeNonRtClientNull, opcode);
CARLA_SAFE_ASSERT_RETURN(opcode == kPluginBridgeNonRtClientVersion, false);

const uint32_t apiVersion = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_RETURN(apiVersion == CARLA_PLUGIN_BRIDGE_API_VERSION, false);

const uint32_t shmRtClientDataSize = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_INT2(shmRtClientDataSize == sizeof(BridgeRtClientData), shmRtClientDataSize, sizeof(BridgeRtClientData));
@@ -182,8 +185,17 @@ public:
const uint32_t shmNonRtServerDataSize = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_INT2(shmNonRtServerDataSize == sizeof(BridgeNonRtServerData), shmNonRtServerDataSize, sizeof(BridgeNonRtServerData));

if (shmRtClientDataSize != sizeof(BridgeRtClientData) ||
shmNonRtClientDataSize != sizeof(BridgeNonRtClientData) ||
shmNonRtServerDataSize != sizeof(BridgeNonRtServerData))
{
carla_stderr2("CarlaJackAppClient: data size mismatch");
return false;
}

opcode = fShmNonRtClientControl.readOpcode();
CARLA_SAFE_ASSERT_INT(opcode == kPluginBridgeNonRtClientInitialSetup, opcode);
CARLA_SAFE_ASSERT_RETURN(opcode == kPluginBridgeNonRtClientInitialSetup, false);

pData->bufferSize = fShmNonRtClientControl.readUInt();
pData->sampleRate = fShmNonRtClientControl.readDouble();

@@ -195,9 +207,6 @@ public:

pData->initTime(nullptr);

if (shmRtClientDataSize != sizeof(BridgeRtClientData) || shmNonRtClientDataSize != sizeof(BridgeNonRtClientData) || shmNonRtServerDataSize != sizeof(BridgeNonRtServerData))
return false;

// tell backend we're live
{
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex);
@@ -208,7 +217,6 @@ public:

// TODO
startThread(/*Thread::realtimeAudioPriority*/);

return true;
}

@@ -661,6 +669,11 @@ public:
case kPluginBridgeNonRtClientNull:
break;

case kPluginBridgeNonRtClientVersion: {
const uint apiVersion = fShmNonRtServerControl.readUInt();
CARLA_SAFE_ASSERT_UINT2(apiVersion == CARLA_PLUGIN_BRIDGE_API_VERSION, apiVersion, CARLA_PLUGIN_BRIDGE_API_VERSION);
} break;

case kPluginBridgeNonRtClientPing: {
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex);



+ 3
- 1
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -2211,7 +2211,9 @@ public:
// ---------------------------------------------------------------
// initial values

fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientNull);
fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientVersion);
fShmNonRtClientControl.writeUInt(CARLA_PLUGIN_BRIDGE_API_VERSION);

fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeRtClientData)));
fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeNonRtClientData)));
fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeNonRtServerData)));


+ 3
- 1
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -1422,7 +1422,9 @@ private:
fShmNonRtServerControl.clearData();

// initial values
fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientNull);
fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientVersion);
fShmNonRtClientControl.writeUInt(CARLA_PLUGIN_BRIDGE_API_VERSION);

fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeRtClientData)));
fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeNonRtClientData)));
fShmNonRtClientControl.writeUInt(static_cast<uint32_t>(sizeof(BridgeNonRtServerData)));


+ 14
- 3
source/libjack/libjack.cpp View File

@@ -353,7 +353,10 @@ bool CarlaJackAppClient::initSharedMemmory()
PluginBridgeNonRtClientOpcode opcode;

opcode = fShmNonRtClientControl.readOpcode();
CARLA_SAFE_ASSERT_INT(opcode == kPluginBridgeNonRtClientNull, opcode);
CARLA_SAFE_ASSERT_RETURN(opcode == kPluginBridgeNonRtClientVersion, false);

const uint32_t apiVersion = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_RETURN(apiVersion == CARLA_PLUGIN_BRIDGE_API_VERSION, false);

const uint32_t shmRtClientDataSize = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_INT2(shmRtClientDataSize == sizeof(BridgeRtClientData), shmRtClientDataSize, sizeof(BridgeRtClientData));
@@ -364,14 +367,17 @@ bool CarlaJackAppClient::initSharedMemmory()
const uint32_t shmNonRtServerDataSize = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_INT2(shmNonRtServerDataSize == sizeof(BridgeNonRtServerData), shmNonRtServerDataSize, sizeof(BridgeNonRtServerData));

if (shmRtClientDataSize != sizeof(BridgeRtClientData) || shmNonRtClientDataSize != sizeof(BridgeNonRtClientData) || shmNonRtServerDataSize != sizeof(BridgeNonRtServerData))
if (shmRtClientDataSize != sizeof(BridgeRtClientData) ||
shmNonRtClientDataSize != sizeof(BridgeNonRtClientData) ||
shmNonRtServerDataSize != sizeof(BridgeNonRtServerData))
{
carla_stderr2("CarlaJackAppClient: data size mismatch");
return false;
}

opcode = fShmNonRtClientControl.readOpcode();
CARLA_SAFE_ASSERT_INT(opcode == kPluginBridgeNonRtClientInitialSetup, opcode);
CARLA_SAFE_ASSERT_RETURN(opcode == kPluginBridgeNonRtClientInitialSetup, false);

fServer.bufferSize = fShmNonRtClientControl.readUInt();
fServer.sampleRate = fShmNonRtClientControl.readDouble();

@@ -869,6 +875,11 @@ bool CarlaJackAppClient::handleNonRtData()
case kPluginBridgeNonRtClientNull:
break;

case kPluginBridgeNonRtClientVersion: {
const uint apiVersion = fShmNonRtServerControl.readUInt();
CARLA_SAFE_ASSERT_UINT2(apiVersion == CARLA_PLUGIN_BRIDGE_API_VERSION, apiVersion, CARLA_PLUGIN_BRIDGE_API_VERSION);
} break;

case kPluginBridgeNonRtClientPing: {
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex);



+ 3
- 0
source/utils/CarlaBridgeDefines.hpp View File

@@ -20,6 +20,8 @@

#include "CarlaRingBuffer.hpp"

#define CARLA_PLUGIN_BRIDGE_API_VERSION 1

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

// Server sends these to client during RT
@@ -42,6 +44,7 @@ enum PluginBridgeRtClientOpcode {
// Server sends these to client during non-RT
enum PluginBridgeNonRtClientOpcode {
kPluginBridgeNonRtClientNull = 0,
kPluginBridgeNonRtClientVersion, // uint
kPluginBridgeNonRtClientPing,
kPluginBridgeNonRtClientPingOnOff, // bool
kPluginBridgeNonRtClientActivate,


+ 2
- 0
source/utils/CarlaBridgeUtils.hpp View File

@@ -78,6 +78,8 @@ const char* PluginBridgeNonRtClientOpcode2str(const PluginBridgeNonRtClientOpcod
{
case kPluginBridgeNonRtClientNull:
return "kPluginBridgeNonRtClientNull";
case kPluginBridgeNonRtClientVersion:
return "kPluginBridgeNonRtClientVersion";
case kPluginBridgeNonRtClientPing:
return "kPluginBridgeNonRtClientPing";
case kPluginBridgeNonRtClientPingOnOff:


Loading…
Cancel
Save