aboutsummaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities/4a-hal-utilities-data.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal-utilities/4a-hal-utilities-data.c')
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c142
1 files changed, 120 insertions, 22 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
index 4bb19a8..b5d0293 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -29,27 +29,126 @@
* Specfic Hal controller streams data handling functions *
******************************************************************************/
-uint8_t HalUtlRemoveAllCtlHalStreamsData(struct CtlHalMixerDataT *ctlHalStreamsData)
+struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **firstMixerData)
{
- unsigned int cpt;
+ struct CtlHalMixerData *currentMixerData;
- if(! ctlHalStreamsData)
+ if(! firstMixerData)
+ return NULL;
+
+ currentMixerData = *firstMixerData;
+
+ if(! currentMixerData) {
+ currentMixerData = (struct CtlHalMixerData *) calloc(1, sizeof(struct CtlHalMixerData));
+ if(! currentMixerData)
+ return NULL;
+
+ *firstMixerData = currentMixerData;
+ }
+ else {
+ while(currentMixerData->next)
+ currentMixerData = currentMixerData->next;
+
+ currentMixerData->next = calloc(1, sizeof(struct CtlHalMixerData));
+ if(! currentMixerData)
+ return NULL;
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return currentMixerData;
+}
+
+int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, struct CtlHalMixerData *mixerDataToRemove)
+{
+ struct CtlHalMixerData *currentMixerData, *matchingMixerData;
+
+ if(! firstMixerData || ! mixerDataToRemove)
return -1;
- if(! ctlHalStreamsData->count)
- return -2;
+ currentMixerData = *firstMixerData;
- for(cpt = 0; cpt < ctlHalStreamsData->count; cpt++) {
- free(ctlHalStreamsData->data[cpt].verb);
- free(ctlHalStreamsData->data[cpt].verbToCall);
- free(ctlHalStreamsData->data[cpt].streamCardId);
+ if(currentMixerData == mixerDataToRemove) {
+ *firstMixerData = currentMixerData->next;
+ matchingMixerData = currentMixerData;
+ }
+ else {
+ while(currentMixerData && currentMixerData->next != mixerDataToRemove)
+ currentMixerData = currentMixerData->next;
+
+ if(currentMixerData) {
+ matchingMixerData = currentMixerData->next;
+ currentMixerData->next = currentMixerData->next->next;
+ }
+ else {
+ return -2;
+ }
}
- free(ctlHalStreamsData->data);
+ free(matchingMixerData->verb);
+ free(matchingMixerData->verbToCall);
+ free(matchingMixerData->streamCardId);
+
+ free(matchingMixerData);
return 0;
}
+int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData)
+{
+ int8_t ret;
+ int64_t mixerDataRemoved = 0;
+
+ while(*firstMixerData) {
+ ret = HalUtlRemoveSelectedMixerData(firstMixerData, *firstMixerData);
+ if(ret)
+ return (int64_t) ret;
+
+ mixerDataRemoved++;
+ }
+
+ return mixerDataRemoved;
+}
+
+int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData)
+{
+ int64_t numberOfMixerData = 0;
+ struct CtlHalMixerData *currentMixerData;
+
+ if(! firstMixerData)
+ return -1;
+
+ currentMixerData = *firstMixerData;
+
+ while(currentMixerData) {
+ currentMixerData = currentMixerData->next;
+ numberOfMixerData++;
+ }
+
+ return numberOfMixerData;
+}
+
+struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **firstMixerData, char *verb, char *verbToCall, char *streamCardId)
+{
+ struct CtlHalMixerData *currentMixerData;
+
+ if(! firstMixerData || ! verb)
+ return NULL;
+
+ currentMixerData = *firstMixerData;
+
+ while(currentMixerData) {
+ if((! strcmp(verb, currentMixerData->verb)) &&
+ (! strcmp(verbToCall, currentMixerData->verbToCall)) &&
+ (! strcmp(streamCardId, currentMixerData->streamCardId)))
+ return currentMixerData;
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return NULL;
+}
+
/*******************************************************************************
* Specfic Hal data handling functions *
******************************************************************************/
@@ -81,8 +180,6 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstH
currentApi = currentApi->next;
}
- memset(currentApi, 0, sizeof(struct SpecificHalData));
-
return currentApi;
}
@@ -112,16 +209,17 @@ int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, st
}
}
- if(! matchingApi->internal) {
- free(matchingApi->apiName);
- free(matchingApi->sndCardPath);
- free(matchingApi->info);
- free(matchingApi->author);
- free(matchingApi->version);
- free(matchingApi->date);
- }
- else {
- HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
+ free(matchingApi->apiName);
+ free(matchingApi->sndCardPath);
+ free(matchingApi->info);
+ free(matchingApi->author);
+ free(matchingApi->version);
+ free(matchingApi->date);
+
+ if(matchingApi->internal) {
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalPlaybacksData);
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalCapturesData);
HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT);