From b5007352099457ef9d9ff5bb757af605ef927b16 Mon Sep 17 00:00:00 2001 From: Ronan Le Martret Date: Tue, 19 Dec 2017 03:02:57 +0100 Subject: Change initial volume to be in % in place of absolute values Signed-off-by: Fulup Ar Foll Signed-off-by: Ronan Le Martret --- alsa-binding/Alsa-AddCtl.c | 13 ++++++- nbproject/configurations.xml | 83 +++++++++++++++++++++----------------------- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/alsa-binding/Alsa-AddCtl.c b/alsa-binding/Alsa-AddCtl.c index 82a6dac..a1da706 100644 --- a/alsa-binding/Alsa-AddCtl.c +++ b/alsa-binding/Alsa-AddCtl.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "Alsa-ApiHat.h" @@ -299,7 +300,17 @@ UpdateDefaultVal: // Set Value to default snd_ctl_elem_value_alloca(&elemValue); for (int idx = 0; idx < snd_ctl_elem_info_get_count(elemInfo); idx++) { - snd_ctl_elem_value_set_integer(elemValue, idx, ctlValue); + + // initial default value should be a percentage for integer + if (snd_ctl_elem_info_get_type(elemInfo) == SND_CTL_ELEM_TYPE_INTEGER) { + double min = (double)snd_ctl_elem_info_get_min(elemInfo); + double max = (double)snd_ctl_elem_info_get_max(elemInfo); + double normValue = ceil((ctlValue) * (max - min) * 0.01 + min); + snd_ctl_elem_value_set_integer(elemValue, idx, (int)normValue); + + } else { + snd_ctl_elem_value_set_integer(elemValue, idx, ctlValue); + } } // write default values in newly created control diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 4d6ec63..986f648 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -473,61 +473,57 @@ - - - ../../../opt/include/alsa - /usr/include/json-c - ../../../opt/include - build/alsa-binding - + - - - /usr/include/json-c - build/alsa-binding - + - - - ../../../opt/include/alsa - /usr/include/json-c - ../../../opt/include - build/alsa-binding - + - + + + + + + + + + - ../../../opt/include/alsa /usr/include/json-c ../../../opt/include - build/alsa-binding + /usr/include/p11-kit-1 + ../../../opt/include/alsa + build/alsa-hook + + CONTROL_MAXPATH_LEN=255 + MAX_LINEAR_DB_SCALE=24 + MAX_SND_CARD=16 + NATIVE_LINUX + PIC + TLV_BYTE_SIZE=256 + policy_alsa_hook_EXPORTS + - + + alsa-hook ../../../opt/include/alsa /usr/include/json-c + ../../../opt/include/afb ../../../opt/include - build/alsa-binding + build/alsa-hook - - - - - - - - @@ -758,21 +754,20 @@ - ../../../opt/include/afb - alsa-binding - - - - - - - alsa-hook - ../../../opt/include/alsa /usr/include/json-c - ../../../opt/include/afb ../../../opt/include - build/alsa-hook + /usr/include/p11-kit-1 + ../../../opt/include/alsa + build/alsa-binding + + CONTROL_MAXPATH_LEN=255 + MAX_LINEAR_DB_SCALE=24 + MAX_SND_CARD=16 + NATIVE_LINUX + TLV_BYTE_SIZE=256 + alsa_4a_EXPORTS + -- cgit 1.2.3-korg