From 13b915b1b130c30e302a2326689b73a13657d95c Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 20 Jan 2013 03:50:54 +0000 Subject: [PATCH] Misc stuff --- source/utils/carla_backend_utils.hpp | 4 +++- source/utils/carla_ladspa_utils.hpp | 36 +++++++++++++++------------- source/utils/carla_lib_utils.hpp | 4 ++-- source/utils/carla_lv2_utils.hpp | 2 +- source/utils/carla_osc_utils.hpp | 18 +++++++------- source/utils/carla_utils.hpp | 32 +++++++++++++++++++++++-- source/utils/carla_vst_utils.hpp | 8 +++---- 7 files changed, 68 insertions(+), 36 deletions(-) diff --git a/source/utils/carla_backend_utils.hpp b/source/utils/carla_backend_utils.hpp index 379878ab0..98d6d3ded 100644 --- a/source/utils/carla_backend_utils.hpp +++ b/source/utils/carla_backend_utils.hpp @@ -1,6 +1,6 @@ /* * Carla Backend utils - * Copyright (C) 2011-2012 Filipe Coelho + * Copyright (C) 2011-2013 Filipe Coelho * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,10 +121,12 @@ const char* ParameterType2Str(const ParameterType& type) return "PARAMETER_LATENCY"; case PARAMETER_SAMPLE_RATE: return "PARAMETER_SAMPLE_RATE"; +#ifdef WANT_LV2 case PARAMETER_LV2_FREEWHEEL: return "PARAMETER_LV2_FREEWHEEL"; case PARAMETER_LV2_TIME: return "PARAMETER_LV2_TIME"; +#endif } qWarning("CarlaBackend::ParameterType2Str(%i) - invalid type", type); diff --git a/source/utils/carla_ladspa_utils.hpp b/source/utils/carla_ladspa_utils.hpp index af9356eef..ca6c5babc 100644 --- a/source/utils/carla_ladspa_utils.hpp +++ b/source/utils/carla_ladspa_utils.hpp @@ -9,7 +9,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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. * * For a full copy of the GNU General Public License see the COPYING file @@ -55,27 +55,31 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o for (unsigned long i=0; i < newDescriptor->PortCount; i++) { + LADSPA_RDF_Port* const oldPort = &oldDescriptor->Ports[i]; LADSPA_RDF_Port* const newPort = &newDescriptor->Ports[i]; - newPort->Type = oldDescriptor->Ports[i].Type; - newPort->Hints = oldDescriptor->Ports[i].Hints; - newPort->Default = oldDescriptor->Ports[i].Default; - newPort->Unit = oldDescriptor->Ports[i].Unit; - newPort->ScalePointCount = oldDescriptor->Ports[i].ScalePointCount; - if (oldDescriptor->Ports[i].Label) - newPort->Label = strdup(oldDescriptor->Ports[i].Label); + newPort->Type = oldPort->Type; + newPort->Hints = oldPort->Hints; + newPort->Default = oldPort->Default; + newPort->Unit = oldPort->Unit; + newPort->ScalePointCount = oldPort->ScalePointCount; - if (newPort->ScalePointCount > 0) + if (oldPort->Label) + newPort->Label = strdup(oldPort->Label); + + if (oldPort->ScalePointCount > 0) { - newPort->ScalePoints = new LADSPA_RDF_ScalePoint[newPort->ScalePointCount]; + newPort->ScalePoints = new LADSPA_RDF_ScalePoint[oldPort->ScalePointCount]; - for (unsigned long j=0; j < newPort->ScalePointCount; j++) + for (unsigned long j=0; j < oldPort->ScalePointCount; j++) { + LADSPA_RDF_ScalePoint* const oldScalePoint = &oldPort->ScalePoints[j]; LADSPA_RDF_ScalePoint* const newScalePoint = &newPort->ScalePoints[j]; - newScalePoint->Value = oldDescriptor->Ports[i].ScalePoints[j].Value; - if (oldDescriptor->Ports[i].ScalePoints[j].Label) - newScalePoint->Label = strdup(oldDescriptor->Ports[i].ScalePoints[j].Label); + newScalePoint->Value = oldScalePoint->Value; + + if (oldScalePoint->Label) + newScalePoint->Label = strdup(oldScalePoint->Label); } } } @@ -110,9 +114,7 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri CARLA_ASSERT(rdfDescriptor); CARLA_ASSERT(descriptor); - if (! rdfDescriptor) - return false; - if (! descriptor) + if (! (rdfDescriptor && descriptor)) return false; if (rdfDescriptor->UniqueID != descriptor->UniqueID) diff --git a/source/utils/carla_lib_utils.hpp b/source/utils/carla_lib_utils.hpp index 0881dc0a6..170ec9003 100644 --- a/source/utils/carla_lib_utils.hpp +++ b/source/utils/carla_lib_utils.hpp @@ -9,7 +9,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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. * * For a full copy of the GNU General Public License see the COPYING file @@ -33,7 +33,7 @@ void* lib_open(const char* const filename) CARLA_ASSERT(filename); #ifdef Q_OS_WIN - return LoadLibraryA(filename); + return (void*)LoadLibraryA(filename); #else return dlopen(filename, RTLD_NOW|RTLD_LOCAL); #endif diff --git a/source/utils/carla_lv2_utils.hpp b/source/utils/carla_lv2_utils.hpp index 391e1194a..b304f5b90 100644 --- a/source/utils/carla_lv2_utils.hpp +++ b/source/utils/carla_lv2_utils.hpp @@ -9,7 +9,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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. * * For a full copy of the GNU General Public License see the COPYING file diff --git a/source/utils/carla_osc_utils.hpp b/source/utils/carla_osc_utils.hpp index 574e9d5f8..1faaabcca 100644 --- a/source/utils/carla_osc_utils.hpp +++ b/source/utils/carla_osc_utils.hpp @@ -1,6 +1,6 @@ /* * Carla OSC utils - * Copyright (C) 2012 Filipe Coelho + * Copyright (C) 2012-2013 Filipe Coelho * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -9,21 +9,21 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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. * * For a full copy of the GNU General Public License see the COPYING file */ -#ifndef CARLA_OSC_UTILS_HPP -#define CARLA_OSC_UTILS_HPP +#ifndef __CARLA_OSC_UTILS_HPP__ +#define __CARLA_OSC_UTILS_HPP__ #include "carla_utils.hpp" #include #include -// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------- struct CarlaOscData { const char* path; @@ -57,7 +57,7 @@ struct CarlaOscData { } }; -// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------- static inline void osc_send_configure(const CarlaOscData* const oscData, const char* const key, const char* const value) @@ -269,7 +269,7 @@ void osc_send_quit(const CarlaOscData* const oscData) } } -// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------- #ifdef BUILD_BRIDGE_PLUGIN static inline @@ -343,6 +343,6 @@ void osc_send_lv2_transfer_event(const CarlaOscData* const oscData, const int32_ } #endif -// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------- -#endif // CARLA_OSC_UTILS_HPP +#endif // __CARLA_OSC_UTILS_HPP__ diff --git a/source/utils/carla_utils.hpp b/source/utils/carla_utils.hpp index 948d3ec11..32918acd6 100644 --- a/source/utils/carla_utils.hpp +++ b/source/utils/carla_utils.hpp @@ -23,7 +23,12 @@ #include #include #include -#include + +#ifdef DONT_USE_PTHREAD +# include +#else +# include +#endif #if defined(Q_OS_HAIKU) # include @@ -178,29 +183,46 @@ class CarlaMutex { public: CarlaMutex() - //: pmutex PTHREAD_MUTEX_INITIALIZER { +#ifndef DONT_USE_PTHREAD pthread_mutex_init(&pmutex, nullptr); +#endif } ~CarlaMutex() { +#ifndef DONT_USE_PTHREAD pthread_mutex_destroy(&pmutex); +#endif } bool lock() { +#ifdef DONT_USE_PTHREAD + cmutex.lock(); + return true; +#else return (pthread_mutex_lock(&pmutex) == 0); +#endif } bool tryLock() { +#ifdef DONT_USE_PTHREAD + return cmutex.try_lock(); +#else return (pthread_mutex_trylock(&pmutex) == 0); +#endif } bool unlock() { +#ifdef DONT_USE_PTHREAD + cmutex.unlock(); + return true; +#else return (pthread_mutex_unlock(&pmutex) == 0); +#endif } class ScopedLocker @@ -222,7 +244,11 @@ public: }; private: +#ifdef DONT_USE_PTHREAD + std::mutex cmutex; +#else pthread_mutex_t pmutex; +#endif }; // ------------------------------------------------- @@ -343,6 +369,8 @@ public: if (*strBuf == 0) return false; + // FIXME - use strstr + size_t thisLen = ::strlen(buffer); size_t thatLen = ::strlen(strBuf)-1; diff --git a/source/utils/carla_vst_utils.hpp b/source/utils/carla_vst_utils.hpp index 08152eb7c..221bfd864 100644 --- a/source/utils/carla_vst_utils.hpp +++ b/source/utils/carla_vst_utils.hpp @@ -9,7 +9,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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. * * For a full copy of the GNU General Public License see the COPYING file @@ -18,9 +18,6 @@ #ifndef __CARLA_VST_UTILS_HPP__ #define __CARLA_VST_UTILS_HPP__ -// Disable deprecated VST features (NOT) -#define VST_FORCE_DEPRECATED 0 - #include "carla_utils.hpp" #include @@ -28,6 +25,9 @@ // ------------------------------------------------- // Include fixes +// Disable deprecated VST features (NOT) +#define VST_FORCE_DEPRECATED 0 + #if VESTIGE_HEADER #include "vestige/aeffectx.h" #define audioMasterGetOutputSpeakerArrangement audioMasterGetSpeakerArrangement