diff --git a/source/Makefile.mk b/source/Makefile.mk index 758f28268..6e070da88 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -162,7 +162,7 @@ endif # Strict test build ifeq ($(TESTBUILD),true) -BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations +BASE_FLAGS += -Werror -Wabi=98 -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing BASE_FLAGS += -Wstrict-overflow -fstrict-overflow diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 3ca819f82..f245e00a1 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -289,6 +289,11 @@ struct CARLA_API EngineTimeInfoBBT { double ticksPerBeat; double beatsPerMinute; + /*! + * Clear. + */ + void clear() noexcept; + #ifndef DOXYGEN EngineTimeInfoBBT() noexcept; EngineTimeInfoBBT(const EngineTimeInfoBBT&) noexcept; diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 96ba5d082..079ceca1c 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -264,6 +264,11 @@ typedef struct _CarlaTransportInfo { * C++ constructor. */ CARLA_API _CarlaTransportInfo() noexcept; + + /*! + * Clear struct contents. + */ + CARLA_API void clear() noexcept; #endif } CarlaTransportInfo; diff --git a/source/backend/CarlaHostCommon.cpp b/source/backend/CarlaHostCommon.cpp index f2202df48..3ed008e59 100644 --- a/source/backend/CarlaHostCommon.cpp +++ b/source/backend/CarlaHostCommon.cpp @@ -96,6 +96,16 @@ _CarlaTransportInfo::_CarlaTransportInfo() noexcept tick(0), bpm(0.0) {} +void _CarlaTransportInfo::clear() noexcept +{ + playing = false; + frame = 0; + bar = 0; + beat = 0; + tick = 0; + bpm = 0.0; +} + // ------------------------------------------------------------------------------------------------------------------- const char* carla_get_library_filename() diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 49900ed86..7c6bf32b2 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -857,7 +857,7 @@ uint64_t carla_get_current_transport_frame() const CarlaTransportInfo* carla_get_transport_info() { static CarlaTransportInfo retTransInfo; - carla_zeroStruct(retTransInfo); + retTransInfo.clear(); CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr && gStandalone.engine->isRunning(), &retTransInfo); diff --git a/source/backend/engine/CarlaEngineData.cpp b/source/backend/engine/CarlaEngineData.cpp index cb4c9e5b0..441da65a2 100644 --- a/source/backend/engine/CarlaEngineData.cpp +++ b/source/backend/engine/CarlaEngineData.cpp @@ -315,6 +315,19 @@ EngineTimeInfoBBT::EngineTimeInfoBBT(const EngineTimeInfoBBT& bbt) noexcept ticksPerBeat(bbt.ticksPerBeat), beatsPerMinute(bbt.beatsPerMinute) {} +void EngineTimeInfoBBT::clear() noexcept +{ + valid = false; + bar = 0; + beat = 0; + tick = 0.0; + barStartTick = 0.0; + beatsPerBar = 0.0f; + beatType = 0.0f; + ticksPerBeat = 0.0; + beatsPerMinute = 0.0; +} + // ----------------------------------------------------------------------- // EngineTimeInfo @@ -329,7 +342,7 @@ void EngineTimeInfo::clear() noexcept playing = false; frame = 0; usecs = 0; - carla_zeroStruct(bbt); + bbt.clear(); } EngineTimeInfo::EngineTimeInfo(const EngineTimeInfo& info) noexcept @@ -345,7 +358,7 @@ EngineTimeInfo& EngineTimeInfo::operator=(const EngineTimeInfo& info) noexcept usecs = info.usecs; bbt.valid = info.bbt.valid; bbt.bar = info.bbt.bar; - bbt.tick = info.bbt.tick; + bbt.beat = info.bbt.beat; bbt.tick = info.bbt.tick; bbt.barStartTick = info.bbt.barStartTick; bbt.beatsPerBar = info.bbt.beatsPerBar; diff --git a/source/backend/plugin/CarlaPluginDSSI.cpp b/source/backend/plugin/CarlaPluginDSSI.cpp index b9e664931..69b8b530d 100644 --- a/source/backend/plugin/CarlaPluginDSSI.cpp +++ b/source/backend/plugin/CarlaPluginDSSI.cpp @@ -2214,7 +2214,7 @@ public: CARLA_SAFE_ASSERT_RETURN(std::strcmp(msgport, ourport) == 0,); } - const lo_arg* const* const argv(static_cast(argvx)); + const lo_arg* const* const argv(static_cast(argvx)); if (std::strcmp(method, "configure") == 0) return handleOscMessageConfigure(argc, argv, types); diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp index 11db81b61..be9e720a0 100644 --- a/source/backend/plugin/CarlaPluginFluidSynth.cpp +++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp @@ -329,6 +329,7 @@ public: std::strncpy(strBuf, "Triangle wave", STR_MAX); return; } + break; case FluidSynthInterpolation: switch (scalePointId) { @@ -345,6 +346,7 @@ public: std::strncpy(strBuf, "Seventh-order", STR_MAX); return; } + break; } CarlaPlugin::getParameterScalePointLabel(parameterId, scalePointId, strBuf); diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index 8d0b86c6b..7501eda8f 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -2941,7 +2941,7 @@ public: pData->postRtEvents.trySplice(); - carla_copyStruct(fLastTimeInfo, timeInfo); + fLastTimeInfo = timeInfo; } // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index ac6e2e23f..c6674731a 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -1139,7 +1139,7 @@ public: if (fFirstActive || ! fLastTimeInfo.compareIgnoringRollingFrames(timeInfo, fBufferSize)) { fTimeInfo.flags |= kVstTransportChanged; - carla_copyStruct(fLastTimeInfo, timeInfo); + fLastTimeInfo = timeInfo; } if (timeInfo.playing) @@ -2491,10 +2491,10 @@ private: const int32_t chunkSize = fxbSwap(set[39]); CARLA_SAFE_ASSERT_RETURN(chunkSize > 0, false); - if (static_cast(chunkSize + 160) > dataSize) + if (static_cast(chunkSize + 160) > dataSize) return false; - setChunkData(&set[40], static_cast(chunkSize)); + setChunkData(&set[40], static_cast(chunkSize)); return true; } diff --git a/source/bridges-plugin/CarlaBridgeSingleLV2.cpp b/source/bridges-plugin/CarlaBridgeSingleLV2.cpp index 8a45b77cf..7225bcffa 100644 --- a/source/bridges-plugin/CarlaBridgeSingleLV2.cpp +++ b/source/bridges-plugin/CarlaBridgeSingleLV2.cpp @@ -29,6 +29,13 @@ #include "water/files/File.h" +template<> +void Lv2PluginBaseClass::clearTimeData() noexcept +{ + fLastPositionData.clear(); + fTimeInfo.clear(); +} + // -------------------------------------------------------------------------------------------------------------------- CARLA_BACKEND_START_NAMESPACE diff --git a/source/includes/lv2/atom-util.h b/source/includes/lv2/atom-util.h index 3ca490f85..73cae6457 100644 --- a/source/includes/lv2/atom-util.h +++ b/source/includes/lv2/atom-util.h @@ -130,15 +130,15 @@ lv2_atom_sequence_next(const LV2_Atom_Event* i) @endcode */ #define LV2_ATOM_SEQUENCE_FOREACH(seq, iter) \ - for (const LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(&(seq)->body); \ + for (const LV2_Atom_Event* iter = lv2_atom_sequence_begin(&(seq)->body); \ !lv2_atom_sequence_is_end(&(seq)->body, (seq)->atom.size, (iter)); \ - (iter) = lv2_atom_sequence_next(iter)) + iter = lv2_atom_sequence_next(iter)) /** Like LV2_ATOM_SEQUENCE_FOREACH but for a headerless sequence body. */ #define LV2_ATOM_SEQUENCE_BODY_FOREACH(body, size, iter) \ - for (const LV2_Atom_Event* (iter) = lv2_atom_sequence_begin(body); \ + for (const LV2_Atom_Event* iter = lv2_atom_sequence_begin(body); \ !lv2_atom_sequence_is_end(body, size, (iter)); \ - (iter) = lv2_atom_sequence_next(iter)) + iter = lv2_atom_sequence_next(iter)) /** @} @@ -227,15 +227,15 @@ lv2_atom_tuple_next(const LV2_Atom* i) @endcode */ #define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \ - for (const LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \ + for (const LV2_Atom* iter = lv2_atom_tuple_begin(tuple); \ !lv2_atom_tuple_is_end(LV2_ATOM_BODY_CONST(tuple), (tuple)->atom.size, (iter)); \ - (iter) = lv2_atom_tuple_next(iter)) + iter = lv2_atom_tuple_next(iter)) /** Like LV2_ATOM_TUPLE_FOREACH but for a headerless tuple body. */ #define LV2_ATOM_TUPLE_BODY_FOREACH(body, size, iter) \ - for (const LV2_Atom* (iter) = (const LV2_Atom*)body; \ + for (const LV2_Atom* iter = (const LV2_Atom*)body; \ !lv2_atom_tuple_is_end(body, size, (iter)); \ - (iter) = lv2_atom_tuple_next(iter)) + iter = lv2_atom_tuple_next(iter)) /** @} @@ -283,15 +283,15 @@ lv2_atom_object_next(const LV2_Atom_Property_Body* i) @endcode */ #define LV2_ATOM_OBJECT_FOREACH(obj, iter) \ - for (const LV2_Atom_Property_Body* (iter) = lv2_atom_object_begin(&(obj)->body); \ + for (const LV2_Atom_Property_Body* iter = lv2_atom_object_begin(&(obj)->body); \ !lv2_atom_object_is_end(&(obj)->body, (obj)->atom.size, (iter)); \ - (iter) = lv2_atom_object_next(iter)) + iter = lv2_atom_object_next(iter)) /** Like LV2_ATOM_OBJECT_FOREACH but for a headerless object body. */ #define LV2_ATOM_OBJECT_BODY_FOREACH(body, size, iter) \ - for (const LV2_Atom_Property_Body* (iter) = lv2_atom_object_begin(body); \ + for (const LV2_Atom_Property_Body* iter = lv2_atom_object_begin(body); \ !lv2_atom_object_is_end(body, size, (iter)); \ - (iter) = lv2_atom_object_next(iter)) + iter = lv2_atom_object_next(iter)) /** @} diff --git a/source/modules/lilv/lilv-0.24.0/lilv/lilv.h b/source/modules/lilv/lilv-0.24.0/lilv/lilv.h index 760f7b5f4..725b98a76 100644 --- a/source/modules/lilv/lilv-0.24.0/lilv/lilv.h +++ b/source/modules/lilv/lilv-0.24.0/lilv/lilv.h @@ -353,9 +353,9 @@ lilv_node_as_bool(const LilvNode* value); @endcode */ #define LILV_FOREACH(colltype, iter, collection) \ - for (LilvIter* (iter) = lilv_ ## colltype ## _begin(collection); \ + for (LilvIter* iter = lilv_ ## colltype ## _begin(collection); \ !lilv_ ## colltype ## _is_end(collection, iter); \ - (iter) = lilv_ ## colltype ## _next(collection, iter)) + iter = lilv_ ## colltype ## _next(collection, iter)) /* LilvPluginClasses */ diff --git a/source/plugin/carla-lv2.cpp b/source/plugin/carla-lv2.cpp index 11a54fbdf..1fb2c6e43 100644 --- a/source/plugin/carla-lv2.cpp +++ b/source/plugin/carla-lv2.cpp @@ -25,6 +25,12 @@ #include "water/files/File.h" +template<> +void Lv2PluginBaseClass::clearTimeData() noexcept +{ + fLastPositionData.clear(); + carla_zeroStruct(fTimeInfo); +} // -------------------------------------------------------------------------------------------------------------------- // Carla Internal Plugin API exposed as LV2 plugin diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index fb32fb360..8c98c1068 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -646,8 +646,7 @@ public: fWorker = worker; - carla_zeroStruct(fTimeInfo); - carla_zeroStruct(fLastPositionData); + clearTimeData(); } virtual ~Lv2PluginBaseClass() {} @@ -1137,6 +1136,19 @@ protected: virtual void handleBufferSizeChanged(const uint32_t bufferSize) = 0; virtual void handleSampleRateChanged(const double sampleRate) = 0; + void resetTimeInfo() noexcept + { + clearTimeData(); + + // hosts may not send all values, resulting on some invalid data + fTimeInfo.bbt.bar = 1; + fTimeInfo.bbt.beat = 1; + fTimeInfo.bbt.beatsPerBar = 4; + fTimeInfo.bbt.beatType = 4; + fTimeInfo.bbt.ticksPerBeat = fLastPositionData.ticksPerBeat = 960.0; + fTimeInfo.bbt.beatsPerMinute = fLastPositionData.beatsPerMinute = 120.0; + } + // LV2 host data bool fIsActive : 1; bool fIsOffline : 1; @@ -1172,21 +1184,21 @@ protected: frame(0), speed(0.0), ticksPerBeat(-1.0) {} - } fLastPositionData; - void resetTimeInfo() - { - carla_zeroStruct(fLastPositionData); - carla_zeroStruct(fTimeInfo); + void clear() + { + bar = -1; + bar_f = -1.0f; + barBeat = -1.0f; + beatUnit = 0; + beatsPerBar = 0.0f; + beatsPerMinute = -1.0; + frame = 0; + speed = 0.0; + ticksPerBeat = -1.0; + } - // hosts may not send all values, resulting on some invalid data - fTimeInfo.bbt.bar = 1; - fTimeInfo.bbt.beat = 1; - fTimeInfo.bbt.beatsPerBar = 4; - fTimeInfo.bbt.beatType = 4; - fTimeInfo.bbt.ticksPerBeat = fLastPositionData.ticksPerBeat = 960.0; - fTimeInfo.bbt.beatsPerMinute = fLastPositionData.beatsPerMinute = 120.0; - } + } fLastPositionData; // Port stuff struct Ports { @@ -1544,6 +1556,10 @@ private: // ---------------------------------------------------------------------------------------------------------------- + void clearTimeData() noexcept; + + // ---------------------------------------------------------------------------------------------------------------- + CARLA_DECLARE_NON_COPY_STRUCT(Lv2PluginBaseClass) };