summaryrefslogtreecommitdiffstats
path: root/lib/4a-hal-utilities/4a-hal-utilities-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/4a-hal-utilities/4a-hal-utilities-data.c')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c133
1 files changed, 130 insertions, 3 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 6121b33..d7ae1f6 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -33,6 +33,7 @@
void HalUtlFreeSelectedProbedDeviceAllocation(struct InternalHalProbedDevice *probedDeviceToFree);
void HalUtlFreeSelectedMixerDataAllocation(struct InternalHalMixerData *mixerDataToFree);
+void HalUtlFreeSelectedHalMapDataAllocation(struct InternalHalAlsaMap *halMapDataToFree);
void HalUtlFreeSelectedHalAllocation(struct HalData *halDataToFree);
/*******************************************************************************
@@ -62,6 +63,13 @@ void *HalUtlAddNodeInList(struct cds_list_head *listHead, enum LinkedListType li
nodeToAdd = &((struct InternalHalMixerData *) returned)->node;
break;
+ case LINKED_LIST_FOR_HALMAP_DATA:
+ returned = calloc(1, sizeof(struct InternalHalAlsaMap));
+ if(! returned)
+ return NULL;
+ nodeToAdd = &((struct InternalHalAlsaMap *) returned)->node;
+ break;
+
case LINKED_LIST_FOR_HAL_DATA:
returned = calloc(1, sizeof(struct HalData));
if(! returned)
@@ -96,6 +104,12 @@ int HalUtlRemoveNodeFromList(struct cds_list_head *listHead, void *dataToRemove,
HalUtlFreeSelectedMixerDataAllocation((struct InternalHalMixerData *) dataToRemove);
break;
+ case LINKED_LIST_FOR_HALMAP_DATA:
+ cds_list_del(&((struct InternalHalAlsaMap *) dataToRemove)->node);
+
+ HalUtlFreeSelectedHalMapDataAllocation((struct InternalHalAlsaMap *) dataToRemove);
+ break;
+
case LINKED_LIST_FOR_HAL_DATA:
cds_list_del(&((struct HalData *) dataToRemove)->node);
@@ -135,14 +149,20 @@ int HalUtlRemoveAllNodeFromList(struct cds_list_head *listHead, enum LinkedListT
return -3;
break;
+ case LINKED_LIST_FOR_HALMAP_DATA:
+ if(HalUtlRemoveSelectedHalMapData(listHead,
+ cds_list_entry(nodeToRemove, struct InternalHalAlsaMap, node)))
+ return -4;
+ break;
+
case LINKED_LIST_FOR_HAL_DATA:
if(HalUtlRemoveSelectedHalFromList(listHead,
cds_list_entry(nodeToRemove, struct HalData, node)))
- return -4;
+ return -5;
break;
default:
- return -5;
+ return -6;
}
nodesRemoved++;
@@ -820,6 +840,11 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_
return NULL;
}
+ if(cds_list_empty(mixerDataListHead)) {
+ AFB_API_ERROR(apiHandle, "Mixer data list is empty");
+ return NULL;
+ }
+
mixerDataArrayJ = json_object_new_array();
if(! mixerDataArrayJ) {
AFB_API_ERROR(apiHandle, "Didn't succeed to allocate requested mixer data json array");
@@ -841,6 +866,108 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_
}
/*******************************************************************************
+ * Internal Hal - Alsa Map data handling functions *
+ ******************************************************************************/
+
+void HalUtlFreeSelectedHalMapDataAllocation(struct InternalHalAlsaMap *halMapDataToFree)
+{
+ free(halMapDataToFree->uid);
+ free(halMapDataToFree->info);
+
+ free(halMapDataToFree->action);
+
+ free(halMapDataToFree->ctl.name);
+
+ free(halMapDataToFree);
+}
+
+struct InternalHalAlsaMap *HalUtlAddHalMapDataToHalMapDataList(struct cds_list_head *halMapListHead)
+{
+ return (struct InternalHalAlsaMap *) HalUtlAddNodeInList(halMapListHead, LINKED_LIST_FOR_HALMAP_DATA);
+}
+
+int HalUtlRemoveSelectedHalMapData(struct cds_list_head *halMapListHead,
+ struct InternalHalAlsaMap *halMapDataToRemove)
+{
+ return HalUtlRemoveNodeFromList(halMapListHead, (void *) halMapDataToRemove, LINKED_LIST_FOR_HALMAP_DATA);
+}
+
+int HalUtlRemoveAllHalMapData(struct cds_list_head *halMapListHead)
+{
+ return HalUtlRemoveAllNodeFromList(halMapListHead, LINKED_LIST_FOR_HALMAP_DATA);
+}
+
+int HalUtlGetNumberOfHalMapDataInList(struct cds_list_head *halMapListHead)
+{
+ return HalUtlGetNumberOfNodesInList(halMapListHead);
+}
+
+json_object *HalUtGetJsonArrayForSpecificHalMapControl(afb_api_t apiHandle,
+ struct InternalHalAlsaMap *currentHalMapData)
+{
+ int wrapRet;
+
+ json_object *currentAlsaMapDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle");
+ return NULL;
+ }
+
+ if(! currentHalMapData) {
+ 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", currentHalMapData->uid,
+ "info", currentHalMapData->info ? currentHalMapData->info : "none");
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current streams json object");
+ return NULL;
+ }
+
+ return currentAlsaMapDataJ;
+}
+
+json_object *HalUtGetJsonArrayForAllHalMapControls(afb_api_t apiHandle, struct cds_list_head *halMapListHead)
+{
+ struct InternalHalAlsaMap *currentHalMapData;
+
+ json_object *halMapDataArrayJ, *currentHalMapDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle");
+ return NULL;
+ }
+
+ if(! halMapListHead || cds_list_empty(halMapListHead)) {
+ AFB_API_ERROR(apiHandle, "HalMap data list is empty");
+ return NULL;
+ }
+
+ halMapDataArrayJ = json_object_new_array();
+ if(! halMapDataArrayJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate ALSA controls data json array");
+ return NULL;
+ }
+
+ cds_list_for_each_entry(currentHalMapData, halMapListHead, node) {
+ currentHalMapDataJ = HalUtGetJsonArrayForSpecificHalMapControl(apiHandle, currentHalMapData);
+ if(! currentHalMapDataJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to generate current HalMap data json object");
+ json_object_put(halMapDataArrayJ);
+ return NULL;
+ }
+
+ json_object_array_add(halMapDataArrayJ, currentHalMapDataJ);
+ }
+
+ return halMapDataArrayJ;
+}
+
+/*******************************************************************************
* Hal data handling functions *
******************************************************************************/
@@ -857,7 +984,7 @@ void HalUtlFreeSelectedHalAllocation(struct HalData *halDataToFree)
HalUtlRemoveAllMixerData(&halDataToFree->internalHalData->streamsDataListHead);
- HalUtlFreeAlsaCtlsMap(halDataToFree->internalHalData->alsaMapT);
+ HalUtlRemoveAllHalMapData(&halDataToFree->internalHalData->halMapListHead);
free(halDataToFree->internalHalData);
}