diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-06-08 15:30:46 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-10-08 15:52:51 +0200 |
commit | dddb442d4a5208c0ad63479daca3e3c7a3946ee0 (patch) | |
tree | 53f079c8833bd2657ddcc3399a69a34e5a0dc03d /4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c | |
parent | 7297c6b5d2dc47574e981c76a282e67fcef230c0 (diff) |
Get alsa controls properties at control get
Get alsa controls properties by parsing the response sent by balsacore
when we search for an existing alsa control.
Change-Id: I9d13327ae2ef79c793dbd227589740f7e336e46c
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c')
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c index 462994a..230cddd 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c @@ -185,10 +185,10 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl return -4; } else if(currentAlsaCtl->name) { - wrap_json_pack(&queryJ, "{s:s s:s}", "devid", cardId, "ctl", currentAlsaCtl->name); + wrap_json_pack(&queryJ, "{s:s s:s s:i}", "devid", cardId, "ctl", currentAlsaCtl->name, "mode", 3); } else if(currentAlsaCtl->numid > 0) { - wrap_json_pack(&queryJ, "{s:s s:i}", "devid", cardId, "ctl", currentAlsaCtl->numid); + wrap_json_pack(&queryJ, "{s:s s:i s:i}", "devid", cardId, "ctl", currentAlsaCtl->numid, "mode", 3); } else { AFB_ApiError(apiHandle, "%s: Need at least a control name or a control uid", __func__); @@ -216,6 +216,23 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl return -8; } + // TBD JAI : get dblinear/dbminmax/... values + if(wrap_json_unpack(returnedJ, "{s:{s:{s?:i s?:i s?:i s?:i s?:i}}}", + "response", + "ctl", + "type", (snd_ctl_elem_type_t) ¤tAlsaCtl->alsaCtlProperties.type, + "count", ¤tAlsaCtl->alsaCtlProperties.count, + "min", ¤tAlsaCtl->alsaCtlProperties.minval, + "max", ¤tAlsaCtl->alsaCtlProperties.maxval, + "step", ¤tAlsaCtl->alsaCtlProperties.step)) { + AFB_ApiError(apiHandle, + "Didn't succeed to get control %i properties on device '%s' : '%s'", + currentAlsaCtl->numid, + cardId, + json_object_get_string(returnedJ)); + return -9; + } + return 0; } @@ -301,16 +318,16 @@ int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl return -4; } - wrap_json_pack(&queryJ, "{s:s s:{s:i s:s s:i s:i s:i s:i s:i s:i} s:i}", + wrap_json_pack(&queryJ, "{s:s s:{s:i s:s s:i s:i s:i s:i s:i}}", "devid", cardId, "ctl", - "ctl", -1, - "name", alsaCtlToCreate->name, - "min", alsaCtlToCreate->alsaCtlCreation->minval, - "max", alsaCtlToCreate->alsaCtlCreation->maxval, - "step", alsaCtlToCreate->alsaCtlCreation->step, - "type", (int) alsaCtlToCreate->alsaCtlCreation->type, - "count", alsaCtlToCreate->alsaCtlCreation->count); + "ctl", -1, + "name", alsaCtlToCreate->name, + "min", alsaCtlToCreate->alsaCtlCreation->minval, + "max", alsaCtlToCreate->alsaCtlCreation->maxval, + "step", alsaCtlToCreate->alsaCtlCreation->step, + "type", (int) alsaCtlToCreate->alsaCtlCreation->type, + "count", alsaCtlToCreate->alsaCtlCreation->count); if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, queryJ, &returnedJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, returnedJ, &returnedStatus, &returnedInfo); |