aboutsummaryrefslogtreecommitdiffstats
path: root/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-06 14:56:03 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-06 14:56:03 +0200
commit82cde4494319b55b51a6c42e037003b8241c02be (patch)
tree602dd5384b2d5b977392453b6163527c045129be /lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c
parent391fcec50ea79d4f487258532e1df6007f3942c7 (diff)
Move functions used to generate json
Move functions used to generate hal information json into there corresponding files in hal-utilities. BUG-AGL: SPEC-2329 Change-Id: Id518e7f732ef393bbf98f3b3a32edf01ec81f70c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c
index 90fb612..5d37c0a 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c
@@ -19,14 +19,80 @@
#include <stdio.h>
+#include <wrap-json.h>
+
#include <afb/afb-binding.h>
#include "4a-hal-utilities-alsa-data.h"
/*******************************************************************************
- * Free contents of 'InternalHalAlsaMapT' data structure *
+ * Internal Hal - ALSA controls data handling functions *
******************************************************************************/
+json_object *HalUtGetJsonArrayForSpecificControl(afb_api_t apiHandle, struct InternalHalAlsaMap *currentAlsaMapData)
+{
+ int wrapRet;
+
+ json_object *currentAlsaMapDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle");
+ return NULL;
+ }
+
+ if(! currentAlsaMapData) {
+ AFB_API_ERROR(apiHandle, "ALSA control data to use to generate json object are empty");
+ return NULL;
+ }
+
+ wrapRet = wrap_json_pack(&currentAlsaMapDataJ,
+ "{s:s s:s}",
+ "name", currentAlsaMapData->uid,
+ "info", currentAlsaMapData->info ? currentAlsaMapData->info : "none");
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current streams json object");
+ return NULL;
+ }
+
+ return currentAlsaMapDataJ;
+}
+
+json_object *HalUtGetJsonArrayForAllControls(afb_api_t apiHandle, struct InternalHalAlsaMapT *currentAlsaMapDataT)
+{
+ unsigned int idx;
+
+ json_object *alsaMapDataArrayJ, *currentAlsaMapDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle");
+ return NULL;
+ }
+
+ if(! currentAlsaMapDataT) {
+ AFB_API_ERROR(apiHandle, "Can't get Alsa map data table to handle");
+ return NULL;
+ }
+
+ alsaMapDataArrayJ = json_object_new_array();
+ if(! alsaMapDataArrayJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate ALSA controls data json array");
+ return NULL;
+ }
+
+ for(idx = 0; idx < currentAlsaMapDataT->ctlsCount; idx++) {
+ currentAlsaMapDataJ = HalUtGetJsonArrayForSpecificControl(apiHandle, &currentAlsaMapDataT->ctls[idx]);
+ if(! currentAlsaMapDataJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to generate current ALSA control data json object");
+ json_object_put(alsaMapDataArrayJ);
+ return NULL;
+ }
+
+ json_object_array_add(alsaMapDataArrayJ, currentAlsaMapDataJ);
+ }
+
+ return alsaMapDataArrayJ;
+}
+
int HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap)
{
int idx;