From 83f71f89eb0b525dd089120ba23956822d7dff69 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 6 Aug 2014 17:10:54 +0100 Subject: [PATCH] Cleanup --- source/Makefile.mk | 7 +-- source/backend/engine/CarlaEngineJack.cpp | 3 +- source/backend/plugin/NativePlugin.cpp | 35 +------------- source/discovery/carla-discovery.cpp | 8 ++-- source/modules/CarlaNative.h | 22 +++------ source/modules/CarlaNative.hpp | 56 ----------------------- source/modules/native-plugins/lfo.c | 2 - source/plugin/carla-native-lv2-export.cpp | 3 -- source/plugin/carla-native-lv2.cpp | 45 ++---------------- source/utils/CarlaLv2Utils.hpp | 5 -- 10 files changed, 23 insertions(+), 163 deletions(-) diff --git a/source/Makefile.mk b/source/Makefile.mk index 3f07c4761..39256d790 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -106,10 +106,11 @@ endif ifeq ($(TESTBUILD),true) BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings -BASE_FLAGS += -Wfloat-equal -Wpointer-arith -Wstrict-overflow=5 -Waggregate-return -Wabi -Winit-self -Wuninitialized -Wold-style-definition +BASE_FLAGS += -Wfloat-equal -Wpointer-arith -Wabi -Winit-self -Wuninitialized #-Wstrict-overflow=5 +ifeq ($(CC),clang) BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command # BASE_FLAGS += -Weverything -ifneq ($(CC),clang) +else BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations endif ifneq ($(MACOS),true) @@ -118,7 +119,7 @@ ifneq ($(CC),clang) BASE_FLAGS += -Wlogical-op endif endif -CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes +CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual ifeq ($(LINUX),true) CFLAGS += -isystem /opt/kxstudio/include diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 5dc1fcd2c..ab6ca9af3 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -638,6 +638,7 @@ public: fUsedPorts(), fUsedConnections(), fNewGroups(), + fRetConns(), #endif leakDetector_CarlaEngineJack() { @@ -710,7 +711,7 @@ public: carla_zeroStruct(fTransportPos); #ifdef BUILD_BRIDGE - if (pData->bufferSize == 0 || pData->sampleRate == 0.0) + if (pData->bufferSize == 0 || carla_compareFloats(pData->sampleRate, 0.0)) { // open temp client to get initial buffer-size and sample-rate values if (jack_client_t* const tmpClient = jackbridge_client_open(clientName, JackNullOption, nullptr)) diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index 64d0ed603..c68dfc071 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -988,9 +988,9 @@ public: else if (max < min) min = max; - if (max - min == 0.0f) + if (carla_compareFloats(min, max)) { - carla_stderr2("WARNING - Broken plugin parameter '%s': max - min == 0.0f", paramInfo->name); + carla_stderr2("WARNING - Broken plugin parameter '%s': max == min", paramInfo->name); max = min + 0.1f; } @@ -2137,37 +2137,6 @@ protected: { case ::HOST_OPCODE_NULL: break; -#ifdef BUILD_BRIDGE - case ::HOST_OPCODE_SET_VOLUME: - case ::HOST_OPCODE_SET_DRYWET: - case ::HOST_OPCODE_SET_BALANCE_LEFT: - case ::HOST_OPCODE_SET_BALANCE_RIGHT: - case ::HOST_OPCODE_SET_PANNING: - break; -#else - case ::HOST_OPCODE_SET_VOLUME: - setVolume(opt, true, true); - break; - case ::HOST_OPCODE_SET_DRYWET: - setDryWet(opt, true, true); - break; - case ::HOST_OPCODE_SET_BALANCE_LEFT: - setBalanceLeft(opt, true, true); - break; - case ::HOST_OPCODE_SET_BALANCE_RIGHT: - setBalanceRight(opt, true, true); - break; - case ::HOST_OPCODE_SET_PANNING: - setPanning(opt, true, true); - break; -#endif - case ::HOST_OPCODE_GET_PARAMETER_MIDI_CC: - case ::HOST_OPCODE_SET_PARAMETER_MIDI_CC: - // TODO - break; - case ::HOST_OPCODE_SET_PROCESS_PRECISION: - // TODO - break; case ::HOST_OPCODE_UPDATE_PARAMETER: // TODO pData->engine->callback(ENGINE_CALLBACK_UPDATE, pData->id, -1, 0, 0.0f, nullptr); diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index b2a29718f..673871338 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -572,9 +572,9 @@ static void do_ladspa_check(void*& libHandle, const char* const filename, const DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: min > max"); max = min + 0.1f; } - else if (max - min == 0.0f) + else if (carla_compareFloats(min, max)) { - DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: max - min == 0"); + DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: max == min"); max = min + 0.1f; } @@ -838,9 +838,9 @@ static void do_dssi_check(void*& libHandle, const char* const filename, const bo DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: min > max"); max = min + 0.1f; } - else if (max - min == 0.0f) + else if (carla_compareFloats(min, max)) { - DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: max - min == 0"); + DISCOVERY_OUT("warning", "Parameter '" << portName << "' is broken: max == min"); max = min + 0.1f; } diff --git a/source/modules/CarlaNative.h b/source/modules/CarlaNative.h index f26a93d25..6dbe76b52 100644 --- a/source/modules/CarlaNative.h +++ b/source/modules/CarlaNative.h @@ -97,21 +97,13 @@ typedef enum { } NativePluginDispatcherOpcode; typedef enum { - HOST_OPCODE_NULL = 0, // nothing - HOST_OPCODE_SET_VOLUME = 1, // uses opt - HOST_OPCODE_SET_DRYWET = 2, // uses opt - HOST_OPCODE_SET_BALANCE_LEFT = 3, // uses opt - HOST_OPCODE_SET_BALANCE_RIGHT = 4, // uses opt - HOST_OPCODE_SET_PANNING = 5, // uses opt - HOST_OPCODE_GET_PARAMETER_MIDI_CC = 6, // uses index; return answer - HOST_OPCODE_SET_PARAMETER_MIDI_CC = 7, // uses index and value - HOST_OPCODE_SET_PROCESS_PRECISION = 8, // uses value - HOST_OPCODE_UPDATE_PARAMETER = 9, // uses index, -1 for all - HOST_OPCODE_UPDATE_MIDI_PROGRAM = 10, // uses index, -1 for all; may use value for channel - HOST_OPCODE_RELOAD_PARAMETERS = 11, // nothing - HOST_OPCODE_RELOAD_MIDI_PROGRAMS = 12, // nothing - HOST_OPCODE_RELOAD_ALL = 13, // nothing - HOST_OPCODE_UI_UNAVAILABLE = 14 // nothing + HOST_OPCODE_NULL = 0, // nothing + HOST_OPCODE_UPDATE_PARAMETER = 1, // uses index, -1 for all + HOST_OPCODE_UPDATE_MIDI_PROGRAM = 2, // uses index, -1 for all; may use value for channel + HOST_OPCODE_RELOAD_PARAMETERS = 3, // nothing + HOST_OPCODE_RELOAD_MIDI_PROGRAMS = 4, // nothing + HOST_OPCODE_RELOAD_ALL = 5, // nothing + HOST_OPCODE_UI_UNAVAILABLE = 6 // nothing } NativeHostDispatcherOpcode; // ----------------------------------------------------------------------- diff --git a/source/modules/CarlaNative.hpp b/source/modules/CarlaNative.hpp index 5f70cfe30..cc7fe79da 100644 --- a/source/modules/CarlaNative.hpp +++ b/source/modules/CarlaNative.hpp @@ -153,62 +153,6 @@ protected: // ------------------------------------------------------------------- // Host dispatcher calls - void hostSetVolume(const float value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_VOLUME, 0, 0, nullptr, value); - } - - void hostSetDryWet(const float value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_DRYWET, 0, 0, nullptr, value); - } - - void hostSetBalanceLeft(const float value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_BALANCE_LEFT, 0, 0, nullptr, value); - } - - void hostSetBalanceRight(const float value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_BALANCE_RIGHT, 0, 0, nullptr, value); - } - - void hostSetPanning(const float value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_PANNING, 0, 0, nullptr, value); - } - - intptr_t hostGetParameterMidiCC(const int32_t index) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, -1); - - return pHost->dispatcher(pHost->handle, HOST_OPCODE_GET_PARAMETER_MIDI_CC, index, 0, nullptr, 0.0f); - } - - void hostSetParameterMidiCC(const int32_t index, const intptr_t value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_PARAMETER_MIDI_CC, index, value, nullptr, 0.0f); - } - - void hostSetProcessPrecision(const intptr_t value) const - { - CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - - pHost->dispatcher(pHost->handle, HOST_OPCODE_SET_PROCESS_PRECISION, 0, value, nullptr, 0.0f); - } - void hostUpdateParameter(const int32_t index) const { CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); diff --git a/source/modules/native-plugins/lfo.c b/source/modules/native-plugins/lfo.c index b0dce81c5..3d98d8a17 100644 --- a/source/modules/native-plugins/lfo.c +++ b/source/modules/native-plugins/lfo.c @@ -52,8 +52,6 @@ static NativePluginHandle lfo_instantiate(const NativeHostDescriptor* host) if (handle == NULL) return NULL; - host->dispatcher(host->handle, HOST_OPCODE_SET_PROCESS_PRECISION, 0, 32, NULL, 0.0f); - handle->host = host; handle->mode = 1; handle->speed = 1.0f; diff --git a/source/plugin/carla-native-lv2-export.cpp b/source/plugin/carla-native-lv2-export.cpp index 6755226dc..f14f4f924 100644 --- a/source/plugin/carla-native-lv2-export.cpp +++ b/source/plugin/carla-native-lv2-export.cpp @@ -15,9 +15,6 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -// include this first to ignore documentation warnings -#include "CarlaLv2Utils.hpp" - #define CARLA_NATIVE_PLUGIN_LV2 #include "carla-native-base.cpp" diff --git a/source/plugin/carla-native-lv2.cpp b/source/plugin/carla-native-lv2.cpp index 2aea0c208..ab0570677 100644 --- a/source/plugin/carla-native-lv2.cpp +++ b/source/plugin/carla-native-lv2.cpp @@ -15,12 +15,10 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -// include this first to ignore documentation warnings -#include "CarlaLv2Utils.hpp" - #define CARLA_NATIVE_PLUGIN_LV2 #include "carla-native-base.cpp" +#include "CarlaLv2Utils.hpp" #include "CarlaMathUtils.hpp" #include "CarlaString.hpp" @@ -78,8 +76,6 @@ public: fMidiEventCount(0), fTimeInfo(), fIsProcessing(false), - fVolume(1.0f), - fDryWet(1.0f), fBufferSize(0), fSampleRate(sampleRate), fUridMap(nullptr), @@ -253,8 +249,6 @@ public: return; } - const int iframes(static_cast(frames)); - // Check for updated parameters float curValue; @@ -366,7 +360,7 @@ public: } if (speed != nullptr && speed->type == fURIs.atomFloat) - fTimeInfo.playing = ((LV2_Atom_Float*)speed)->body == 1.0f; + fTimeInfo.playing = carla_compareFloats(((LV2_Atom_Float*)speed)->body, 1.0f); continue; } @@ -407,21 +401,6 @@ public: fDescriptor->process(fHandle, fPorts.audioIns, fPorts.audioOuts, frames, fMidiEvents, fMidiEventCount); fIsProcessing = false; - if (fDryWet != 1.0f && fDescriptor->audioIns == fDescriptor->audioOuts) - { - for (uint32_t i=0; i < fDescriptor->audioOuts; ++i) - { - FloatVectorOperations::multiply(fPorts.audioIns[i], fVolume*(1.0f-fDryWet), iframes); - FloatVectorOperations::multiply(fPorts.audioOuts[i], fVolume*fDryWet, iframes); - FloatVectorOperations::add(fPorts.audioOuts[i], fPorts.audioIns[i], iframes); - } - } - else if (fVolume != 1.0f) - { - for (uint32_t i=0; i < fDescriptor->audioOuts; ++i) - FloatVectorOperations::multiply(fPorts.audioOuts[i], fVolume, iframes); - } - // TODO - midi out updateParameterOutputs(); @@ -784,21 +763,6 @@ protected: switch (opcode) { case HOST_OPCODE_NULL: - break; - case HOST_OPCODE_SET_VOLUME: - fVolume = opt; - break; - case HOST_OPCODE_SET_DRYWET: - fDryWet = opt; - break; - case HOST_OPCODE_SET_BALANCE_LEFT: - case HOST_OPCODE_SET_BALANCE_RIGHT: - case HOST_OPCODE_SET_PANNING: - // nothing - break; - case HOST_OPCODE_GET_PARAMETER_MIDI_CC: - case HOST_OPCODE_SET_PARAMETER_MIDI_CC: - case HOST_OPCODE_SET_PROCESS_PRECISION: case HOST_OPCODE_UPDATE_PARAMETER: case HOST_OPCODE_UPDATE_MIDI_PROGRAM: case HOST_OPCODE_RELOAD_PARAMETERS: @@ -817,6 +781,7 @@ protected: (void)index; (void)value; (void)ptr; + (void)opt; } void updateParameterOutputs() @@ -846,9 +811,7 @@ private: NativeMidiEvent fMidiEvents[kMaxMidiEvents*2]; NativeTimeInfo fTimeInfo; - bool fIsProcessing; - float fVolume; - float fDryWet; + bool fIsProcessing; // Lv2 host data uint32_t fBufferSize; diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index 1efa9cef6..aaf55bcaf 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -29,9 +29,6 @@ #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wdocumentation" -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdocumentation" #endif #include "lv2/lv2.h" @@ -76,8 +73,6 @@ // enable -Wdocumentation again #if defined(__clang__) # pragma clang diagnostic pop -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -# pragma GCC diagnostic pop #endif #include "lv2_rdf.hpp"