diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-06-06 09:43:10 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-06-14 16:02:58 +0200 |
commit | 66bf020290892b19fb61a01f260e47cd5ff35f3e (patch) | |
tree | cb0cc99c91e9d67e0445cf4b47bbb1fe228166d8 /alsa-binding/Alsa-SetGet.c | |
parent | 3248ce4154f503f0f63ffda0313caa3a482b4084 (diff) |
Add an option to 'ctlget' verb
Add a new way to ask for alsa controls info by implementing the
possibility to ask for alsa control using its label.
It is a clean way to get control numid using control label.
Bug-AGL: SPEC-1405
Change-Id: If5387c63a41a07d451a21edab86e9bb90b4908c4
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'alsa-binding/Alsa-SetGet.c')
-rw-r--r-- | alsa-binding/Alsa-SetGet.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c index 6681415..9ed316c 100644 --- a/alsa-binding/Alsa-SetGet.c +++ b/alsa-binding/Alsa-SetGet.c @@ -64,6 +64,13 @@ PUBLIC void NumidsListParse(ActionSetGetT action, queryValuesT *queryValues, ctl } else break; + case json_type_string: + if(action == ACTION_GET) { + ctlRequest[idx].tag = json_object_get_string(ctlRequest[idx].jToken); + ctlRequest[idx].numId = 0; + } + break; + case json_type_array: // NUMID is an array 1st slot should be numid, optionally values may come after length = json_object_array_length(ctlRequest[idx].jToken); @@ -726,6 +733,7 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) { case json_type_int: case json_type_object: + case json_type_string: queryValues.count = 1; queryValues.numidsJ = numidsJ; break; @@ -780,13 +788,15 @@ STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) { jdx = ctlIndex; // map all existing ctl as requested } else { int numid = snd_ctl_elem_list_get_numid(ctlList, ctlIndex); + const char *tag = snd_ctl_elem_list_get_name(ctlList, ctlIndex); if (numid < 0) { AFB_NOTICE("snd_ctl_elem_list_get_numid index=%d fail", ctlIndex); continue; } // check if current control was requested in query numids list for (jdx = 0; jdx < queryValues.count; jdx++) { - if (numid == ctlRequest[jdx].numId) { + if (numid == ctlRequest[jdx].numId || ! strcasecmp(tag, ctlRequest[jdx].tag)) { + ctlRequest[jdx].numId = numid; selected = 1; break; } |