summaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal-utilities')
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c142
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.h21
2 files changed, 133 insertions, 30 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);
diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h
index 031fa9b..a2f1f1a 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-data.h
@@ -41,12 +41,8 @@ struct CtlHalMixerData {
char *verbToCall;
char *streamCardId;
AFB_EventT event;
-};
-// Structure to store stream data table
-struct CtlHalMixerDataT {
- struct CtlHalMixerData *data;
- unsigned int count;
+ struct CtlHalMixerData *next;
};
// Structure to store specific controller hal data
@@ -55,9 +51,11 @@ struct CtlHalSpecificData {
char *prefix;
json_object *halMixerJ;
- struct CtlHalMixerDataT ctlHalStreamsData;
- struct CtlHalMixerDataT ctlHalPlaybacksData;
- struct CtlHalMixerDataT ctlHalCapturesData;
+ struct CtlHalMixerData *ctlHalStreamsData;
+
+ struct CtlHalMixerData *ctlHalPlaybacksData;
+ struct CtlHalMixerData *ctlHalCapturesData;
+
struct CtlHalAlsaMapT *ctlHalAlsaMapT;
AFB_ApiT apiHandle;
@@ -93,6 +91,13 @@ struct HalMgrData {
struct SpecificHalData *first;
};
+// Specfic Hal controller streams data handling functions
+struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **firstMixerData);
+int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, struct CtlHalMixerData *mixerDataToRemove);
+int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData);
+int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData);
+struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **firstMixerData, char *verb, char *verbToCall, char *streamCardId);
+
// Exported verbs for 'struct SpecificHalData' handling
struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData);
int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *ApiToRemove);