summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c88
5 files changed, 138 insertions, 86 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);
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index 451572e..d9123c9 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -1012,86 +1012,6 @@ int InternalHalHalDependenciesConfig(afb_api_t apiHandle, CtlSectionT *section,
* Internals HAL verbs functions *
******************************************************************************/
-json_object *InternalHalGetJsonArrayForMixerDataTable(afb_api_t apiHandle,
- struct InternalHalMixerData **mixerDataList)
-{
- int wrapRet;
-
- 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) {
- wrapRet = wrap_json_pack(&currentMixerDataJ,
- "{s:s s:s}",
- "name", currentMixerData->verb,
- "cardId", currentMixerData->streamCardId);
- if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer json object");
- json_object_put(mixerDataArrayJ);
- return NULL;
- }
-
- json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
-
- currentMixerData = currentMixerData->next;
- }
-
- return mixerDataArrayJ;
-}
-
-json_object *InternalHalGetJsonArrayForControls(afb_api_t apiHandle, struct InternalHalAlsaMapT *currentAlsaMapDataT)
-{
- int wrapRet;
- unsigned int idx;
-
- json_object *alsaMapDataArray, *currentAlsaMapData;
-
- 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;
- }
-
- alsaMapDataArray = json_object_new_array();
- if(! alsaMapDataArray) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate ALSA controls data json array");
- return NULL;
- }
-
- for(idx = 0; idx < currentAlsaMapDataT->ctlsCount; idx++) {
- wrapRet = wrap_json_pack(&currentAlsaMapData,
- "{s:s s:s}",
- "name", currentAlsaMapDataT->ctls[idx].uid,
- "info", currentAlsaMapDataT->ctls[idx].info ? currentAlsaMapDataT->ctls[idx].info : "none");
- if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current streams json object");
- json_object_put(alsaMapDataArray);
- return NULL;
- }
-
- json_object_array_add(alsaMapDataArray, currentAlsaMapData);
- }
-
- return alsaMapDataArray;
-}
-
void InternalHalInfo(afb_req_t request)
{
int wrapRet;
@@ -1151,15 +1071,15 @@ void InternalHalInfo(afb_req_t request)
return;
}
- streamsArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle,
- &currentHalData->internalHalData->streamsData);
+ streamsArray = HalUtlGetJsonArrayForAllMixersData(apiHandle,
+ &currentHalData->internalHalData->streamsData);
if(! streamsArray) {
afb_req_fail(request, "streams_data", "Didn't succeed to generate streams data array");
return;
}
- controlsArray = InternalHalGetJsonArrayForControls(apiHandle,
- currentHalData->internalHalData->alsaMapT);
+ controlsArray = HalUtGetJsonArrayForAllControls(apiHandle,
+ currentHalData->internalHalData->alsaMapT);
if(! controlsArray) {
afb_req_fail(request, "controls_data", "Didn't succeed to generate controls data array");
return;