From 3ef5f90b0d5bc8bd41c21f14d2f680c411a5447a Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 3 Apr 2018 13:11:40 +0200 Subject: [PATCH] Make ringbuffer write calls return bool --- source/backend/plugin/CarlaPluginLV2.cpp | 2 +- source/utils/CarlaBridgeUtils.cpp | 16 ++++---- source/utils/CarlaBridgeUtils.hpp | 6 +-- source/utils/CarlaRingBuffer.hpp | 52 ++++++++++++------------ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index c3d635224..bd392a752 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -4266,7 +4266,7 @@ public: if (! File(bridgeBinary.buffer()).existsAsFile()) return nullptr; - return bridgeBinary.dup(); + return bridgeBinary.dupSafe(); } // ------------------------------------------------------------------- diff --git a/source/utils/CarlaBridgeUtils.cpp b/source/utils/CarlaBridgeUtils.cpp index 485d0c843..c04bb7307 100644 --- a/source/utils/CarlaBridgeUtils.cpp +++ b/source/utils/CarlaBridgeUtils.cpp @@ -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(opcode)); + return writeUInt(static_cast(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(opcode)); + return writeUInt(static_cast(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(opcode)); + return writeUInt(static_cast(opcode)); } // ------------------------------------------------------------------------------------------------------------------- diff --git a/source/utils/CarlaBridgeUtils.hpp b/source/utils/CarlaBridgeUtils.hpp index d974f6eab..39d93a449 100644 --- a/source/utils/CarlaBridgeUtils.hpp +++ b/source/utils/CarlaBridgeUtils.hpp @@ -247,7 +247,7 @@ struct BridgeRtClientControl : public CarlaRingBufferControl { // 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 // 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 // bridge, client void waitIfDataIsReachingLimit() noexcept; - void writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept; + bool writeOpcode(const PluginBridgeNonRtServerOpcode opcode) noexcept; CARLA_DECLARE_NON_COPY_STRUCT(BridgeNonRtServerControl) }; diff --git a/source/utils/CarlaRingBuffer.hpp b/source/utils/CarlaRingBuffer.hpp index caf7cbbe7..40e40f7cc 100644 --- a/source/utils/CarlaRingBuffer.hpp +++ b/source/utils/CarlaRingBuffer.hpp @@ -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 - void writeCustomType(const T& type) noexcept + bool writeCustomType(const T& type) noexcept { - tryWrite(&type, sizeof(T)); + return tryWrite(&type, sizeof(T)); } // -------------------------------------------------------------------