From eba201b583be0ac17f851635920d7269366e5b79 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 12 Jan 2026 14:19:51 +0100 Subject: [PATCH] Catch invalid parameter designation use in runtime-test builds Signed-off-by: falkTX --- distrho/src/DistrhoPluginInternal.hpp | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp index d0bef80a..fdcda69e 100644 --- a/distrho/src/DistrhoPluginInternal.hpp +++ b/distrho/src/DistrhoPluginInternal.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -352,9 +352,44 @@ public: } #endif // DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0 + #ifdef DPF_RUNTIME_TESTING + uint32_t parameterDesignationBypass = UINT32_MAX; + uint32_t parameterDesignationReset = UINT32_MAX; + #endif + for (uint32_t i=0, count=fData->parameterCount; i < count; ++i) + { fPlugin->initParameter(i, fData->parameters[i]); + #ifdef DPF_RUNTIME_TESTING + switch (fData->parameters[i].designation) + { + case kParameterDesignationNull: + break; + case kParameterDesignationBypass: + if (parameterDesignationBypass != UINT32_MAX) + { + d_stderr2("DPF warning: Bypass parameter designation used more than once"); + abort(); + } + parameterDesignationBypass = i; + break; + case kParameterDesignationReset: + if (parameterDesignationReset != UINT32_MAX) + { + d_stderr2("DPF warning: Reset parameter designation used more than once"); + abort(); + } + parameterDesignationReset = i; + break; + default: + d_stderr2("DPF warning: Invalid parameter designation %d (for index %u)", fData->parameters[i].designation, i); + abort(); + break; + } + #endif + } + { std::set portGroupIndices;