summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-alsa-data.c68
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h4
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c62
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h2
4 files changed, 134 insertions, 2 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;
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h
index 50171e7..3a4c885 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h
@@ -68,7 +68,9 @@ struct InternalHalAlsaMapT {
unsigned int ctlsCount;
};
-// Free contents of 'CtlHalAlsaMapT' data structure
+// Internal Hal - ALSA controls data handling functions
+json_object *HalUtGetJsonArrayForSpecificControl(afb_api_t apiHandle, struct InternalHalAlsaMap *currentAlsaMapData);
+json_object *HalUtGetJsonArrayForAllControls(afb_api_t apiHandle, struct InternalHalAlsaMapT *currentAlsaMapDataT);
int HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap);
#endif /* _HAL_UTILITIES_ALSA_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 3918db4..b1401a9 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -348,6 +348,68 @@ struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHa
return NULL;
}
+json_object *HalUtlGetJsonArrayForSpecificMixerData(afb_api_t apiHandle, struct InternalHalMixerData *mixerData)
+{
+ int wrapRet;
+
+ json_object *currentMixerDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Api handle is not valid");
+ return NULL;
+ }
+
+ if(! mixerData) {
+ AFB_API_ERROR(apiHandle, "Mixer data to use to generate json object are empty");
+ return NULL;
+ }
+
+ wrapRet = wrap_json_pack(&currentMixerDataJ,
+ "{s:s s:s}",
+ "name", mixerData->verb,
+ "cardId", mixerData->streamCardId);
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer json object");
+ return NULL;
+ }
+
+ return currentMixerDataJ;
+}
+
+json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct InternalHalMixerData **mixerDataList)
+{
+ json_object *mixerDataArrayJ, *currentMixerDataJ;
+
+ struct InternalHalMixerData *currentMixerData;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Api handle is not valid");
+ return NULL;
+ }
+
+ mixerDataArrayJ = json_object_new_array();
+ if(! mixerDataArrayJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate requested mixer data json array");
+ return NULL;
+ }
+
+ currentMixerData = *mixerDataList;
+ while(currentMixerData) {
+ currentMixerDataJ = HalUtlGetJsonArrayForSpecificMixerData(apiHandle, currentMixerData);
+ if(! currentMixerDataJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to generate current mixer data json object");
+ json_object_put(mixerDataArrayJ);
+ return NULL;
+ }
+
+ json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return mixerDataArrayJ;
+}
+
/*******************************************************************************
* Hal data handling functions *
******************************************************************************/
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index 0ec66e6..6d5cd2d 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -150,6 +150,8 @@ int HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList
struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList,
char *verb, char *verbToCall,
char *streamCardId);
+json_object *HalUtlGetJsonArrayForSpecificMixerData(afb_api_t apiHandle, struct InternalHalMixerData *mixerData);
+json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct InternalHalMixerData **mixerDataList);
// Hal data handling functions
struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList);