@@ -96,6 +96,8 @@ const char* PluginType2Str(const PluginType type) | |||
return "PLUGIN_VST"; | |||
case PLUGIN_VST3: | |||
return "PLUGIN_VST3"; | |||
case PLUGIN_AU: | |||
return "PLUGIN_AU"; | |||
case PLUGIN_GIG: | |||
return "PLUGIN_GIG"; | |||
case PLUGIN_SF2: | |||
@@ -402,7 +404,7 @@ const char* TransportMode2Str(const TransportMode mode) | |||
static inline | |||
uintptr_t getAddressFromPointer(void* ptr) | |||
{ | |||
CARLA_ASSERT(ptr != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0); | |||
uintptr_t* const addr((uintptr_t*)&ptr); | |||
return *addr; | |||
@@ -412,7 +414,7 @@ template<typename T> | |||
static inline | |||
T* getPointerFromAddress(uintptr_t& addr) | |||
{ | |||
CARLA_ASSERT(addr != 0); | |||
CARLA_SAFE_ASSERT_RETURN(addr != 0, nullptr); | |||
T** const ptr((T**)&addr); | |||
return *ptr; | |||
@@ -441,6 +443,8 @@ const char* getPluginTypeAsString(const PluginType type) | |||
return "VST"; | |||
case PLUGIN_VST3: | |||
return "VST3"; | |||
case PLUGIN_AU: | |||
return "AU"; | |||
case PLUGIN_GIG: | |||
return "GIG"; | |||
case PLUGIN_SF2: | |||
@@ -479,6 +483,8 @@ PluginType getPluginTypeFromString(const char* const stype) | |||
return PLUGIN_VST; | |||
if (std::strcmp(stype, "VST3") == 0) | |||
return PLUGIN_VST3; | |||
if (std::strcmp(stype, "AU") == 0) | |||
return PLUGIN_AU; | |||
if (std::strcmp(stype, "GIG") == 0) | |||
return PLUGIN_GIG; | |||
if (std::strcmp(stype, "SF2") == 0) | |||
@@ -574,6 +580,8 @@ PluginCategory getPluginCategoryFromName(const char* const name) | |||
return PLUGIN_CATEGORY_NONE; | |||
} | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE | |||
#endif // CARLA_BACKEND_UTILS_HPP_INCLUDED |
@@ -20,6 +20,8 @@ | |||
#include "CarlaRingBuffer.hpp" | |||
// ----------------------------------------------------------------------- | |||
enum PluginBridgeInfoType { | |||
kPluginBridgeAudioCount = 0, | |||
kPluginBridgeMidiCount, | |||
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -31,10 +31,7 @@ | |||
static inline | |||
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()); | |||
@@ -143,66 +140,55 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri | |||
static inline | |||
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)) | |||
{ | |||
switch (hintDescriptor & LADSPA_HINT_DEFAULT_MASK) | |||
{ | |||
case LADSPA_HINT_DEFAULT_MINIMUM: | |||
def = min; | |||
break; | |||
return min; | |||
case LADSPA_HINT_DEFAULT_MAXIMUM: | |||
def = max; | |||
break; | |||
return max; | |||
case LADSPA_HINT_DEFAULT_0: | |||
def = 0.0f; | |||
break; | |||
return 0.0f; | |||
case LADSPA_HINT_DEFAULT_1: | |||
def = 1.0f; | |||
break; | |||
return 1.0f; | |||
case LADSPA_HINT_DEFAULT_100: | |||
def = 100.0f; | |||
break; | |||
return 100.0f; | |||
case LADSPA_HINT_DEFAULT_440: | |||
def = 440.0f; | |||
break; | |||
return 440.0f; | |||
case LADSPA_HINT_DEFAULT_LOW: | |||
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 | |||
def = (min*0.75f) + (max*0.25f); | |||
break; | |||
return (min*0.75f) + (max*0.25f); | |||
case LADSPA_HINT_DEFAULT_MIDDLE: | |||
if (LADSPA_IS_HINT_LOGARITHMIC(hintDescriptor)) | |||
def = std::sqrt(min*max); | |||
return std::sqrt(min*max); | |||
else | |||
def = (min+max)/2; | |||
break; | |||
return (min+max)/2; | |||
case LADSPA_HINT_DEFAULT_HIGH: | |||
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 | |||
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 |
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -30,7 +30,7 @@ | |||
static inline | |||
void* lib_open(const char* const filename) | |||
{ | |||
CARLA_ASSERT(filename != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, nullptr); | |||
#ifdef CARLA_OS_WIN | |||
return (void*)LoadLibraryA(filename); | |||
@@ -42,10 +42,7 @@ void* lib_open(const char* const filename) | |||
static inline | |||
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 | |||
return FreeLibrary((HMODULE)lib); | |||
@@ -57,11 +54,8 @@ bool lib_close(void* const lib) | |||
static inline | |||
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 | |||
return (void*)GetProcAddress((HMODULE)lib, symbol); | |||
@@ -73,11 +67,11 @@ void* lib_symbol(void* const lib, const char* const symbol) | |||
static inline | |||
const char* lib_error(const char* const filename) | |||
{ | |||
CARLA_ASSERT(filename != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(filename != nullptr, nullptr); | |||
#ifdef CARLA_OS_WIN | |||
static char libError[2048+1]; | |||
//carla_fill<char>(libError, 2048, '\0'); | |||
carla_zeroChar(libError, 2048); | |||
LPVOID winErrorString; | |||
DWORD winErrorCode = GetLastError(); | |||
@@ -89,10 +83,9 @@ const char* lib_error(const char* const filename) | |||
return libError; | |||
#else | |||
return dlerror(); | |||
// unused | |||
(void)filename; | |||
#endif | |||
} | |||
// ----------------------------------------------------------------------- | |||
#endif // CARLA_LIB_UTILS_HPP_INCLUDED |
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -68,211 +68,185 @@ struct CarlaOscData { | |||
static inline | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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 | |||
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); | |||
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 | |||
static inline | |||
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); | |||
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 | |||
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); | |||
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 | |||
static inline | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
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); | |||
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 | |||
@@ -315,36 +285,34 @@ void osc_send_bridge_error(const CarlaOscData& oscData, const char* const error) | |||
static inline | |||
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); | |||
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 | |||
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); | |||
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 // CARLA_OSC_UTILS_HPP_INCLUDED |
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -185,7 +185,7 @@ void carla_shm_unmap(shm_t& shm, void* const ptr, const size_t size) | |||
#endif | |||
} | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// shared memory, templated calls | |||
template<typename T> | |||
@@ -204,4 +204,6 @@ void carla_shm_unmap(shm_t& shm, T*& value) | |||
value = nullptr; | |||
} | |||
// ----------------------------------------------------------------------- | |||
#endif // CARLA_SHM_UTILS_HPP_INCLUDED |
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -22,7 +22,13 @@ | |||
#include "CarlaMIDI.h" | |||
#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 | |||
@@ -36,7 +42,7 @@ struct StateParameter { | |||
uint8_t midiChannel; | |||
int16_t midiCC; | |||
StateParameter() | |||
StateParameter() noexcept | |||
: index(0), | |||
name(nullptr), | |||
symbol(nullptr), | |||
@@ -66,7 +72,7 @@ struct StateCustomData { | |||
const char* key; | |||
const char* value; | |||
StateCustomData() | |||
StateCustomData() noexcept | |||
: type(nullptr), | |||
key(nullptr), | |||
value(nullptr) {} | |||
@@ -123,7 +129,7 @@ struct SaveState { | |||
StateParameterList parameters; | |||
StateCustomDataList customData; | |||
SaveState() | |||
SaveState() noexcept | |||
: type(nullptr), | |||
name(nullptr), | |||
label(nullptr), | |||
@@ -211,8 +217,9 @@ struct SaveState { | |||
CARLA_DECLARE_NON_COPY_STRUCT(SaveState) | |||
}; | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
#if 1 | |||
static inline | |||
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()); | |||
} | |||
#else | |||
static inline | |||
String xmlSafeString(const String& string, const bool toXml) | |||
{ | |||
String newString(string); | |||
// ------------------------------------------------- | |||
if (toXml) | |||
return newString.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace("\"","""); | |||
else | |||
return newString.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace(""","\""); | |||
} | |||
static inline | |||
const char* xmlSafeStringCharDup(const String& string, const bool toXml) | |||
{ | |||
return carla_strdup(xmlSafeString(string, toXml).toRawUTF8()); | |||
} | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
static inline | |||
void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
@@ -244,7 +269,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
while (! node.isNull()) | |||
{ | |||
// ------------------------------------------------------ | |||
// --------------------------------------------------------------- | |||
// Info | |||
if (node.toElement().tagName().compare("Info", Qt::CaseInsensitive) == 0) | |||
@@ -275,7 +300,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
} | |||
} | |||
// ------------------------------------------------------ | |||
// --------------------------------------------------------------- | |||
// Data | |||
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 text(xmlData.toElement().text().trimmed()); | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Internal Data | |||
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); | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Program (current) | |||
else if (tag.compare("CurrentProgramIndex", Qt::CaseInsensitive) == 0) | |||
@@ -347,7 +372,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
saveState.currentProgramName = xmlSafeStringCharDup(text, false); | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Midi Program (current) | |||
else if (tag.compare("CurrentMidiBank", Qt::CaseInsensitive) == 0) | |||
@@ -365,7 +390,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
saveState.currentMidiProgram = value-1; | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Parameters | |||
else if (tag.compare("Parameter", Qt::CaseInsensitive) == 0) | |||
@@ -420,7 +445,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
saveState.parameters.append(stateParameter); | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Custom Data | |||
else if (tag.compare("CustomData", Qt::CaseInsensitive) == 0) | |||
@@ -447,7 +472,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
saveState.customData.append(stateCustomData); | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
// Chunk | |||
else if (tag.compare("Chunk", Qt::CaseInsensitive) == 0) | |||
@@ -455,19 +480,19 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode) | |||
saveState.chunk = xmlSafeStringCharDup(text, false); | |||
} | |||
// ---------------------------------------------- | |||
// ------------------------------------------------------- | |||
xmlData = xmlData.nextSibling(); | |||
} | |||
} | |||
// ------------------------------------------------------ | |||
// --------------------------------------------------------------- | |||
node = node.nextSibling(); | |||
} | |||
} | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
static inline | |||
void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) | |||
@@ -630,6 +655,8 @@ void fillXmlStringFromSaveState(QString& content, const SaveState& saveState) | |||
content += " </Data>\n"; | |||
} | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE | |||
#endif // CARLA_STATE_UTILS_HPP_INCLUDED |
@@ -12,7 +12,7 @@ | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* 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 | |||
@@ -22,7 +22,7 @@ | |||
#include <cstring> | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// Include fixes | |||
// Disable deprecated VST features (NOT) | |||
@@ -119,12 +119,12 @@ struct VstTimeInfo_R { | |||
typedef VstTimeInfo VstTimeInfo_R; | |||
#endif | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// Plugin callback | |||
typedef AEffect* (*VST_Function)(audioMasterCallback); | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// Check if feature is supported by the plugin | |||
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); | |||
} | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// Convert Effect opcode to string | |||
static inline | |||
@@ -326,7 +326,7 @@ const char* vstEffectOpcode2str(const int32_t opcode) | |||
} | |||
} | |||
// ------------------------------------------------- | |||
// ----------------------------------------------------------------------- | |||
// Convert Host/Master opcode to string | |||
static inline | |||
@@ -453,4 +453,6 @@ const char* vstMasterOpcode2str(const int32_t opcode) | |||
} | |||
} | |||
// ----------------------------------------------------------------------- | |||
#endif // CARLA_VST_UTILS_HPP_INCLUDED |
@@ -195,7 +195,7 @@ public: | |||
T& getAt(const size_t index, const bool remove = false) | |||
{ | |||
if (fCount == 0 || index >= fCount) | |||
return fFallbackValue; | |||
return fRetValue; | |||
size_t i = 0; | |||
Data* data = nullptr; | |||
@@ -227,7 +227,7 @@ public: | |||
break; | |||
} | |||
return (data != nullptr) ? fRetValue : fFallbackValue; | |||
return fRetValue; | |||
} | |||
T& getFirst(const bool remove = false) | |||
@@ -320,7 +320,6 @@ protected: | |||
virtual void _deallocate(Data*& dataPtr) = 0; | |||
private: | |||
T fFallbackValue; | |||
T fRetValue; | |||
void _init() noexcept | |||
@@ -332,7 +331,7 @@ private: | |||
T& _getFirstOrLast(const bool first, const bool remove) | |||
{ | |||
if (fCount == 0) | |||
return fFallbackValue; | |||
return fRetValue; | |||
k_list_head* const entry = first ? fQueue.next : fQueue.prev; | |||
Data* data = list_entry(entry, Data, siblings); | |||
@@ -352,7 +351,7 @@ private: | |||
} | |||
} | |||
return (data != nullptr) ? fRetValue : fFallbackValue; | |||
return fRetValue; | |||
} | |||
LIST_DECLARATIONS(List) | |||
@@ -41,14 +41,14 @@ | |||
#include "RtList.hpp" | |||
// 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 "CarlaOscUtils.hpp" | |||
// #include "CarlaShmUtils.hpp" | |||
// #include "CarlaStateUtils.hpp" | |||
#include "CarlaOscUtils.hpp" | |||
#include "CarlaShmUtils.hpp" | |||
#include "CarlaStateUtils.hpp" | |||
// #include "CarlaVstUtils.hpp" | |||
// Carla utils (part 4/4) | |||
@@ -526,14 +526,56 @@ int main() | |||
assert(! ctrl.dataAvailable()); | |||
printf("\nDUMP FINISHED"); | |||
printf("\nDUMP FINISHED\n"); | |||
} | |||
// 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(); | |||
obj = ListTester::getCounter(); | |||
assert(obj.count == 2); // List fRetValue + t1 | |||
} | |||
return 0; | |||