diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-05 15:35:11 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-05 15:35:11 +0100 |
commit | d52e5cf217ac3dfd348e80e26eb6d8844c78fc1e (patch) | |
tree | 94c4321be207e270bcbcb9160ecbf52bab9d89ee | |
parent | e5742e9244b21a866a1dc15b618a11a4e515e019 (diff) |
Updated to support search value in response to be interger
-rw-r--r-- | alsa-hook/PolicyAlsaHook.c | 51 | ||||
-rw-r--r-- | nbproject/configurations.xml | 146 |
2 files changed, 106 insertions, 91 deletions
diff --git a/alsa-hook/PolicyAlsaHook.c b/alsa-hook/PolicyAlsaHook.c index 3fbf40e..6f88bca 100644 --- a/alsa-hook/PolicyAlsaHook.c +++ b/alsa-hook/PolicyAlsaHook.c @@ -78,6 +78,7 @@ typedef struct { typedef struct { const char *search; const char *value; + long ivalue; int signal; } afbEventT; @@ -136,7 +137,7 @@ void OnEventCB(void *handle, const char *event, int evtid, struct json_object *d afbClientT *afbClient = (afbClientT*) handle; afbEventT **afbEvent = afbClient->event; json_object *tmpJ; - int done; + int signal=0, index; // if no event handler just ignore events if (!afbEvent) goto OnErrorExit; @@ -144,17 +145,32 @@ void OnEventCB(void *handle, const char *event, int evtid, struct json_object *d if (afbClient->verbose) printf("ON-EVENT processing signal event=%s search=%s\n", event, json_object_get_string(dataJ)); // loop on event/signal mapping table - for (int index=0; afbEvent[index]!= NULL; index++) { + for (index=0; afbEvent[index]!= NULL; index++) { + int done; + done = json_object_object_get_ex(dataJ,afbEvent[index]->search, &tmpJ); if (done) { - const char *value=json_object_get_string(tmpJ); - if (!strcmp(afbEvent[index]->value, value)) { - if (afbEvent[index]->signal) { - if (afbClient->verbose) printf("ON-EVENT search=%s value=%s signal=%d\n", afbEvent[index]->search, value, afbEvent[index]->signal); - if (afbEvent[index]->signal) kill (getpid(), afbEvent[index]->signal); - } + + if (afbEvent[index]->value) { + // search value is a string + if (json_object_get_type(tmpJ) != json_type_string) goto OnErrorExit; + const char *value=json_object_get_string(tmpJ); + if (!strcmp(afbEvent[index]->value, value)) signal=afbEvent[index]->signal; + + } else { + + // search value is an integer + if (json_object_get_type(tmpJ) != json_type_int) goto OnErrorExit; + int ivalue=json_object_get_int(tmpJ); + if (ivalue == afbEvent[index]->ivalue) signal=afbEvent[index]->signal; } - } + break; + + } + } + if (signal) { + if (afbClient->verbose) printf("ON-EVENT self-signal search=%s signal=%d\n", afbEvent[index]->search, afbEvent[index]->signal); + if (afbEvent[index]->signal) kill (getpid(), afbEvent[index]->signal); } return; @@ -503,17 +519,24 @@ static int AlsaGetEvents (snd_config_t *node, afbEventT **afbEvent, const char*i err = snd_config_search(ctlconfig, "value", &itemConf); if (!err) { const char *value; - if (snd_config_get_string(itemConf, &value) < 0) { - SNDERR("Invalid event/signal 'value' should be a string %s", confEvents); - goto OnErrorExit; + switch (snd_config_get_type(itemConf)) { + case SND_CONFIG_TYPE_INTEGER: + snd_config_get_integer(itemConf, &afbEvent[callCount]->ivalue); + break; + + case SND_CONFIG_TYPE_STRING: + snd_config_get_string(itemConf, &value); + afbEvent[callCount]->value=strdup(value); + break; + default: + SNDERR("Invalid event/signal 'value' should be a string %s", confEvents); + goto OnErrorExit; } - afbEvent[callCount]->value=strdup(value); } else { SNDERR("Missing 'value' from event/signal 'value' from signal definition %s", confEvents); goto OnErrorExit; } - // move to next call if any callCount ++; if (callCount == MAX_EVT_CALL) { diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 4bd0c69..75116a1 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -1416,11 +1416,12 @@ <rebuildPropChanged>false</rebuildPropChanged> </toolsSet> <flagsDictionary> - <element flagsID="0" commonFlags="-g -fPIC -fPIC -g"/> - <element flagsID="1" commonFlags="-mtune=generic -march=x86-64 -fPIC"/> - <element flagsID="2" commonFlags="-mtune=generic -march=x86-64 -g -fPIC"/> - <element flagsID="3" commonFlags="-mtune=generic -march=x86-64 -g -g -fPIC"/> - <element flagsID="4" + <element flagsID="0" commonFlags="-g -fPIC -fPIC"/> + <element flagsID="1" commonFlags="-g -fPIC -fPIC -g"/> + <element flagsID="2" commonFlags="-mtune=generic -march=x86-64 -fPIC"/> + <element flagsID="3" commonFlags="-mtune=generic -march=x86-64 -g -fPIC"/> + <element flagsID="4" commonFlags="-mtune=generic -march=x86-64 -g -g -fPIC"/> + <element flagsID="5" commonFlags="-mtune=generic -march=x86-64 -g -ggdb -g -ggdb -fPIC"/> </flagsDictionary> <codeAssistance> @@ -1429,10 +1430,10 @@ <makefileType> <makeTool> <buildCommandWorkingDir>build</buildCommandWorkingDir> - <buildCommand>${MAKE} -f Makefile populate</buildCommand> + <buildCommand>${MAKE} -f Makefile</buildCommand> <cleanCommand>${MAKE} -f Makefile clean</cleanCommand> <executablePath>build/CMakeFiles/feature_tests.bin</executablePath> - <cTool flags="2"> + <cTool flags="3"> </cTool> </makeTool> <preBuild> @@ -1442,7 +1443,7 @@ </preBuild> </makefileType> <item path="Audio-Common/audio-common.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>Audio-Common</pElem> @@ -1452,7 +1453,7 @@ </cTool> </item> <item path="Audio-Common/filescan-utils.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>Audio-Common</pElem> @@ -1462,7 +1463,7 @@ </cTool> </item> <item path="Audio-Common/wrap-json.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>Audio-Common</pElem> <pElem>/usr/include/json-c</pElem> @@ -1471,18 +1472,18 @@ </cTool> </item> <item path="Common/AudioCommonLib.c" ex="false" tool="0" flavor2="2"> - <cTool flags="0"> + <cTool flags="1"> </cTool> </item> <item path="Controller-afb/ctl-binding.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>build/Controller-afb</pElem> </incDir> </cTool> </item> <item path="Controller-afb/ctl-dispatch.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/lua5.3</pElem> @@ -1493,7 +1494,7 @@ </cTool> </item> <item path="Controller-afb/ctl-lua.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/lua5.3</pElem> @@ -1504,7 +1505,7 @@ </cTool> </item> <item path="Controller-afb/ctl-misc.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>/usr/include/json-c</pElem> <pElem>build/Controller-afb</pElem> @@ -1512,7 +1513,7 @@ </cTool> </item> <item path="Controller-afb/ctl-plugin-sample.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>/usr/include/json-c</pElem> <pElem>/usr/include/lua5.3</pElem> @@ -1521,7 +1522,7 @@ </cTool> </item> <item path="Controller-afb/ctl-timer.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include</pElem> <pElem>build/Controller-afb</pElem> @@ -1532,7 +1533,7 @@ ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>Audio-Common</pElem> <pElem>build/HAL-afb/HAL-interface</pElem> @@ -1543,7 +1544,7 @@ ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>Audio-Common</pElem> <pElem>build/HAL-afb/HAL-interface</pElem> @@ -1551,21 +1552,21 @@ </cTool> </item> <item path="HAL-afb/HAL-interface/hal-volume.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>build/HAL-afb/HAL-interface</pElem> </incDir> </cTool> </item> <item path="HAL-afb/HAL-plugin/HalPlugPcm.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> </cTool> </item> <item path="HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>HAL-afb/HAL_MOST_UNICENS</pElem> @@ -1579,35 +1580,35 @@ ex="false" tool="1" flavor2="4"> - <ccTool flags="1"> + <ccTool flags="2"> </ccTool> </item> <item path="HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp" ex="false" tool="1" flavor2="4"> - <ccTool flags="1"> + <ccTool flags="2"> </ccTool> </item> <item path="HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp" ex="false" tool="1" flavor2="4"> - <ccTool flags="1"> + <ccTool flags="2"> </ccTool> </item> <item path="HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/setup.cpp" ex="false" tool="1" flavor2="4"> - <ccTool flags="1"> + <ccTool flags="2"> </ccTool> </item> <item path="HAL-afb/HAL_MOST_UNICENS/wrap-json.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>HAL-afb/HAL_MOST_UNICENS</pElem> <pElem>build/HAL-afb/HAL_MOST_UNICENS</pElem> @@ -1618,7 +1619,7 @@ ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>HAL-afb/HAL_MOST_UNICENS</pElem> @@ -1630,7 +1631,7 @@ ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>HAL-afb/HAL_MOST_UNICENS</pElem> @@ -1640,25 +1641,25 @@ </cTool> </item> <item path="HAL-afb/HDA-intel/IntelHdaHAL.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> </cTool> </item> <item path="HAL-afb/Jabra-Solemate/JabraUsbHAL.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> </cTool> </item> <item path="HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> </cTool> </item> <item path="HAL-afb/Unicens-USB/UnicensHAL.c" ex="false" tool="0" flavor2="3"> - <cTool flags="4"> + <cTool flags="5"> <incDir> <pElem>Shared-Interface</pElem> <pElem>HAL-afb/HAL-interface</pElem> @@ -1667,7 +1668,7 @@ </cTool> </item> <item path="HAL-afb/Unicens-USB/UnicensVol.c" ex="false" tool="0" flavor2="3"> - <cTool flags="4"> + <cTool flags="5"> <incDir> <pElem>HAL-afb/HAL-interface</pElem> <pElem>build/HAL-afb/Unicens-USB</pElem> @@ -1675,11 +1676,11 @@ </cTool> </item> <item path="HighLevel-afb/HighLevelApiConf.c" ex="false" tool="0" flavor2="3"> - <cTool flags="3"> + <cTool flags="4"> </cTool> </item> <item path="HighLevel-afb/HighLevelBinding.c" ex="false" tool="0" flavor2="3"> - <cTool flags="3"> + <cTool flags="4"> </cTool> </item> <item path="MostVolume/DeviceContainer.cpp" ex="false" tool="1" flavor2="4"> @@ -1717,7 +1718,7 @@ <item path="MostVolume/libmostvolume.cpp" ex="false" tool="1" flavor2="4"> </item> <item path="afb-utilities/filescan-utils.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-utilities</pElem> @@ -1727,7 +1728,7 @@ </cTool> </item> <item path="afb-utilities/wrap-json.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="3"> <incDir> <pElem>afb-utilities</pElem> <pElem>/usr/include/json-c</pElem> @@ -1736,55 +1737,27 @@ </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"> - <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-Ucm.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-hook/PolicyAlsaHook.c" ex="false" tool="0" flavor2="3"> - <cTool flags="2"> + <cTool flags="0"> </cTool> </item> <folder path="0/Common"> @@ -2024,21 +1997,40 @@ <folder path="0/alsa-binding"> <cTool> <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>alsa-binding</pElem> + <pElem>/usr/include/json-c</pElem> + <pElem>../../../opt/include</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> <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>/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> </folder> </conf> |