diff options
author | ronan Le Martret <ronan.lemartret@iot.bzh> | 2017-11-30 14:19:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@automotivelinux.org> | 2017-11-30 14:19:39 +0000 |
commit | 9938a19818ad6fd555b4c46f405141ae2059f9f1 (patch) | |
tree | 136ca573d6dd60d72cb6427220d0643198e0d2f0 | |
parent | 2a8b7aeed1b5217a608032ce1afabadd1166e7c3 (diff) | |
parent | 37bd97c96ac79206518e95abc34933bd8b0f6369 (diff) |
Merge "Change initial volume to be in % in place of absolute values"
-rw-r--r-- | alsa-binding/Alsa-AddCtl.c | 13 | ||||
-rw-r--r-- | 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 <alsa/sound/tlv.h> #include <systemd/sd-event.h> #include <sys/ioctl.h> +#include <math.h> #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 @@ </cTool> </item> <item path="alsa-binding/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> - <pElem>../../../opt/include/alsa</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="alsa-binding/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> - <pElem>/usr/include/json-c</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - <incDir> - <pElem>../../../opt/include/alsa</pElem> - <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> - </incDir> + <cTool flags="0"> </cTool> </item> <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="0"> + </cTool> + </item> + <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="alsa-hook/PolicyAlsaHook.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> <incDir> - <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/json-c</pElem> <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> + <pElem>/usr/include/p11-kit-1</pElem> + <pElem>../../../opt/include/alsa</pElem> + <pElem>build/alsa-hook</pElem> </incDir> + <preprocessorList> + <Elem>CONTROL_MAXPATH_LEN=255</Elem> + <Elem>MAX_LINEAR_DB_SCALE=24</Elem> + <Elem>MAX_SND_CARD=16</Elem> + <Elem>NATIVE_LINUX</Elem> + <Elem>PIC</Elem> + <Elem>TLV_BYTE_SIZE=256</Elem> + <Elem>policy_alsa_hook_EXPORTS</Elem> + </preprocessorList> </cTool> </item> - <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3"> + <item path="alsa-hook/PolicyHookTcp.c" ex="false" tool="0" flavor2="3"> <cTool flags="2"> <incDir> + <pElem>alsa-hook</pElem> <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/json-c</pElem> + <pElem>../../../opt/include/afb</pElem> <pElem>../../../opt/include</pElem> - <pElem>build/alsa-binding</pElem> + <pElem>build/alsa-hook</pElem> </incDir> </cTool> </item> - <item path="alsa-hook/PolicyAlsaHook.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - </cTool> - </item> - <item path="alsa-hook/PolicyHookTcp.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> - </cTool> - </item> <folder path="0/Audio-Common"> <cTool> <incDir> @@ -758,21 +754,20 @@ <folder path="0/alsa-binding"> <cTool> <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> - </incDir> - </cTool> - </folder> - <folder path="0/alsa-hook"> - <cTool> - <incDir> - <pElem>alsa-hook</pElem> - <pElem>../../../opt/include/alsa</pElem> <pElem>/usr/include/json-c</pElem> - <pElem>../../../opt/include/afb</pElem> <pElem>../../../opt/include</pElem> - <pElem>build/alsa-hook</pElem> + <pElem>/usr/include/p11-kit-1</pElem> + <pElem>../../../opt/include/alsa</pElem> + <pElem>build/alsa-binding</pElem> </incDir> + <preprocessorList> + <Elem>CONTROL_MAXPATH_LEN=255</Elem> + <Elem>MAX_LINEAR_DB_SCALE=24</Elem> + <Elem>MAX_SND_CARD=16</Elem> + <Elem>NATIVE_LINUX</Elem> + <Elem>TLV_BYTE_SIZE=256</Elem> + <Elem>alsa_4a_EXPORTS</Elem> + </preprocessorList> </cTool> </folder> </conf> |