aboutsummaryrefslogtreecommitdiffstats
path: root/alsa-binding
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-06 09:43:10 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-06 16:50:58 +0000
commitf713de4da7b34e030c5f9ac226f3e615c1c77fd3 (patch)
treeddc1691a9f1ea34570e6974692977bde94a42dd1 /alsa-binding
parenta79fdcf92f9f94bdaed68dd57091e4e8fb665e18 (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')
-rw-r--r--alsa-binding/Alsa-ApiHat.h1
-rw-r--r--alsa-binding/Alsa-SetGet.c12
2 files changed, 12 insertions, 1 deletions
diff --git a/alsa-binding/Alsa-ApiHat.h b/alsa-binding/Alsa-ApiHat.h
index f5feacd..50337db 100644
--- a/alsa-binding/Alsa-ApiHat.h
+++ b/alsa-binding/Alsa-ApiHat.h
@@ -70,6 +70,7 @@ typedef struct {
// use to store crl numid user request
typedef struct {
unsigned int numId;
+ const char *tag;
json_object *jToken;
json_object *valuesJ;
int used;
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;
}