Browse Source

Make ringbuffer write calls return bool

tags/v1.9.9
falkTX 6 years ago
parent
commit
3ef5f90b0d
4 changed files with 38 additions and 38 deletions
  1. +1
    -1
      source/backend/plugin/CarlaPluginLV2.cpp
  2. +8
    -8
      source/utils/CarlaBridgeUtils.cpp
  3. +3
    -3
      source/utils/CarlaBridgeUtils.hpp
  4. +26
    -26
      source/utils/CarlaRingBuffer.hpp

+ 1
- 1
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -4266,7 +4266,7 @@ public:
if (! File(bridgeBinary.buffer()).existsAsFile())
return nullptr;

return bridgeBinary.dup();
return bridgeBinary.dupSafe();
}

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


+ 8
- 8
source/utils/CarlaBridgeUtils.cpp View File

@@ -294,9 +294,9 @@ bool BridgeRtClientControl::waitForClient(const uint msecs) noexcept
return false;
}

void BridgeRtClientControl::writeOpcode(const PluginBridgeRtClientOpcode opcode) noexcept
bool BridgeRtClientControl::writeOpcode(const PluginBridgeRtClientOpcode opcode) noexcept
{
writeUInt(static_cast<uint32_t>(opcode));
return writeUInt(static_cast<uint32_t>(opcode));
}

PluginBridgeRtClientOpcode BridgeRtClientControl::readOpcode() noexcept
@@ -442,11 +442,11 @@ void BridgeNonRtClientControl::waitIfDataIsReachingLimit() noexcept
carla_stderr("Server waitIfDataIsReachingLimit() reached and failed");
}

void BridgeNonRtClientControl::writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept
bool BridgeNonRtClientControl::writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept
{
CARLA_SAFE_ASSERT_RETURN(isServer,);
CARLA_SAFE_ASSERT_RETURN(isServer, false);

writeUInt(static_cast<uint32_t>(opcode));
return writeUInt(static_cast<uint32_t>(opcode));
}

PluginBridgeNonRtClientOpcode BridgeNonRtClientControl::readOpcode() noexcept
@@ -587,11 +587,11 @@ void BridgeNonRtServerControl::waitIfDataIsReachingLimit() noexcept
carla_stderr("Client waitIfDataIsReachingLimit() reached and failed");
}

void BridgeNonRtServerControl::writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept
bool BridgeNonRtServerControl::writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept
{
CARLA_SAFE_ASSERT_RETURN(! isServer,);
CARLA_SAFE_ASSERT_RETURN(! isServer, false);

writeUInt(static_cast<uint32_t>(opcode));
return writeUInt(static_cast<uint32_t>(opcode));
}

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

+ 3
- 3
source/utils/CarlaBridgeUtils.hpp View File

@@ -247,7 +247,7 @@ struct BridgeRtClientControl : public CarlaRingBufferControl<SmallStackBuffer> {

// non-bridge, server
bool waitForClient(const uint msecs) noexcept;
void writeOpcode(const PluginBridgeRtClientOpcode opcode) noexcept;
bool writeOpcode(const PluginBridgeRtClientOpcode opcode) noexcept;

// bridge, client
PluginBridgeRtClientOpcode readOpcode() noexcept;
@@ -287,7 +287,7 @@ struct BridgeNonRtClientControl : public CarlaRingBufferControl<BigStackBuffer>

// non-bridge, server
void waitIfDataIsReachingLimit() noexcept;
void writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept;
bool writeOpcode(const PluginBridgeNonRtClientOpcode opcode) noexcept;

// bridge, client
PluginBridgeNonRtClientOpcode readOpcode() noexcept;
@@ -319,7 +319,7 @@ struct BridgeNonRtServerControl : public CarlaRingBufferControl<HugeStackBuffer>

// bridge, client
void waitIfDataIsReachingLimit() noexcept;
void writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept;
bool writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept;

CARLA_DECLARE_NON_COPY_STRUCT(BridgeNonRtServerControl)
};


+ 26
- 26
source/utils/CarlaRingBuffer.hpp View File

@@ -238,68 +238,68 @@ public:

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

void writeBool(const bool value) noexcept
bool writeBool(const bool value) noexcept
{
tryWrite(&value, sizeof(bool));
return tryWrite(&value, sizeof(bool));
}

void writeByte(const uint8_t value) noexcept
bool writeByte(const uint8_t value) noexcept
{
tryWrite(&value, sizeof(uint8_t));
return tryWrite(&value, sizeof(uint8_t));
}

void writeShort(const int16_t value) noexcept
bool writeShort(const int16_t value) noexcept
{
tryWrite(&value, sizeof(int16_t));
return tryWrite(&value, sizeof(int16_t));
}

void writeUShort(const uint16_t value) noexcept
bool writeUShort(const uint16_t value) noexcept
{
tryWrite(&value, sizeof(uint16_t));
return tryWrite(&value, sizeof(uint16_t));
}

void writeInt(const int32_t value) noexcept
bool writeInt(const int32_t value) noexcept
{
tryWrite(&value, sizeof(int32_t));
return tryWrite(&value, sizeof(int32_t));
}

void writeUInt(const uint32_t value) noexcept
bool writeUInt(const uint32_t value) noexcept
{
tryWrite(&value, sizeof(uint32_t));
return tryWrite(&value, sizeof(uint32_t));
}

void writeLong(const int64_t value) noexcept
bool writeLong(const int64_t value) noexcept
{
tryWrite(&value, sizeof(int64_t));
return tryWrite(&value, sizeof(int64_t));
}

void writeULong(const uint64_t value) noexcept
bool writeULong(const uint64_t value) noexcept
{
tryWrite(&value, sizeof(uint64_t));
return tryWrite(&value, sizeof(uint64_t));
}

void writeFloat(const float value) noexcept
bool writeFloat(const float value) noexcept
{
tryWrite(&value, sizeof(float));
return tryWrite(&value, sizeof(float));
}

void writeDouble(const double value) noexcept
bool writeDouble(const double value) noexcept
{
tryWrite(&value, sizeof(double));
return tryWrite(&value, sizeof(double));
}

void writeCustomData(const void* const data, const uint32_t size) noexcept
bool writeCustomData(const void* const data, const uint32_t size) noexcept
{
CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);
CARLA_SAFE_ASSERT_RETURN(data != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(size > 0, false);

tryWrite(data, size);
return tryWrite(data, size);
}

template <typename T>
void writeCustomType(const T& type) noexcept
bool writeCustomType(const T& type) noexcept
{
tryWrite(&type, sizeof(T));
return tryWrite(&type, sizeof(T));
}

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


Loading…
Cancel
Save