From 11133beedd85c5912500b9b9b9e49b0654124934 Mon Sep 17 00:00:00 2001 From: Iscle Date: Wed, 10 Apr 2024 00:34:22 +0200 Subject: [PATCH] Fix DynamicSystem parameter types --- src/ViperContext.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ViperContext.cpp b/src/ViperContext.cpp index 5be1dfe..c288cdb 100644 --- a/src/ViperContext.cpp +++ b/src/ViperContext.cpp @@ -559,22 +559,22 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData return 0; } case PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS: { - if (pCmdParam->vsize != sizeof(uint32_t) * 2) { - VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint32_t) * 2); + if (pCmdParam->vsize != sizeof(uint16_t) * 2) { + VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2); return -EINVAL; } - uint32_t low = *(uint32_t *) (pCmdParam->data + vOffset); - uint32_t high = *(uint32_t *) (pCmdParam->data + vOffset + sizeof(uint32_t)); + uint16_t low = *(uint16_t *) (pCmdParam->data + vOffset); + uint16_t high = *(uint16_t *) (pCmdParam->data + vOffset + sizeof(uint16_t)); VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with low = %d, high = %d", low, high); viper.dynamicSystem.SetXCoeffs(low, high); } case PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS: { - if (pCmdParam->vsize != sizeof(uint32_t) * 2) { - VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint32_t) * 2); + if (pCmdParam->vsize != sizeof(uint16_t) * 2) { + VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2); return -EINVAL; } - uint32_t low = *(uint32_t *) (pCmdParam->data + vOffset); - uint32_t high = *(uint32_t *) (pCmdParam->data + vOffset + sizeof(uint32_t)); + uint16_t low = *(uint16_t *) (pCmdParam->data + vOffset); + uint16_t high = *(uint16_t *) (pCmdParam->data + vOffset + sizeof(uint16_t)); VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with low = %d, high = %d", low, high); viper.dynamicSystem.SetYCoeffs(low, high); } @@ -589,11 +589,11 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData viper.dynamicSystem.SetSideGain(static_cast(gainX) / 100.0f, static_cast(gainY) / 100.0f); } case PARAM_SET_DYNAMIC_SYSTEM_STRENGTH: { - if (pCmdParam->vsize != sizeof(uint8_t)) { - VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t)); + if (pCmdParam->vsize != sizeof(uint16_t)) { + VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t)); return -EINVAL; } - uint8_t strength = *(uint8_t *) (pCmdParam->data + vOffset); + uint16_t strength = *(uint16_t *) (pCmdParam->data + vOffset); VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with strength = %d", strength); viper.dynamicSystem.SetBassGain(static_cast(strength) / 100.0f); }