Browse Source

Add noexcept's where possible, cleanup

tags/1.9.4
falkTX 11 years ago
parent
commit
74e67cee93
10 changed files with 237 additions and 208 deletions
  1. +2
    -2
      source/tests/CarlaString.cpp
  2. +44
    -39
      source/tests/Makefile
  3. +32
    -17
      source/tests/Utils.cpp
  4. +30
    -30
      source/utils/CarlaBackendUtils.hpp
  5. +2
    -2
      source/utils/CarlaBridgeUtils.hpp
  6. +3
    -3
      source/utils/CarlaLadspaUtils.hpp
  7. +70
    -72
      source/utils/CarlaOscUtils.hpp
  8. +7
    -7
      source/utils/CarlaRingBuffer.hpp
  9. +12
    -12
      source/utils/CarlaString.hpp
  10. +35
    -24
      source/utils/CarlaUtils.hpp

+ 2
- 2
source/tests/CarlaString.cpp View File

@@ -70,7 +70,7 @@ int main()
assert(! str.isEmpty()); assert(! str.isEmpty());
assert(! str.contains("6")); assert(! str.contains("6"));
assert(! str.isDigit(2)); assert(! str.isDigit(2));
assert(! str.isDigit(-1));
assert(! str.isDigit((size_t)-1)); // test out of bounds


// negative number // negative number
str = CarlaString(-51); str = CarlaString(-51);
@@ -85,7 +85,7 @@ int main()
assert(! str.isEmpty()); assert(! str.isEmpty());
assert(! str.contains("6")); assert(! str.contains("6"));
assert(! str.isDigit(0)); assert(! str.isDigit(0));
assert(! str.isDigit(-1));
assert(! str.isDigit((size_t)-1)); // test out of bounds


// small operations // small operations
str += "ah"; str += "ah";


+ 44
- 39
source/tests/Makefile View File

@@ -4,28 +4,37 @@
# Created by falkTX # Created by falkTX
# #


include ../Makefile.mk
# --------------------------------------------------------------

BASE_FLAGS = -Wall -Wextra -Werror -fPIC -DPIC -pipe -DREAL_BUILD
BASE_FLAGS += -Wcast-qual -Wconversion -Wlogical-op
BASE_FLAGS += -Wsign-conversion -Wuninitialized -Wunused-parameter
BASE_FLAGS += -DDEBUG -O0 -g
BASE_FLAGS += -I. -I../backend -I../includes -I../utils
BASE_FLAGS += -isystem ../modules


# -------------------------------------------------------------- # --------------------------------------------------------------


BUILD_CXX_FLAGS += -I. -I../backend -I../includes -I../modules -I../modules/distrho -I../utils
BUILD_CXX_FLAGS += -std=c++11 -std=gnu++11 -Wzero-as-null-pointer-constant
BUILD_CXX_FLAGS += -isystem /opt/kxstudio/include
ANSI_FLAGS = $(BASE_FLAGS) -DBUILD_ANSI_TEST
ANSI_FLAGS += -ansi -pedantic -pedantic-errors -Waggregate-return
ANSI_FLAGS += -I../backend -I../includes
# ANSI_FLAGS += -L../backend -lcarla_standalone2


# -------------------------------------------------------------- # --------------------------------------------------------------


ANSI_FLAGS = -DBUILD_ANSI_TEST -DREAL_BUILD -I../backend -I../includes
ANSI_FLAGS += -Wall -Wextra -Werror
ANSI_FLAGS += -DDEBUG -O0 -g
ANSI_FLAGS += -ansi -pedantic -pedantic-errors
ANSI_FLAGS += -Wunused-parameter -Wuninitialized -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return
ANSI_FLAGS += -L../backend -lcarla_standalone2
GNU_CXX_FLAGS = $(BASE_FLAGS)
GNU_CXX_FLAGS += -std=c++11 -std=gnu++11 -Wzero-as-null-pointer-constant

# --------------------------------------------------------------

PEDANTIC_CXX_FLAGS = $(BASE_FLAGS)
PEDANTIC_CXX_FLAGS += -std=c++11 -pedantic -pedantic-errors -Wzero-as-null-pointer-constant -Wno-vla
PEDANTIC_CXX_FLAGS += -isystem /opt/kxstudio/include


# -------------------------------------------------------------- # --------------------------------------------------------------


# TARGETS = ansi-pedantic-test_c ansi-pedantic-test_c99 ansi-pedantic-test_cxx ansi-pedantic-test_cxx11 # TARGETS = ansi-pedantic-test_c ansi-pedantic-test_c99 ansi-pedantic-test_cxx ansi-pedantic-test_cxx11
TARGETS += CarlaString
# Print RtList Utils
TARGETS += CarlaString Print RtLinkedList RtLinkedListGnu Utils


all: $(TARGETS) all: $(TARGETS)


@@ -46,45 +55,27 @@ ansi-pedantic-test_cxx11: ansi-pedantic-test.c ../backend/Carla*.h
# -------------------------------------------------------------- # --------------------------------------------------------------


CarlaString: CarlaString.cpp ../utils/CarlaString.hpp CarlaString: CarlaString.cpp ../utils/CarlaString.hpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@
valgrind ./CarlaString valgrind ./CarlaString


DISTRHO: DISTRHO.cpp ../modules/distrho/*.hpp ../modules/distrho/src/*.cpp
$(CXX) $< ../modules/dgl.a $(BUILD_CXX_FLAGS) -I../modules/distrho -I../modules/carla_native/nekobi $(LINK_FLAGS) $(DGL_LIBS) -lpthread -o $@
./DISTRHO

DISTRHO.so: DISTRHO.cpp ../modules/distrho/*.hpp ../modules/distrho/src/*.cpp
$(CXX) $< ../modules/dgl.a $(BUILD_CXX_FLAGS) -I../modules/distrho -I../modules/carla_native/nekobi -DSHARED_DLL $(LINK_FLAGS) $(DGL_LIBS) -lpthread -shared -Wl,--no-undefined -o $@

DGL: DGL.cpp ../modules/distrho/dgl/src/Window.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@
# ./DGL
# valgrind ./DGL

LibOpenMain: LibOpenMain.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -ldl -o $@

Print: Print.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@
# valgrind ./Print
Print: Print.cpp ../utils/CarlaUtils.hpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@
valgrind ./Print


RtLinkedList: RtLinkedList.cpp ../utils/LinkedList.hpp ../utils/RtLinkedList.hpp ../modules/rtmempool.a RtLinkedList: RtLinkedList.cpp ../utils/LinkedList.hpp ../utils/RtLinkedList.hpp ../modules/rtmempool.a
$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -lpthread -o $@
$(CXX) $< ../modules/rtmempool.a $(PEDANTIC_CXX_FLAGS) -lpthread -o $@
valgrind ./RtLinkedList valgrind ./RtLinkedList


RtLinkedListGnu: RtLinkedList.cpp ../utils/LinkedList.hpp ../utils/RtLinkedList.hpp ../modules/rtmempool.a RtLinkedListGnu: RtLinkedList.cpp ../utils/LinkedList.hpp ../utils/RtLinkedList.hpp ../modules/rtmempool.a
$(CXX) $^ $(BUILD_CXX_FLAGS) -std=gnu++11 $(LINK_FLAGS) -lpthread -o $@
$(CXX) $< ../modules/rtmempool.a $(GNU_CXX_FLAGS) -lpthread -o $@
valgrind ./RtLinkedListGnu valgrind ./RtLinkedListGnu


Utils: Utils.cpp
$(CXX) $^ $(BUILD_CXX_FLAGS) $(ANSI_CXX_FLAGS) -std=c++11 -Wzero-as-null-pointer-constant $(LINK_FLAGS) -ldl -lpthread -o $@
# valgrind ./Utils
Utils: Utils.cpp ../utils/*.hpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -ldl -lpthread -o $@
valgrind ./Utils


# -------------------------------------------------------------- # --------------------------------------------------------------


%.cpp.o: %.cpp
$(CXX) $< $(BUILD_CXX_FLAGS) $(ANSI_CXX_FLAGS) -c -o $@

../modules/%.a: ../modules/%.a:
$(MAKE) -C ../modules $* $(MAKE) -C ../modules $*


@@ -97,3 +88,17 @@ debug:
$(MAKE) DEBUG=true $(MAKE) DEBUG=true


# -------------------------------------------------------------- # --------------------------------------------------------------

DISTRHO: DISTRHO.cpp ../modules/distrho/*.hpp ../modules/distrho/src/*.cpp
$(CXX) $< ../modules/dgl.a $(PEDANTIC_CXX_FLAGS) -I../modules/distrho -I../modules/carla_native/nekobi $(LINK_FLAGS) $(DGL_LIBS) -lpthread -o $@
./DISTRHO

DISTRHO.so: DISTRHO.cpp ../modules/distrho/*.hpp ../modules/distrho/src/*.cpp
$(CXX) $< ../modules/dgl.a $(PEDANTIC_CXX_FLAGS) -I../modules/distrho -I../modules/carla_native/nekobi -DSHARED_DLL $(LINK_FLAGS) $(DGL_LIBS) -lpthread -shared -Wl,--no-undefined -o $@

DGL: DGL.cpp ../modules/distrho/dgl/src/Window.cpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) -o $@
# ./DGL
# valgrind ./DGL

# --------------------------------------------------------------

+ 32
- 17
source/tests/Utils.cpp View File

@@ -22,25 +22,25 @@
// #include "CarlaDssiUtils.hpp" // #include "CarlaDssiUtils.hpp"
#include "CarlaJuceUtils.hpp" #include "CarlaJuceUtils.hpp"
#include "CarlaLadspaUtils.hpp" #include "CarlaLadspaUtils.hpp"
#include "CarlaLibUtils.hpp"
// #include "CarlaLibUtils.hpp"
// #include "CarlaLv2Utils.hpp" // #include "CarlaLv2Utils.hpp"
#include "CarlaOscUtils.hpp" #include "CarlaOscUtils.hpp"
#include "CarlaPipeUtils.hpp"
#include "CarlaShmUtils.hpp"
// #include "CarlaPipeUtils.hpp"
// #include "CarlaShmUtils.hpp"
// #include "CarlaStateUtils.hpp" // #include "CarlaStateUtils.hpp"
#include "CarlaVstUtils.hpp"
// #include "CarlaVstUtils.hpp"


#include "CarlaLibCounter.hpp"
//#include "CarlaLogThread.hpp"
#include "CarlaMutex.hpp"
#include "CarlaRingBuffer.hpp"
#include "CarlaString.hpp"
#include "CarlaThread.hpp"
#include "List.hpp"
#include "Lv2AtomQueue.hpp"
#include "RtList.hpp"
// #include "CarlaLibCounter.hpp"
// #include "CarlaLogThread.hpp"
// #include "CarlaMutex.hpp"
// #include "CarlaRingBuffer.hpp"
// #include "CarlaString.hpp"
// #include "CarlaThread.hpp"
// #include "List.hpp"
// #include "Lv2AtomQueue.hpp"
// #include "RtList.hpp"


//#include "JucePluginWindow.hpp"
// #include "JucePluginWindow.hpp"


struct MyStruct { struct MyStruct {
char pad[100]; char pad[100];
@@ -63,6 +63,7 @@ private:
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyLeakCheckedClass) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyLeakCheckedClass)
}; };


#if 0
class MyThread : public CarlaThread class MyThread : public CarlaThread
{ {
public: public:
@@ -101,6 +102,7 @@ protected:
private: private:
CarlaMutex* const fMu; CarlaMutex* const fMu;
}; };
#endif


int main() int main()
{ {
@@ -175,9 +177,18 @@ int main()


// math/memory functions // math/memory functions
{ {
carla_min<int32_t>(0, -5, 8);
carla_max<int32_t>(0, -5, 8);
carla_fixValue<float>(0.0f, 1.0f, 1.1f);
assert(carla_min<int32_t>(0, -5, 8) == 8);
assert(carla_max<int32_t>(0, -5, 8) == 0);
assert(carla_fixValue<float>(0.0f, 1.0f, 1.1f) == 1.0f);

int v1 = 6;
int v2 = 8;
const int v3 = 9;
assert(v1 == 6 && v2 == 8 && v3 == 9);
carla_copy<int>(&v1, &v2, 1);
assert(v1 == 8 && v2 == 8 && v3 == 9);
carla_copy<int>(&v2, &v3, 1);
assert(v1 == 8 && v2 == 9 && v3 == 9);


float fl[5]; float fl[5];
carla_fill(fl, 5, 1.11f); carla_fill(fl, 5, 1.11f);
@@ -224,6 +235,8 @@ int main()


char ch[500]; char ch[500];
carla_zeroChar(ch, 500); carla_zeroChar(ch, 500);
for (int i=0; i<500; ++i)
assert(ch[i] == '\0');
} }


{ {
@@ -242,6 +255,7 @@ int main()
delete b; delete b;
} }


#if 0
// Mutex // Mutex
{ {
CarlaMutex m; CarlaMutex m;
@@ -281,6 +295,7 @@ int main()
m.unlock(); m.unlock();
t.stop(-1); t.stop(-1);
} }
#endif


return 0; return 0;
} }

+ 30
- 30
source/utils/CarlaBackendUtils.hpp View File

@@ -27,7 +27,7 @@ CARLA_BACKEND_START_NAMESPACE
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
const char* PluginOption2Str(const unsigned int option)
const char* PluginOption2Str(const unsigned int option) noexcept
{ {
switch (option) switch (option)
{ {
@@ -58,7 +58,7 @@ const char* PluginOption2Str(const unsigned int option)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
const char* BinaryType2Str(const BinaryType type)
const char* BinaryType2Str(const BinaryType type) noexcept
{ {
switch (type) switch (type)
{ {
@@ -81,7 +81,7 @@ const char* BinaryType2Str(const BinaryType type)
} }


static inline static inline
const char* PluginType2Str(const PluginType type)
const char* PluginType2Str(const PluginType type) noexcept
{ {
switch (type) switch (type)
{ {
@@ -99,14 +99,14 @@ const char* PluginType2Str(const PluginType type)
return "PLUGIN_VST"; return "PLUGIN_VST";
case PLUGIN_AU: case PLUGIN_AU:
return "PLUGIN_AU"; return "PLUGIN_AU";
case PLUGIN_CSOUND:
return "PLUGIN_CSOUND";
case PLUGIN_GIG:
return "PLUGIN_GIG";
case PLUGIN_SF2:
return "PLUGIN_SF2";
case PLUGIN_SFZ:
return "PLUGIN_SFZ";
case PLUGIN_FILE_CSD:
return "PLUGIN_FILE_CSD";
case PLUGIN_FILE_GIG:
return "PLUGIN_FILE_GIG";
case PLUGIN_FILE_SF2:
return "PLUGIN_FILE_SF2";
case PLUGIN_FILE_SFZ:
return "PLUGIN_FILE_SFZ";
} }


carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type); carla_stderr("CarlaBackend::PluginType2Str(%i) - invalid type", type);
@@ -114,7 +114,7 @@ const char* PluginType2Str(const PluginType type)
} }


static inline static inline
const char* PluginCategory2Str(const PluginCategory category)
const char* PluginCategory2Str(const PluginCategory category) noexcept
{ {
switch (category) switch (category)
{ {
@@ -145,7 +145,7 @@ const char* PluginCategory2Str(const PluginCategory category)
} }


static inline static inline
const char* ParameterType2Str(const ParameterType type)
const char* ParameterType2Str(const ParameterType type) noexcept
{ {
switch (type) switch (type)
{ {
@@ -164,7 +164,7 @@ const char* ParameterType2Str(const ParameterType type)
} }


static inline static inline
const char* InternalParameterIndex2Str(const InternalParameterIndex index)
const char* InternalParameterIndex2Str(const InternalParameterIndex index) noexcept
{ {
switch (index) switch (index)
{ {
@@ -193,7 +193,7 @@ const char* InternalParameterIndex2Str(const InternalParameterIndex index)
} }


static inline static inline
const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode)
const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept
{ {
switch (opcode) switch (opcode)
{ {
@@ -278,7 +278,7 @@ const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode)
} }


static inline static inline
const char* EngineOption2Str(const EngineOption option)
const char* EngineOption2Str(const EngineOption option) noexcept
{ {
switch (option) switch (option)
{ {
@@ -319,7 +319,7 @@ const char* EngineOption2Str(const EngineOption option)
} }


static inline static inline
const char* EngineProcessMode2Str(const EngineProcessMode mode)
const char* EngineProcessMode2Str(const EngineProcessMode mode) noexcept
{ {
switch (mode) switch (mode)
{ {
@@ -340,7 +340,7 @@ const char* EngineProcessMode2Str(const EngineProcessMode mode)
} }


static inline static inline
const char* EngineTransportMode2Str(const EngineTransportMode mode)
const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept
{ {
switch (mode) switch (mode)
{ {
@@ -361,7 +361,7 @@ const char* EngineTransportMode2Str(const EngineTransportMode mode)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode)
const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode) noexcept
{ {
switch (opcode) switch (opcode)
{ {
@@ -380,7 +380,7 @@ const char* FileCallbackOpcode2Str(const FileCallbackOpcode opcode)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
const char* getPluginTypeAsString(const PluginType type)
const char* getPluginTypeAsString(const PluginType type) noexcept
{ {
carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type)); carla_debug("CarlaBackend::getPluginTypeAsString(%i:%s)", type, PluginType2Str(type));


@@ -400,13 +400,13 @@ const char* getPluginTypeAsString(const PluginType type)
return "VST"; return "VST";
case PLUGIN_AU: case PLUGIN_AU:
return "AU"; return "AU";
case PLUGIN_CSOUND:
return "CSOUND";
case PLUGIN_GIG:
case PLUGIN_FILE_CSD:
return "CSD";
case PLUGIN_FILE_GIG:
return "GIG"; return "GIG";
case PLUGIN_SF2:
case PLUGIN_FILE_SF2:
return "SF2"; return "SF2";
case PLUGIN_SFZ:
case PLUGIN_FILE_SFZ:
return "SFZ"; return "SFZ";
} }


@@ -437,14 +437,14 @@ PluginType getPluginTypeFromString(const char* const ctype)
return PLUGIN_VST; return PLUGIN_VST;
if (stype == "au") if (stype == "au")
return PLUGIN_AU; return PLUGIN_AU;
if (stype == "csound")
return PLUGIN_CSOUND;
if (stype == "csd")
return PLUGIN_FILE_CSD;
if (stype == "gig") if (stype == "gig")
return PLUGIN_GIG;
return PLUGIN_FILE_GIG;
if (stype == "sf2") if (stype == "sf2")
return PLUGIN_SF2;
return PLUGIN_FILE_SF2;
if (stype == "sfz") if (stype == "sfz")
return PLUGIN_SFZ;
return PLUGIN_FILE_SFZ;


carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype); carla_stderr("CarlaBackend::getPluginTypeFromString(\"%s\") - invalid string type", ctype);
return PLUGIN_NONE; return PLUGIN_NONE;


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

@@ -85,7 +85,7 @@ struct BridgeShmControl {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type)
const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type) noexcept
{ {
switch (type) switch (type)
{ {
@@ -136,7 +136,7 @@ const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type)
} }


static inline static inline
const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode)
const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode) noexcept
{ {
switch (opcode) switch (opcode)
{ {


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

@@ -88,7 +88,7 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o
// Check if 2 ports match types // Check if 2 ports match types


static inline static inline
bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDescriptor port2)
bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDescriptor port2) noexcept
{ {
if (port1 == 0x0 || port2 == 0x0) if (port1 == 0x0 || port2 == 0x0)
return false; return false;
@@ -107,7 +107,7 @@ bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDes
// Check if rdf data matches descriptor // Check if rdf data matches descriptor


static inline static inline
bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescriptor, const LADSPA_Descriptor* const descriptor)
bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescriptor, const LADSPA_Descriptor* const descriptor) noexcept
{ {
if (rdfDescriptor == nullptr || descriptor == nullptr) if (rdfDescriptor == nullptr || descriptor == nullptr)
return false; return false;
@@ -140,7 +140,7 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri
// Get default control port value // Get default control port value


static inline static inline
LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor hintDescriptor, const LADSPA_Data min, const LADSPA_Data max)
LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor hintDescriptor, const LADSPA_Data min, const LADSPA_Data max) noexcept
{ {
if (LADSPA_IS_HINT_HAS_DEFAULT(hintDescriptor)) if (LADSPA_IS_HINT_HAS_DEFAULT(hintDescriptor))
{ {


+ 70
- 72
source/utils/CarlaOscUtils.hpp View File

@@ -22,6 +22,11 @@


#include <lo/lo.h> #include <lo/lo.h>


#define try_lo_send(...) \
try { \
lo_send(__VA_ARGS__); \
} catch(...) {}

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


struct CarlaOscData { struct CarlaOscData {
@@ -66,24 +71,24 @@ struct CarlaOscData {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static inline static inline
void osc_send_configure(const CarlaOscData& oscData, const char* const key, const char* const value)
void osc_send_configure(const CarlaOscData& oscData, const char* const key, const char* const value) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(key != nullptr,);
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(value != nullptr,); CARLA_SAFE_ASSERT_RETURN(value != nullptr,);
carla_debug("osc_send_configure(path:\"%s\", \"%s\", \"%s\")", oscData.path, key, value); carla_debug("osc_send_configure(path:\"%s\", \"%s\", \"%s\")", oscData.path, key, value);


char targetPath[std::strlen(oscData.path)+11]; char targetPath[std::strlen(oscData.path)+11];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/configure"); std::strcat(targetPath, "/configure");
lo_send(oscData.target, targetPath, "ss", key, value);
try_lo_send(oscData.target, targetPath, "ss", key, value);
} }


static inline static inline
void osc_send_control(const CarlaOscData& oscData, const int32_t index, const float value)
void osc_send_control(const CarlaOscData& oscData, const int32_t index, const float value) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index != -1,); // -1 == PARAMETER_NULL CARLA_SAFE_ASSERT_RETURN(index != -1,); // -1 == PARAMETER_NULL
carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData.path, index, value); carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData.path, index, value);
@@ -91,86 +96,80 @@ void osc_send_control(const CarlaOscData& oscData, const int32_t index, const fl
char targetPath[std::strlen(oscData.path)+9]; char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/control"); std::strcat(targetPath, "/control");
lo_send(oscData.target, targetPath, "if", index, value);
try_lo_send(oscData.target, targetPath, "if", index, value);
} }


static inline static inline
void osc_send_program(const CarlaOscData& oscData, const int32_t index)
void osc_send_program(const CarlaOscData& oscData, const uint32_t index) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index >= 0,);
carla_debug("osc_send_program(path:\"%s\", %i)", oscData.path, index);
carla_debug("osc_send_program(path:\"%s\", %u)", oscData.path, index);


char targetPath[std::strlen(oscData.path)+9]; char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program"); std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "i", index);
try_lo_send(oscData.target, targetPath, "i", static_cast<int32_t>(index));
} }


static inline static inline
void osc_send_program(const CarlaOscData& oscData, const int32_t bank, const int32_t program)
void osc_send_program(const CarlaOscData& oscData, const uint32_t bank, const uint32_t program) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(program >= 0,);
CARLA_SAFE_ASSERT_RETURN(bank >= 0,);
carla_debug("osc_send_program(path:\"%s\", %i, %i)", oscData.path, bank, program);
carla_debug("osc_send_program(path:\"%s\", %u, %u)", oscData.path, bank, program);


char targetPath[std::strlen(oscData.path)+9]; char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program"); std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "ii", bank, program);
try_lo_send(oscData.target, targetPath, "ii", static_cast<int32_t>(bank), static_cast<int32_t>(program));
} }


static inline static inline
void osc_send_midi_program(const CarlaOscData& oscData, const int32_t index)
void osc_send_midi_program(const CarlaOscData& oscData, const uint32_t index) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index >= 0,);
carla_debug("osc_send_midi_program(path:\"%s\", %i)", oscData.path, index);
carla_debug("osc_send_midi_program(path:\"%s\", %u)", oscData.path, index);


char targetPath[std::strlen(oscData.path)+14]; char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program"); std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "i", index);
try_lo_send(oscData.target, targetPath, "i", static_cast<int32_t>(index));
} }


static inline static inline
void osc_send_midi_program(const CarlaOscData& oscData, const int32_t bank, const int32_t program)
void osc_send_midi_program(const CarlaOscData& oscData, const uint32_t bank, const uint32_t program) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(program >= 0,);
CARLA_SAFE_ASSERT_RETURN(bank >= 0,);
carla_debug("osc_send_midi_program(path:\"%s\", %i, %i)", oscData.path, bank, program);
carla_debug("osc_send_midi_program(path:\"%s\", %u, %u)", oscData.path, bank, program);


char targetPath[std::strlen(oscData.path)+14]; char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program"); std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "ii", bank, program);
try_lo_send(oscData.target, targetPath, "ii", static_cast<int32_t>(bank), static_cast<int32_t>(program));
} }


static inline static inline
void osc_send_midi(const CarlaOscData& oscData, const uint8_t buf[4])
void osc_send_midi(const CarlaOscData& oscData, const uint8_t buf[4]) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(buf[0] == 0,); CARLA_SAFE_ASSERT_RETURN(buf[0] == 0,);
CARLA_SAFE_ASSERT_RETURN(buf[1] != 0,); CARLA_SAFE_ASSERT_RETURN(buf[1] != 0,);
carla_debug("osc_send_midi(path:\"%s\", port:%u, [0x%X, %03u, %03u])", oscData.path, buf[0], buf[1], buf[2], buf[3]);
carla_debug("osc_send_midi(path:\"%s\", port:%u, {0x%X, %03u, %03u})", oscData.path, buf[0], buf[1], buf[2], buf[3]);


char targetPath[std::strlen(oscData.path)+6]; char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi"); std::strcat(targetPath, "/midi");
lo_send(oscData.target, targetPath, "m", buf);
try_lo_send(oscData.target, targetPath, "m", buf);
} }


static inline static inline
void osc_send_sample_rate(const CarlaOscData& oscData, const float sampleRate)
void osc_send_sample_rate(const CarlaOscData& oscData, const float sampleRate) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(sampleRate > 0.0f,); CARLA_SAFE_ASSERT_RETURN(sampleRate > 0.0f,);
carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData.path, sampleRate); carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData.path, sampleRate);
@@ -178,138 +177,137 @@ void osc_send_sample_rate(const CarlaOscData& oscData, const float sampleRate)
char targetPath[std::strlen(oscData.path)+13]; char targetPath[std::strlen(oscData.path)+13];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/sample-rate"); std::strcat(targetPath, "/sample-rate");
lo_send(oscData.target, targetPath, "f", sampleRate);
try_lo_send(oscData.target, targetPath, "f", sampleRate);
} }


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
static inline static inline
void osc_send_update(const CarlaOscData& oscData, const char* const url)
void osc_send_update(const CarlaOscData& oscData, const char* const url) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr && url[0] != '\0',);
carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData.path, url); carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData.path, url);


char targetPath[std::strlen(oscData.path)+8]; char targetPath[std::strlen(oscData.path)+8];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/update"); std::strcat(targetPath, "/update");
lo_send(oscData.target, targetPath, "s", url);
try_lo_send(oscData.target, targetPath, "s", url);
} }


static inline static inline
void osc_send_exiting(const CarlaOscData& oscData)
void osc_send_exiting(const CarlaOscData& oscData) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
carla_debug("osc_send_exiting(path:\"%s\")", oscData.path); carla_debug("osc_send_exiting(path:\"%s\")", oscData.path);


char targetPath[std::strlen(oscData.path)+9]; char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/exiting"); std::strcat(targetPath, "/exiting");
lo_send(oscData.target, targetPath, "");
try_lo_send(oscData.target, targetPath, "");
} }
#endif #endif


static inline static inline
void osc_send_show(const CarlaOscData& oscData)
void osc_send_show(const CarlaOscData& oscData) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
carla_debug("osc_send_show(path:\"%s\")", oscData.path); carla_debug("osc_send_show(path:\"%s\")", oscData.path);


char targetPath[std::strlen(oscData.path)+6]; char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/show"); std::strcat(targetPath, "/show");
lo_send(oscData.target, targetPath, "");
try_lo_send(oscData.target, targetPath, "");
} }


static inline static inline
void osc_send_hide(const CarlaOscData& oscData)
void osc_send_hide(const CarlaOscData& oscData) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
carla_debug("osc_send_hide(path:\"%s\")", oscData.path); carla_debug("osc_send_hide(path:\"%s\")", oscData.path);


char targetPath[std::strlen(oscData.path)+6]; char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/hide"); std::strcat(targetPath, "/hide");
lo_send(oscData.target, targetPath, "");
try_lo_send(oscData.target, targetPath, "");
} }


static inline static inline
void osc_send_quit(const CarlaOscData& oscData)
void osc_send_quit(const CarlaOscData& oscData) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
carla_debug("osc_send_quit(path:\"%s\")", oscData.path); carla_debug("osc_send_quit(path:\"%s\")", oscData.path);


char targetPath[std::strlen(oscData.path)+6]; char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/quit"); std::strcat(targetPath, "/quit");
lo_send(oscData.target, targetPath, "");
try_lo_send(oscData.target, targetPath, "");
} }


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


#ifdef BUILD_BRIDGE_PLUGIN #ifdef BUILD_BRIDGE_PLUGIN
static inline static inline
void osc_send_bridge_update(const CarlaOscData& oscData, const char* const url)
void osc_send_bridge_update(const CarlaOscData& oscData, const char* const url) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr && url[0] != '\0',);
carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData.path, url); carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData.path, url);


char targetPath[std::strlen(oscData.path)+15]; char targetPath[std::strlen(oscData.path)+15];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/bridge_update"); std::strcat(targetPath, "/bridge_update");
lo_send(oscData.target, targetPath, "s", url);
try_lo_send(oscData.target, targetPath, "s", url);
} }


static inline static inline
void osc_send_bridge_error(const CarlaOscData& oscData, const char* const error)
void osc_send_bridge_error(const CarlaOscData& oscData, const char* const error) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(error != nullptr,);
CARLA_SAFE_ASSERT_RETURN(error != nullptr && error[0] != '\0',);
carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData.path, error); carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData.path, error);


char targetPath[std::strlen(oscData.path)+14]; char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/bridge_error"); std::strcat(targetPath, "/bridge_error");
lo_send(oscData.target, targetPath, "s", error);
try_lo_send(oscData.target, targetPath, "s", error);
} }
#endif #endif


#if defined(BRIDGE_LV2) || defined(WANT_LV2) #if defined(BRIDGE_LV2) || defined(WANT_LV2)
static inline static inline
void osc_send_lv2_atom_transfer(const CarlaOscData& oscData, const int32_t portIndex, const char* const atomBuf)
void osc_send_lv2_atom_transfer(const CarlaOscData& oscData, const uint32_t portIndex, const char* const atomBuf) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(portIndex >= 0,);
CARLA_SAFE_ASSERT_RETURN(atomBuf != nullptr,);
carla_debug("osc_send_lv2_atom_transfer(path:\"%s\", %i, <atomBuf:%p>)", oscData.path, portIndex, atomBuf);
CARLA_SAFE_ASSERT_RETURN(atomBuf != nullptr && atomBuf[0] != '\0',);
carla_debug("osc_send_lv2_atom_transfer(path:\"%s\", %u, <atomBuf:%p>)", oscData.path, portIndex, atomBuf);


char targetPath[std::strlen(oscData.path)+19]; char targetPath[std::strlen(oscData.path)+19];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_atom_transfer"); std::strcat(targetPath, "/lv2_atom_transfer");
lo_send(oscData.target, targetPath, "is", portIndex, atomBuf);
try_lo_send(oscData.target, targetPath, "is", static_cast<int32_t>(portIndex), atomBuf);
} }


static inline static inline
void osc_send_lv2_urid_map(const CarlaOscData& oscData, const uint32_t urid, const char* const uri)
void osc_send_lv2_urid_map(const CarlaOscData& oscData, const uint32_t urid, const char* const uri) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(urid > 0,);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr,);
carla_debug("osc_send_lv2_urid_map(path:\"%s\", %i, \"%s\")", oscData.path, urid, uri);
CARLA_SAFE_ASSERT_RETURN(urid != 0,);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',);
carla_debug("osc_send_lv2_urid_map(path:\"%s\", %u, \"%s\")", oscData.path, urid, uri);


char targetPath[std::strlen(oscData.path)+14]; char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path); std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_urid_map"); std::strcat(targetPath, "/lv2_urid_map");
lo_send(oscData.target, targetPath, "is", urid, uri);
try_lo_send(oscData.target, targetPath, "is", static_cast<int32_t>(urid), uri);
} }
#endif #endif




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

@@ -40,14 +40,14 @@ struct RingBuffer {
class RingBufferControl class RingBufferControl
{ {
public: public:
RingBufferControl(RingBuffer* const ringBuf)
RingBufferControl(RingBuffer* const ringBuf) noexcept
: fRingBuf(ringBuf) : fRingBuf(ringBuf)
{ {
if (ringBuf != nullptr) if (ringBuf != nullptr)
clear(); clear();
} }


void clear()
void clear() noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,); CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,);


@@ -58,10 +58,10 @@ public:
carla_zeroChar(fRingBuf->buf, RING_BUFFER_SIZE); carla_zeroChar(fRingBuf->buf, RING_BUFFER_SIZE);
} }


void setRingBuffer(RingBuffer* const ringBuf, const bool reset)
void setRingBuffer(RingBuffer* const ringBuf, const bool reset) noexcept
{ {
CARLA_ASSERT(ringBuf != nullptr);
CARLA_ASSERT(ringBuf != fRingBuf);
CARLA_SAFE_ASSERT_RETURN(ringBuf != nullptr,);
CARLA_SAFE_ASSERT_RETURN(ringBuf != fRingBuf,);


fRingBuf = ringBuf; fRingBuf = ringBuf;


@@ -71,7 +71,7 @@ public:


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


bool commitWrite()
bool commitWrite() noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr, false); CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr, false);


@@ -88,7 +88,7 @@ public:
} }
} }


bool isDataAvailable() const
bool isDataAvailable() const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr, false); CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr, false);




+ 12
- 12
source/utils/CarlaString.hpp View File

@@ -243,7 +243,7 @@ public:
/* /*
* Check if the string starts with the character 'c'. * Check if the string starts with the character 'c'.
*/ */
bool startsWith(const char c) const
bool startsWith(const char c) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(c != '\0', false); CARLA_SAFE_ASSERT_RETURN(c != '\0', false);


@@ -253,7 +253,7 @@ public:
/* /*
* Check if the string starts with the string 'prefix'. * Check if the string starts with the string 'prefix'.
*/ */
bool startsWith(const char* const prefix) const
bool startsWith(const char* const prefix) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(prefix != nullptr, false); CARLA_SAFE_ASSERT_RETURN(prefix != nullptr, false);


@@ -268,7 +268,7 @@ public:
/* /*
* Check if the string ends with the character 'c'. * Check if the string ends with the character 'c'.
*/ */
bool endsWith(const char c) const
bool endsWith(const char c) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(c != '\0', false); CARLA_SAFE_ASSERT_RETURN(c != '\0', false);


@@ -278,7 +278,7 @@ public:
/* /*
* Check if the string ends with the string 'suffix'. * Check if the string ends with the string 'suffix'.
*/ */
bool endsWith(const char* const suffix) const
bool endsWith(const char* const suffix) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(suffix != nullptr, false); CARLA_SAFE_ASSERT_RETURN(suffix != nullptr, false);


@@ -322,7 +322,7 @@ public:
* Find the first occurrence of string 'strBuf' in the string. * Find the first occurrence of string 'strBuf' in the string.
* Returns "length()" if the string is not found. * Returns "length()" if the string is not found.
*/ */
size_t find(const char* const strBuf, bool* const found = nullptr) const
size_t find(const char* const strBuf, bool* const found = nullptr) const noexcept
{ {
if (fBufferLen == 0 || strBuf == nullptr || strBuf[0] == '\0') if (fBufferLen == 0 || strBuf == nullptr || strBuf[0] == '\0')
{ {
@@ -387,7 +387,7 @@ public:
* Find the last occurrence of string 'strBuf' in the string. * Find the last occurrence of string 'strBuf' in the string.
* Returns "length()" if the string is not found. * Returns "length()" if the string is not found.
*/ */
size_t rfind(const char* const strBuf, bool* const found = nullptr) const
size_t rfind(const char* const strBuf, bool* const found = nullptr) const noexcept
{ {
if (found != nullptr) if (found != nullptr)
*found = false; *found = false;
@@ -427,7 +427,7 @@ public:
/* /*
* Replace all occurrences of character 'before' with character 'after'. * Replace all occurrences of character 'before' with character 'after'.
*/ */
void replace(const char before, const char after)
void replace(const char before, const char after) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(before != '\0' && after != '\0',); CARLA_SAFE_ASSERT_RETURN(before != '\0' && after != '\0',);


@@ -513,7 +513,7 @@ public:
/* /*
* Direct access to the string buffer. * Direct access to the string buffer.
*/ */
const char* getBuffer() const
const char* getBuffer() const noexcept
{ {
return fBuffer; return fBuffer;
} }
@@ -537,22 +537,22 @@ public:
return rfallback; return rfallback;
} }


bool operator==(const char* const strBuf) const
bool operator==(const char* const strBuf) const noexcept
{ {
return (strBuf != nullptr && std::strcmp(fBuffer, strBuf) == 0); return (strBuf != nullptr && std::strcmp(fBuffer, strBuf) == 0);
} }


bool operator==(const CarlaString& str) const
bool operator==(const CarlaString& str) const noexcept
{ {
return operator==(str.fBuffer); return operator==(str.fBuffer);
} }


bool operator!=(const char* const strBuf) const
bool operator!=(const char* const strBuf) const noexcept
{ {
return !operator==(strBuf); return !operator==(strBuf);
} }


bool operator!=(const CarlaString& str) const
bool operator!=(const CarlaString& str) const noexcept
{ {
return !operator==(str.fBuffer); return !operator==(str.fBuffer);
} }


+ 35
- 24
source/utils/CarlaUtils.hpp View File

@@ -68,14 +68,16 @@ void pass() noexcept {}
# define carla_debug(...) # define carla_debug(...)
#else #else
static inline static inline
void carla_debug(const char* const fmt, ...)
void carla_debug(const char* const fmt, ...) noexcept
{ {
try {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
std::fprintf(stdout, "\x1b[30;1m"); std::fprintf(stdout, "\x1b[30;1m");
std::vfprintf(stdout, fmt, args); std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\x1b[0m\n"); std::fprintf(stdout, "\x1b[0m\n");
va_end(args); va_end(args);
} catch (...) {}
} }
#endif #endif


@@ -83,40 +85,46 @@ void carla_debug(const char* const fmt, ...)
* Print a string to stdout with newline. * Print a string to stdout with newline.
*/ */
static inline static inline
void carla_stdout(const char* const fmt, ...)
void carla_stdout(const char* const fmt, ...) noexcept
{ {
try {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
std::vfprintf(stdout, fmt, args); std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\n"); std::fprintf(stdout, "\n");
va_end(args); va_end(args);
} catch (...) {}
} }


/* /*
* Print a string to stderr with newline. * Print a string to stderr with newline.
*/ */
static inline static inline
void carla_stderr(const char* const fmt, ...)
void carla_stderr(const char* const fmt, ...) noexcept
{ {
try {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
std::vfprintf(stderr, fmt, args); std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\n"); std::fprintf(stderr, "\n");
va_end(args); va_end(args);
} catch (...) {}
} }


/* /*
* Print a string to stderr with newline (red color). * Print a string to stderr with newline (red color).
*/ */
static inline static inline
void carla_stderr2(const char* const fmt, ...)
void carla_stderr2(const char* const fmt, ...) noexcept
{ {
try {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
std::fprintf(stderr, "\x1b[31m"); std::fprintf(stderr, "\x1b[31m");
std::vfprintf(stderr, fmt, args); std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\x1b[0m\n"); std::fprintf(stderr, "\x1b[0m\n");
va_end(args); va_end(args);
} catch (...) {}
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -126,7 +134,7 @@ void carla_stderr2(const char* const fmt, ...)
* Print a safe assertion error message. * Print a safe assertion error message.
*/ */
static inline static inline
void carla_safe_assert(const char* const assertion, const char* const file, const int line)
void carla_safe_assert(const char* const assertion, const char* const file, const int line) noexcept
{ {
carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i", assertion, file, line); carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i", assertion, file, line);
} }
@@ -135,7 +143,7 @@ void carla_safe_assert(const char* const assertion, const char* const file, cons
* Print a safe assertion error message, with 1 extra integer value. * Print a safe assertion error message, with 1 extra integer value.
*/ */
static inline static inline
void carla_safe_assert_int(const char* const assertion, const char* const file, const int line, const int value)
void carla_safe_assert_int(const char* const assertion, const char* const file, const int line, const int value) noexcept
{ {
carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i, value %i", assertion, file, line, value); carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i, value %i", assertion, file, line, value);
} }
@@ -144,7 +152,7 @@ void carla_safe_assert_int(const char* const assertion, const char* const file,
* Print a safe assertion error message, with 2 extra integer values. * Print a safe assertion error message, with 2 extra integer values.
*/ */
static inline static inline
void carla_safe_assert_int2(const char* const assertion, const char* const file, const int line, const int v1, const int v2)
void carla_safe_assert_int2(const char* const assertion, const char* const file, const int line, const int v1, const int v2) noexcept
{ {
carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i, v1 %i, v2 %i", assertion, file, line, v1, v2); carla_stderr2("Carla assertion failure: \"%s\" in file %s, line %i, v1 %i, v2 %i", assertion, file, line, v1, v2);
} }
@@ -189,9 +197,9 @@ void carla_msleep(const unsigned int msecs)
* Set environment variable 'key' to 'value'. * Set environment variable 'key' to 'value'.
*/ */
static inline static inline
void carla_setenv(const char* const key, const char* const value)
void carla_setenv(const char* const key, const char* const value) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(key != nullptr,);
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(value != nullptr,); CARLA_SAFE_ASSERT_RETURN(value != nullptr,);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
@@ -265,7 +273,7 @@ const T& carla_max(const T& v1, const T& v2, const T& max) noexcept
*/ */
template<typename T> template<typename T>
static inline static inline
const T& carla_fixValue(const T& min, const T& max, const T& value)
const T& carla_fixValue(const T& min, const T& max, const T& value) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(max > min, max); CARLA_SAFE_ASSERT_RETURN(max > min, max);


@@ -281,7 +289,7 @@ const T& carla_fixValue(const T& min, const T& max, const T& value)
*/ */
template<typename T> template<typename T>
static inline static inline
void carla_add(T* dataDst, T* dataSrc, const size_t size)
void carla_add(T* dataDst, T* dataSrc, const size_t size) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -296,7 +304,7 @@ void carla_add(T* dataDst, T* dataSrc, const size_t size)
*/ */
template<typename T> template<typename T>
static inline static inline
void carla_add(T* dataDst, const T* dataSrc, const size_t size)
void carla_add(T* dataDst, const T* dataSrc, const size_t size) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -311,7 +319,7 @@ void carla_add(T* dataDst, const T* dataSrc, const size_t size)
*/ */
template<typename T> template<typename T>
static inline static inline
void carla_copy(T* dataDst, T* dataSrc, const size_t size)
void carla_copy(T* dataDst, T* dataSrc, const size_t size) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -326,7 +334,7 @@ void carla_copy(T* dataDst, T* dataSrc, const size_t size)
*/ */
template<typename T> template<typename T>
static inline static inline
void carla_copy(T* dataDst, const T* dataSrc, const size_t size)
void carla_copy(T* dataDst, const T* dataSrc, const size_t size) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -341,7 +349,7 @@ void carla_copy(T* dataDst, const T* dataSrc, const size_t size)
*/ */
template<typename T> template<typename T>
static inline static inline
void carla_fill(T* data, const size_t size, const T v)
void carla_fill(T* data, const size_t size, const T v) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(data != nullptr,); CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size > 0,); CARLA_SAFE_ASSERT_RETURN(size > 0,);
@@ -357,7 +365,7 @@ void carla_fill(T* data, const size_t size, const T v)
* Add float array values to another float array. * Add float array values to another float array.
*/ */
static inline static inline
void carla_addFloat(float* dataDst, float* dataSrc, const size_t numSamples)
void carla_addFloat(float* dataDst, float* dataSrc, const size_t numSamples) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -371,7 +379,7 @@ void carla_addFloat(float* dataDst, float* dataSrc, const size_t numSamples)
* Copy float array values to another float array. * Copy float array values to another float array.
*/ */
static inline static inline
void carla_copyFloat(float* const dataDst, float* const dataSrc, const size_t numSamples)
void carla_copyFloat(float* const dataDst, float* const dataSrc, const size_t numSamples) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
@@ -405,7 +413,7 @@ inline float
*/ */
template<typename C = char> template<typename C = char>
static inline static inline
void carla_zeroChar(C* const data, const size_t numChars)
void carla_zeroChar(C* const data, const size_t numChars) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(data != nullptr,); CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(numChars > 0,); CARLA_SAFE_ASSERT_RETURN(numChars > 0,);
@@ -417,8 +425,11 @@ void carla_zeroChar(C* const data, const size_t numChars)
* Clear a float array. * Clear a float array.
*/ */
static inline static inline
void carla_zeroFloat(float* const data, const size_t numSamples)
void carla_zeroFloat(float* const data, const size_t numSamples) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(numSamples > 0,);

std::memset(data, 0, numSamples*sizeof(float)); std::memset(data, 0, numSamples*sizeof(float));
} }


@@ -426,7 +437,7 @@ void carla_zeroFloat(float* const data, const size_t numSamples)
* Clear a memory location. * Clear a memory location.
*/ */
static inline static inline
void carla_zeroMem(void* const memory, const size_t numBytes)
void carla_zeroMem(void* const memory, const size_t numBytes) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(memory != nullptr,); CARLA_SAFE_ASSERT_RETURN(memory != nullptr,);
CARLA_SAFE_ASSERT_RETURN(numBytes > 0,); CARLA_SAFE_ASSERT_RETURN(numBytes > 0,);
@@ -439,7 +450,7 @@ void carla_zeroMem(void* const memory, const size_t numBytes)
*/ */
template <typename T> template <typename T>
static inline static inline
void carla_zeroStruct(T& structure)
void carla_zeroStruct(T& structure) noexcept
{ {
std::memset(&structure, 0, sizeof(T)); std::memset(&structure, 0, sizeof(T));
} }
@@ -449,7 +460,7 @@ void carla_zeroStruct(T& structure)
*/ */
template <typename T> template <typename T>
static inline static inline
void carla_zeroStruct(T* const structure, const size_t count)
void carla_zeroStruct(T* const structure, const size_t count) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(structure != nullptr,); CARLA_SAFE_ASSERT_RETURN(structure != nullptr,);
CARLA_SAFE_ASSERT_RETURN(count > 0,); CARLA_SAFE_ASSERT_RETURN(count > 0,);
@@ -462,7 +473,7 @@ void carla_zeroStruct(T* const structure, const size_t count)
*/ */
template <typename T> template <typename T>
static inline static inline
void carla_copyStruct(T& struct1, T& struct2)
void carla_copyStruct(T& struct1, T& struct2) noexcept
{ {
std::memcpy(&struct1, &struct2, sizeof(T)); std::memcpy(&struct1, &struct2, sizeof(T));
} }
@@ -472,7 +483,7 @@ void carla_copyStruct(T& struct1, T& struct2)
*/ */
template <typename T> template <typename T>
static inline static inline
void carla_copyStruct(T* const struct1, T* const struct2, const size_t count)
void carla_copyStruct(T* const struct1, T* const struct2, const size_t count) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(struct1 != nullptr,); CARLA_SAFE_ASSERT_RETURN(struct1 != nullptr,);
CARLA_SAFE_ASSERT_RETURN(struct2 != nullptr,); CARLA_SAFE_ASSERT_RETURN(struct2 != nullptr,);


Loading…
Cancel
Save