Browse Source

More of the same

tags/1.9.4
falkTX 12 years ago
parent
commit
0cfe461da5
11 changed files with 289 additions and 260 deletions
  1. +10
    -2
      source/modules/utils/CarlaBackendUtils.hpp
  2. +2
    -0
      source/modules/utils/CarlaBridgeUtils.hpp
  3. +29
    -43
      source/modules/utils/CarlaLadspaUtils.hpp
  4. +9
    -16
      source/modules/utils/CarlaLibUtils.hpp
  5. +1
    -1
      source/modules/utils/CarlaLv2Utils.hpp
  6. +125
    -157
      source/modules/utils/CarlaOscUtils.hpp
  7. +4
    -2
      source/modules/utils/CarlaShmUtils.hpp
  8. +45
    -18
      source/modules/utils/CarlaStateUtils.hpp
  9. +8
    -6
      source/modules/utils/CarlaVstUtils.hpp
  10. +4
    -5
      source/modules/utils/RtList.hpp
  11. +52
    -10
      source/tests/ANSI.cpp

+ 10
- 2
source/modules/utils/CarlaBackendUtils.hpp View File

@@ -96,6 +96,8 @@ const char* PluginType2Str(const PluginType type)
return "PLUGIN_VST"; return "PLUGIN_VST";
case PLUGIN_VST3: case PLUGIN_VST3:
return "PLUGIN_VST3"; return "PLUGIN_VST3";
case PLUGIN_AU:
return "PLUGIN_AU";
case PLUGIN_GIG: case PLUGIN_GIG:
return "PLUGIN_GIG"; return "PLUGIN_GIG";
case PLUGIN_SF2: case PLUGIN_SF2:
@@ -402,7 +404,7 @@ const char* TransportMode2Str(const TransportMode mode)
static inline static inline
uintptr_t getAddressFromPointer(void* ptr) uintptr_t getAddressFromPointer(void* ptr)
{ {
CARLA_ASSERT(ptr != nullptr);
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0);


uintptr_t* const addr((uintptr_t*)&ptr); uintptr_t* const addr((uintptr_t*)&ptr);
return *addr; return *addr;
@@ -412,7 +414,7 @@ template<typename T>
static inline static inline
T* getPointerFromAddress(uintptr_t& addr) T* getPointerFromAddress(uintptr_t& addr)
{ {
CARLA_ASSERT(addr != 0);
CARLA_SAFE_ASSERT_RETURN(addr != 0, nullptr);


T** const ptr((T**)&addr); T** const ptr((T**)&addr);
return *ptr; return *ptr;
@@ -441,6 +443,8 @@ const char* getPluginTypeAsString(const PluginType type)
return "VST"; return "VST";
case PLUGIN_VST3: case PLUGIN_VST3:
return "VST3"; return "VST3";
case PLUGIN_AU:
return "AU";
case PLUGIN_GIG: case PLUGIN_GIG:
return "GIG"; return "GIG";
case PLUGIN_SF2: case PLUGIN_SF2:
@@ -479,6 +483,8 @@ PluginType getPluginTypeFromString(const char* const stype)
return PLUGIN_VST; return PLUGIN_VST;
if (std::strcmp(stype, "VST3") == 0) if (std::strcmp(stype, "VST3") == 0)
return PLUGIN_VST3; return PLUGIN_VST3;
if (std::strcmp(stype, "AU") == 0)
return PLUGIN_AU;
if (std::strcmp(stype, "GIG") == 0) if (std::strcmp(stype, "GIG") == 0)
return PLUGIN_GIG; return PLUGIN_GIG;
if (std::strcmp(stype, "SF2") == 0) if (std::strcmp(stype, "SF2") == 0)
@@ -574,6 +580,8 @@ PluginCategory getPluginCategoryFromName(const char* const name)
return PLUGIN_CATEGORY_NONE; return PLUGIN_CATEGORY_NONE;
} }


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

CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


#endif // CARLA_BACKEND_UTILS_HPP_INCLUDED #endif // CARLA_BACKEND_UTILS_HPP_INCLUDED

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

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


#include "CarlaRingBuffer.hpp" #include "CarlaRingBuffer.hpp"


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

enum PluginBridgeInfoType { enum PluginBridgeInfoType {
kPluginBridgeAudioCount = 0, kPluginBridgeAudioCount = 0,
kPluginBridgeMidiCount, kPluginBridgeMidiCount,


+ 29
- 43
source/modules/utils/CarlaLadspaUtils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_LADSPA_UTILS_HPP_INCLUDED #ifndef CARLA_LADSPA_UTILS_HPP_INCLUDED
@@ -31,10 +31,7 @@
static inline static inline
const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const oldDescriptor) const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const oldDescriptor)
{ {
CARLA_ASSERT(oldDescriptor != nullptr);

if (oldDescriptor == nullptr)
return nullptr;
CARLA_SAFE_ASSERT_RETURN(oldDescriptor != nullptr, nullptr);


LADSPA_RDF_Descriptor* const newDescriptor(new LADSPA_RDF_Descriptor()); LADSPA_RDF_Descriptor* const newDescriptor(new LADSPA_RDF_Descriptor());


@@ -143,66 +140,55 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri
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)
{ {
LADSPA_Data def;

if (LADSPA_IS_HINT_HAS_DEFAULT(hintDescriptor)) if (LADSPA_IS_HINT_HAS_DEFAULT(hintDescriptor))
{ {
switch (hintDescriptor & LADSPA_HINT_DEFAULT_MASK) switch (hintDescriptor & LADSPA_HINT_DEFAULT_MASK)
{ {
case LADSPA_HINT_DEFAULT_MINIMUM: case LADSPA_HINT_DEFAULT_MINIMUM:
def = min;
break;
return min;
case LADSPA_HINT_DEFAULT_MAXIMUM: case LADSPA_HINT_DEFAULT_MAXIMUM:
def = max;
break;
return max;
case LADSPA_HINT_DEFAULT_0: case LADSPA_HINT_DEFAULT_0:
def = 0.0f;
break;
return 0.0f;
case LADSPA_HINT_DEFAULT_1: case LADSPA_HINT_DEFAULT_1:
def = 1.0f;
break;
return 1.0f;
case LADSPA_HINT_DEFAULT_100: case LADSPA_HINT_DEFAULT_100:
def = 100.0f;
break;
return 100.0f;
case LADSPA_HINT_DEFAULT_440: case LADSPA_HINT_DEFAULT_440:
def = 440.0f;
break;
return 440.0f;
case LADSPA_HINT_DEFAULT_LOW: case LADSPA_HINT_DEFAULT_LOW:
if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor)) if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor))
def = std::exp((std::log(min)*0.75f) + (std::log(max)*0.25f));
return std::exp((std::log(min)*0.75f) + (std::log(max)*0.25f));
else else
def = (min*0.75f) + (max*0.25f);
break;
return (min*0.75f) + (max*0.25f);
case LADSPA_HINT_DEFAULT_MIDDLE: case LADSPA_HINT_DEFAULT_MIDDLE:
if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor)) if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor))
def = std::sqrt(min*max);
return std::sqrt(min*max);
else else
def = (min+max)/2;
break;
return (min+max)/2;
case LADSPA_HINT_DEFAULT_HIGH: case LADSPA_HINT_DEFAULT_HIGH:
if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor)) if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor))
def = std::exp((std::log(min)*0.25f) + (std::log(max)*0.75f));
else
def = (min*0.25f) + (max*0.75f);
break;
default:
if (min < 0.0f && max > 0.0f)
def = 0.0f;
return std::exp((std::log(min)*0.25f) + (std::log(max)*0.75f));
else else
def = min;
break;
return (min*0.25f) + (max*0.75f);
} }
} }
else
{
// no default value
if (min < 0.0f && max > 0.0f)
def = 0.0f;
else
def = min;
}


return def;
// no default value
if (min < 0.0f && max > 0.0f)
return 0.0f;
else
return min;
} }


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

#endif // CARLA_LADSPA_UTILS_HPP_INCLUDED #endif // CARLA_LADSPA_UTILS_HPP_INCLUDED

+ 9
- 16
source/modules/utils/CarlaLibUtils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_LIB_UTILS_HPP_INCLUDED #ifndef CARLA_LIB_UTILS_HPP_INCLUDED
@@ -30,7 +30,7 @@
static inline static inline
void* lib_open(const char* const filename) void* lib_open(const char* const filename)
{ {
CARLA_ASSERT(filename != nullptr);
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
return (void*)LoadLibraryA(filename); return (void*)LoadLibraryA(filename);
@@ -42,10 +42,7 @@ void* lib_open(const char* const filename)
static inline static inline
bool lib_close(void* const lib) bool lib_close(void* const lib)
{ {
CARLA_ASSERT(lib != nullptr);

if (lib == nullptr)
return false;
CARLA_SAFE_ASSERT_RETURN(lib != nullptr, false);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
return FreeLibrary((HMODULE)lib); return FreeLibrary((HMODULE)lib);
@@ -57,11 +54,8 @@ bool lib_close(void* const lib)
static inline static inline
void* lib_symbol(void* const lib, const char* const symbol) void* lib_symbol(void* const lib, const char* const symbol)
{ {
CARLA_ASSERT(lib != nullptr);
CARLA_ASSERT(symbol != nullptr);

if (lib == nullptr && symbol == nullptr)
return nullptr;
CARLA_SAFE_ASSERT_RETURN(lib != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(symbol != nullptr, nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
return (void*)GetProcAddress((HMODULE)lib, symbol); return (void*)GetProcAddress((HMODULE)lib, symbol);
@@ -73,11 +67,11 @@ void* lib_symbol(void* const lib, const char* const symbol)
static inline static inline
const char* lib_error(const char* const filename) const char* lib_error(const char* const filename)
{ {
CARLA_ASSERT(filename != nullptr);
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
static char libError[2048+1]; static char libError[2048+1];
//carla_fill<char>(libError, 2048, '\0');
carla_zeroChar(libError, 2048);


LPVOID winErrorString; LPVOID winErrorString;
DWORD winErrorCode = GetLastError(); DWORD winErrorCode = GetLastError();
@@ -89,10 +83,9 @@ const char* lib_error(const char* const filename)
return libError; return libError;
#else #else
return dlerror(); return dlerror();

// unused
(void)filename;
#endif #endif
} }


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

#endif // CARLA_LIB_UTILS_HPP_INCLUDED #endif // CARLA_LIB_UTILS_HPP_INCLUDED

+ 1
- 1
source/modules/utils/CarlaLv2Utils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_LV2_UTILS_HPP_INCLUDED #ifndef CARLA_LV2_UTILS_HPP_INCLUDED


+ 125
- 157
source/modules/utils/CarlaOscUtils.hpp View File

@@ -68,211 +68,185 @@ 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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(key != nullptr);
CARLA_ASSERT(value != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(key != 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);


if (oscData.path != nullptr && oscData.target != nullptr && key != nullptr && value != nullptr)
{
char targetPath[std::strlen(oscData.path)+11];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/configure");
lo_send(oscData.target, targetPath, "ss", key, value);
}
char targetPath[std::strlen(oscData.path)+11];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/configure");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(index != -1); // -1 == PARAMETER_NULL
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
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);


if (oscData.path != nullptr && oscData.target != nullptr && index != -1)
{
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/control");
lo_send(oscData.target, targetPath, "if", index, value);
}
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/control");
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 int32_t index)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(index >= 0);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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\", %i)", oscData.path, index);


if (oscData.path != nullptr && oscData.target != nullptr && index >= 0)
{
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "i", index);
}
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "i", 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 int32_t bank, const int32_t program)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(program >= 0);
CARLA_ASSERT(bank >= 0);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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\", %i, %i)", oscData.path, bank, program);


if (oscData.path != nullptr && oscData.target != nullptr && bank >= 0 && program >= 0)
{
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "ii", bank, program);
}
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/program");
lo_send(oscData.target, targetPath, "ii", bank, 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 int32_t index)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(index >= 0);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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\", %i)", oscData.path, index);


if (oscData.path != nullptr && oscData.target != nullptr && index >= 0)
{
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "i", index);
}
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "i", 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 int32_t bank, const int32_t program)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(program >= 0);
CARLA_ASSERT(bank >= 0);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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\", %i, %i)", oscData.path, bank, program);


if (oscData.path != nullptr && oscData.target != nullptr && bank >= 0 && program >= 0)
{
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "ii", bank, program);
}
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi-program");
lo_send(oscData.target, targetPath, "ii", bank, 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])
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(buf[0] == 0);
CARLA_ASSERT(buf[1] != 0);
carla_debug("osc_send_midi(path:\"%s\", [0x%X, %03u, %03u])", oscData.path, buf[1], buf[2], buf[3]);

if (oscData.path != nullptr && oscData.target != nullptr && buf[0] == 0 && buf[1] != 0)
{
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi");
lo_send(oscData.target, targetPath, "m", buf);
}
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(buf[0] == 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]);

char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/midi");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(sampleRate > 0.0f);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
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);


if (oscData.path != nullptr && oscData.target != nullptr && sampleRate > 0.0f)
{
char targetPath[std::strlen(oscData.path)+13];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/sample-rate");
lo_send(oscData.target, targetPath, "f", sampleRate);
}
char targetPath[std::strlen(oscData.path)+13];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/sample-rate");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(url != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr,);
carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData.path, url); carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData.path, url);


if (oscData.path != nullptr && oscData.target != nullptr && url != nullptr)
{
char targetPath[std::strlen(oscData.path)+8];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/update");
lo_send(oscData.target, targetPath, "s", url);
}
char targetPath[std::strlen(oscData.path)+8];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/update");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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);


if (oscData.path != nullptr && oscData.target != nullptr)
{
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/exiting");
lo_send(oscData.target, targetPath, "");
}
char targetPath[std::strlen(oscData.path)+9];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/exiting");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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);


if (oscData.path != nullptr && oscData.target != nullptr)
{
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/show");
lo_send(oscData.target, targetPath, "");
}
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/show");
lo_send(oscData.target, targetPath, "");
} }


static inline static inline
void osc_send_hide(const CarlaOscData& oscData) void osc_send_hide(const CarlaOscData& oscData)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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);


if (oscData.path != nullptr && oscData.target != nullptr)
{
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/hide");
lo_send(oscData.target, targetPath, "");
}
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/hide");
lo_send(oscData.target, targetPath, "");
} }


static inline static inline
void osc_send_quit(const CarlaOscData& oscData) void osc_send_quit(const CarlaOscData& oscData)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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);


if (oscData.path != nullptr && oscData.target != nullptr)
{
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/quit");
lo_send(oscData.target, targetPath, "");
}
char targetPath[std::strlen(oscData.path)+6];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/quit");
lo_send(oscData.target, targetPath, "");
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -281,33 +255,29 @@ void osc_send_quit(const CarlaOscData& oscData)
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(url != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(url != nullptr,);
carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData.path, url); carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData.path, url);


if (oscData.path != nullptr && oscData.target != nullptr && url != nullptr)
{
char targetPath[std::strlen(oscData.path)+15];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/bridge_update");
lo_send(oscData.target, targetPath, "s", url);
}
char targetPath[std::strlen(oscData.path)+15];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/bridge_update");
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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(error != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr,);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(error != nullptr,);
carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData.path, error); carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData.path, error);


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


@@ -315,36 +285,34 @@ void osc_send_bridge_error(const CarlaOscData& oscData, const char* const error)
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 int32_t portIndex, const char* const atomBuf)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(portIndex >= 0);
CARLA_ASSERT(atomBuf != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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_debug("osc_send_lv2_atom_transfer(path:\"%s\", %i, <atomBuf:%p>)", oscData.path, portIndex, atomBuf);


if (oscData.path != nullptr && oscData.target != nullptr && portIndex >= 0 && atomBuf != nullptr)
{
char targetPath[std::strlen(oscData.path)+19];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_atom_transfer");
lo_send(oscData.target, targetPath, "is", portIndex, atomBuf);
}
char targetPath[std::strlen(oscData.path)+19];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_atom_transfer");
lo_send(oscData.target, targetPath, "is", 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)
{ {
CARLA_ASSERT(oscData.path != nullptr);
CARLA_ASSERT(urid > 0);
CARLA_ASSERT(uri != nullptr);
CARLA_SAFE_ASSERT_RETURN(oscData.path != 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_debug("osc_send_lv2_urid_map(path:\"%s\", %i, \"%s\")", oscData.path, urid, uri);


if (oscData.path != nullptr && oscData.target != nullptr && urid > 0 && uri != nullptr)
{
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_urid_map");
lo_send(oscData.target, targetPath, "is", urid, uri);
}
char targetPath[std::strlen(oscData.path)+14];
std::strcpy(targetPath, oscData.path);
std::strcat(targetPath, "/lv2_urid_map");
lo_send(oscData.target, targetPath, "is", urid, uri);
} }
#endif #endif


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

#endif // CARLA_OSC_UTILS_HPP_INCLUDED #endif // CARLA_OSC_UTILS_HPP_INCLUDED

+ 4
- 2
source/modules/utils/CarlaShmUtils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_SHM_UTILS_HPP_INCLUDED #ifndef CARLA_SHM_UTILS_HPP_INCLUDED
@@ -185,7 +185,7 @@ void carla_shm_unmap(shm_t& shm, void* const ptr, const size_t size)
#endif #endif
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// shared memory, templated calls // shared memory, templated calls


template<typename T> template<typename T>
@@ -204,4 +204,6 @@ void carla_shm_unmap(shm_t& shm, T*& value)
value = nullptr; value = nullptr;
} }


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

#endif // CARLA_SHM_UTILS_HPP_INCLUDED #endif // CARLA_SHM_UTILS_HPP_INCLUDED

+ 45
- 18
source/modules/utils/CarlaStateUtils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_STATE_UTILS_HPP_INCLUDED #ifndef CARLA_STATE_UTILS_HPP_INCLUDED
@@ -22,7 +22,13 @@
#include "CarlaMIDI.h" #include "CarlaMIDI.h"
#include "RtList.hpp" #include "RtList.hpp"


#include <QtXml/QDomNode>
#if 1
# include <QtXml/QDomNode>
#else
# include "juce_core/AppConfig.h"
# include "juce_core/juce_core.h"
using juce::String;
#endif


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


@@ -36,7 +42,7 @@ struct StateParameter {
uint8_t midiChannel; uint8_t midiChannel;
int16_t midiCC; int16_t midiCC;


StateParameter()
StateParameter() noexcept
: index(0), : index(0),
name(nullptr), name(nullptr),
symbol(nullptr), symbol(nullptr),
@@ -66,7 +72,7 @@ struct StateCustomData {
const char* key; const char* key;
const char* value; const char* value;


StateCustomData()
StateCustomData() noexcept
: type(nullptr), : type(nullptr),
key(nullptr), key(nullptr),
value(nullptr) {} value(nullptr) {}
@@ -123,7 +129,7 @@ struct SaveState {
StateParameterList parameters; StateParameterList parameters;
StateCustomDataList customData; StateCustomDataList customData;


SaveState()
SaveState() noexcept
: type(nullptr), : type(nullptr),
name(nullptr), name(nullptr),
label(nullptr), label(nullptr),
@@ -211,8 +217,9 @@ struct SaveState {
CARLA_DECLARE_NON_COPY_STRUCT(SaveState) CARLA_DECLARE_NON_COPY_STRUCT(SaveState)
}; };


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


#if 1
static inline static inline
QString xmlSafeString(const QString& string, const bool toXml) QString xmlSafeString(const QString& string, const bool toXml)
{ {
@@ -229,8 +236,26 @@ const char* xmlSafeStringCharDup(const QString& string, const bool toXml)
{ {
return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData()); return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData());
} }
#else
static inline
String xmlSafeString(const String& string, const bool toXml)
{
String newString(string);


// -------------------------------------------------
if (toXml)
return newString.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;").replace("\"","&quot;");
else
return newString.replace("&amp;","&").replace("&lt;","<").replace("&gt;",">").replace("&apos;","'").replace("&quot;","\"");
}

static inline
const char* xmlSafeStringCharDup(const String& string, const bool toXml)
{
return carla_strdup(xmlSafeString(string, toXml).toRawUTF8());
}
#endif

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


static inline static inline
void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
@@ -244,7 +269,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)


while (! node.isNull()) while (! node.isNull())
{ {
// ------------------------------------------------------
// ---------------------------------------------------------------
// Info // Info


if (node.toElement().tagName().compare("Info", Qt::CaseInsensitive) == 0) if (node.toElement().tagName().compare("Info", Qt::CaseInsensitive) == 0)
@@ -275,7 +300,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
} }
} }


// ------------------------------------------------------
// ---------------------------------------------------------------
// Data // Data


else if (node.toElement().tagName().compare("Data", Qt::CaseInsensitive) == 0) else if (node.toElement().tagName().compare("Data", Qt::CaseInsensitive) == 0)
@@ -287,7 +312,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
const QString tag(xmlData.toElement().tagName()); const QString tag(xmlData.toElement().tagName());
const QString text(xmlData.toElement().text().trimmed()); const QString text(xmlData.toElement().text().trimmed());


// ----------------------------------------------
// -------------------------------------------------------
// Internal Data // Internal Data


if (tag.compare("Active", Qt::CaseInsensitive) == 0) if (tag.compare("Active", Qt::CaseInsensitive) == 0)
@@ -332,7 +357,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.ctrlChannel = static_cast<int8_t>(value-1); saveState.ctrlChannel = static_cast<int8_t>(value-1);
} }


// ----------------------------------------------
// -------------------------------------------------------
// Program (current) // Program (current)


else if (tag.compare("CurrentProgramIndex", Qt::CaseInsensitive) == 0) else if (tag.compare("CurrentProgramIndex", Qt::CaseInsensitive) == 0)
@@ -347,7 +372,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.currentProgramName = xmlSafeStringCharDup(text, false); saveState.currentProgramName = xmlSafeStringCharDup(text, false);
} }


// ----------------------------------------------
// -------------------------------------------------------
// Midi Program (current) // Midi Program (current)


else if (tag.compare("CurrentMidiBank", Qt::CaseInsensitive) == 0) else if (tag.compare("CurrentMidiBank", Qt::CaseInsensitive) == 0)
@@ -365,7 +390,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.currentMidiProgram = value-1; saveState.currentMidiProgram = value-1;
} }


// ----------------------------------------------
// -------------------------------------------------------
// Parameters // Parameters


else if (tag.compare("Parameter", Qt::CaseInsensitive) == 0) else if (tag.compare("Parameter", Qt::CaseInsensitive) == 0)
@@ -420,7 +445,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.parameters.append(stateParameter); saveState.parameters.append(stateParameter);
} }


// ----------------------------------------------
// -------------------------------------------------------
// Custom Data // Custom Data


else if (tag.compare("CustomData", Qt::CaseInsensitive) == 0) else if (tag.compare("CustomData", Qt::CaseInsensitive) == 0)
@@ -447,7 +472,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.customData.append(stateCustomData); saveState.customData.append(stateCustomData);
} }


// ----------------------------------------------
// -------------------------------------------------------
// Chunk // Chunk


else if (tag.compare("Chunk", Qt::CaseInsensitive) == 0) else if (tag.compare("Chunk", Qt::CaseInsensitive) == 0)
@@ -455,19 +480,19 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
saveState.chunk = xmlSafeStringCharDup(text, false); saveState.chunk = xmlSafeStringCharDup(text, false);
} }


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


xmlData = xmlData.nextSibling(); xmlData = xmlData.nextSibling();
} }
} }


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


node = node.nextSibling(); node = node.nextSibling();
} }
} }


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


static inline static inline
void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) void fillXmlStringFromSaveState(QString& content, const SaveState& saveState)
@@ -630,6 +655,8 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState)
content += " </Data>\n"; content += " </Data>\n";
} }


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

CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


#endif // CARLA_STATE_UTILS_HPP_INCLUDED #endif // CARLA_STATE_UTILS_HPP_INCLUDED

+ 8
- 6
source/modules/utils/CarlaVstUtils.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_VST_UTILS_HPP_INCLUDED #ifndef CARLA_VST_UTILS_HPP_INCLUDED
@@ -22,7 +22,7 @@


#include <cstring> #include <cstring>


// -------------------------------------------------
// -----------------------------------------------------------------------
// Include fixes // Include fixes


// Disable deprecated VST features (NOT) // Disable deprecated VST features (NOT)
@@ -119,12 +119,12 @@ struct VstTimeInfo_R {
typedef VstTimeInfo VstTimeInfo_R; typedef VstTimeInfo VstTimeInfo_R;
#endif #endif


// -------------------------------------------------
// -----------------------------------------------------------------------
// Plugin callback // Plugin callback


typedef AEffect* (*VST_Function)(audioMasterCallback); typedef AEffect* (*VST_Function)(audioMasterCallback);


// -------------------------------------------------
// -----------------------------------------------------------------------
// Check if feature is supported by the plugin // Check if feature is supported by the plugin


static inline static inline
@@ -133,7 +133,7 @@ bool vstPluginCanDo(AEffect* const effect, const char* const feature)
return (effect->dispatcher(effect, effCanDo, 0, 0, (void*)feature, 0.0f) == 1); return (effect->dispatcher(effect, effCanDo, 0, 0, (void*)feature, 0.0f) == 1);
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// Convert Effect opcode to string // Convert Effect opcode to string


static inline static inline
@@ -326,7 +326,7 @@ const char* vstEffectOpcode2str(const int32_t opcode)
} }
} }


// -------------------------------------------------
// -----------------------------------------------------------------------
// Convert Host/Master opcode to string // Convert Host/Master opcode to string


static inline static inline
@@ -453,4 +453,6 @@ const char* vstMasterOpcode2str(const int32_t opcode)
} }
} }


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

#endif // CARLA_VST_UTILS_HPP_INCLUDED #endif // CARLA_VST_UTILS_HPP_INCLUDED

+ 4
- 5
source/modules/utils/RtList.hpp View File

@@ -195,7 +195,7 @@ public:
T& getAt(const size_t index, const bool remove = false) T& getAt(const size_t index, const bool remove = false)
{ {
if (fCount == 0 || index >= fCount) if (fCount == 0 || index >= fCount)
return fFallbackValue;
return fRetValue;


size_t i = 0; size_t i = 0;
Data* data = nullptr; Data* data = nullptr;
@@ -227,7 +227,7 @@ public:
break; break;
} }


return (data != nullptr) ? fRetValue : fFallbackValue;
return fRetValue;
} }


T& getFirst(const bool remove = false) T& getFirst(const bool remove = false)
@@ -320,7 +320,6 @@ protected:
virtual void _deallocate(Data*& dataPtr) = 0; virtual void _deallocate(Data*& dataPtr) = 0;


private: private:
T fFallbackValue;
T fRetValue; T fRetValue;


void _init() noexcept void _init() noexcept
@@ -332,7 +331,7 @@ private:
T& _getFirstOrLast(const bool first, const bool remove) T& _getFirstOrLast(const bool first, const bool remove)
{ {
if (fCount == 0) if (fCount == 0)
return fFallbackValue;
return fRetValue;


k_list_head* const entry = first ? fQueue.next : fQueue.prev; k_list_head* const entry = first ? fQueue.next : fQueue.prev;
Data* data = list_entry(entry, Data, siblings); Data* data = list_entry(entry, Data, siblings);
@@ -352,7 +351,7 @@ private:
} }
} }


return (data != nullptr) ? fRetValue : fFallbackValue;
return fRetValue;
} }


LIST_DECLARATIONS(List) LIST_DECLARATIONS(List)


+ 52
- 10
source/tests/ANSI.cpp View File

@@ -41,14 +41,14 @@
#include "RtList.hpp" #include "RtList.hpp"


// Carla utils (part 3/4) // Carla utils (part 3/4)
// #include "CarlaBackendUtils.hpp"
// #include "CarlaBridgeUtils.hpp"
// #include "CarlaLadspaUtils.hpp"
// #include "CarlaLibUtils.hpp"
#include "CarlaBackendUtils.hpp"
#include "CarlaBridgeUtils.hpp"
#include "CarlaLadspaUtils.hpp"
#include "CarlaLibUtils.hpp"
// #include "CarlaLv2Utils.hpp" // #include "CarlaLv2Utils.hpp"
// #include "CarlaOscUtils.hpp"
// #include "CarlaShmUtils.hpp"
// #include "CarlaStateUtils.hpp"
#include "CarlaOscUtils.hpp"
#include "CarlaShmUtils.hpp"
#include "CarlaStateUtils.hpp"
// #include "CarlaVstUtils.hpp" // #include "CarlaVstUtils.hpp"


// Carla utils (part 4/4) // Carla utils (part 4/4)
@@ -526,14 +526,56 @@ int main()


assert(! ctrl.dataAvailable()); assert(! ctrl.dataAvailable());


printf("\nDUMP FINISHED");
printf("\nDUMP FINISHED\n");
} }


// RtList // RtList
{ {
NonRtList<int> list;
list.append(6);
class ListTester
{
public:
struct CountObj {
CountObj() : count(0) {}
volatile int count;
};

ListTester()
{
++getCounter().count;
}

~ListTester()
{
--getCounter().count;
}

static CountObj& getCounter()
{
static CountObj counter;
return counter;
}
};

ListTester::CountObj& obj = ListTester::getCounter();
assert(obj.count == 0);

NonRtList<ListTester> list;
obj = ListTester::getCounter();
assert(obj.count == 1); // List fRetValue

ListTester t1;
obj = ListTester::getCounter();
assert(obj.count == 2); // List fRetValue + t1

list.append(t1);
list.append(t1);
list.append(t1);
obj = ListTester::getCounter();
assert(obj.count == 5); // List fRetValue + t1 + 3 appends

list.clear(); list.clear();
obj = ListTester::getCounter();
assert(obj.count == 2); // List fRetValue + t1
} }


return 0; return 0;


Loading…
Cancel
Save