summaryrefslogtreecommitdiffstats
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.c101
1 files changed, 52 insertions, 49 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
index 51e751f..0790ed3 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -28,31 +28,30 @@
#include "4a-hal-utilities-alsa-data.h"
/*******************************************************************************
- * Specfic Hal controller streams data handling functions *
+ * Specfic Hal controller streams data handling functions *
******************************************************************************/
-struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **firstMixerData)
+struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **mixerDataList)
{
struct CtlHalMixerData *currentMixerData;
- if(! firstMixerData)
+ if(! mixerDataList)
return NULL;
- currentMixerData = *firstMixerData;
-
+ currentMixerData = *mixerDataList;
if(! currentMixerData) {
currentMixerData = (struct CtlHalMixerData *) calloc(1, sizeof(struct CtlHalMixerData));
if(! currentMixerData)
return NULL;
- *firstMixerData = currentMixerData;
+ *mixerDataList = currentMixerData;
}
else {
while(currentMixerData->next)
currentMixerData = currentMixerData->next;
currentMixerData->next = calloc(1, sizeof(struct CtlHalMixerData));
- if(! currentMixerData)
+ if(! currentMixerData->next)
return NULL;
currentMixerData = currentMixerData->next;
@@ -61,17 +60,16 @@ struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData
return currentMixerData;
}
-int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, struct CtlHalMixerData *mixerDataToRemove)
+int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, struct CtlHalMixerData *mixerDataToRemove)
{
struct CtlHalMixerData *currentMixerData, *matchingMixerData;
- if(! firstMixerData || ! mixerDataToRemove)
+ if(! mixerDataList || ! *mixerDataList || ! mixerDataToRemove)
return -1;
- currentMixerData = *firstMixerData;
-
+ currentMixerData = *mixerDataList;
if(currentMixerData == mixerDataToRemove) {
- *firstMixerData = currentMixerData->next;
+ *mixerDataList = currentMixerData->next;
matchingMixerData = currentMixerData;
}
else {
@@ -96,13 +94,16 @@ int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, st
return 0;
}
-int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData)
+int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList)
{
int8_t ret;
int64_t mixerDataRemoved = 0;
- while(*firstMixerData) {
- ret = HalUtlRemoveSelectedMixerData(firstMixerData, *firstMixerData);
+ if(! mixerDataList)
+ return -1;
+
+ while(*mixerDataList) {
+ ret = HalUtlRemoveSelectedMixerData(mixerDataList, *mixerDataList);
if(ret)
return (int64_t) ret;
@@ -112,15 +113,15 @@ int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData)
return mixerDataRemoved;
}
-int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData)
+int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList)
{
int64_t numberOfMixerData = 0;
struct CtlHalMixerData *currentMixerData;
- if(! firstMixerData)
+ if(! mixerDataList)
return -1;
- currentMixerData = *firstMixerData;
+ currentMixerData = *mixerDataList;
while(currentMixerData) {
currentMixerData = currentMixerData->next;
@@ -130,14 +131,14 @@ int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData
return numberOfMixerData;
}
-struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **firstMixerData, char *verb, char *verbToCall, char *streamCardId)
+struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId)
{
struct CtlHalMixerData *currentMixerData;
- if(! firstMixerData || ! verb)
+ if(! mixerDataList || ! verb)
return NULL;
- currentMixerData = *firstMixerData;
+ currentMixerData = *mixerDataList;
while(currentMixerData) {
if((! strcmp(verb, currentMixerData->verb)) &&
@@ -152,31 +153,30 @@ struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData
}
/*******************************************************************************
- * Specfic Hal data handling functions *
+ * Specfic Hal data handling functions *
******************************************************************************/
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData)
+struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **halDataList)
{
struct SpecificHalData *currentApi;
- if(! firstHalData)
+ if(! halDataList)
return NULL;
- currentApi = *firstHalData;
-
+ currentApi = *halDataList;
if(! currentApi) {
currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData));
if(! currentApi)
return NULL;
- *firstHalData = currentApi;
+ *halDataList = currentApi;
}
else {
while(currentApi->next)
currentApi = currentApi->next;
currentApi->next = calloc(1, sizeof(struct SpecificHalData));
- if(! currentApi)
+ if(! currentApi->next)
return NULL;
currentApi = currentApi->next;
@@ -185,17 +185,16 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstH
return currentApi;
}
-int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *apiToRemove)
+int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **halDataList, struct SpecificHalData *apiToRemove)
{
struct SpecificHalData *currentApi, *matchingApi;
- if(! firstHalData || ! apiToRemove)
+ if(! halDataList || ! *halDataList || ! apiToRemove)
return -1;
- currentApi = *firstHalData;
-
+ currentApi = *halDataList;
if(currentApi == apiToRemove) {
- *firstHalData = currentApi->next;
+ *halDataList = currentApi->next;
matchingApi = currentApi;
}
else {
@@ -233,13 +232,16 @@ int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, st
return 0;
}
-int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData)
+int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList)
{
int8_t ret;
int64_t CtlHalApiRemoved = 0;
- while(*firstHalData) {
- ret = HalUtlRemoveSelectedHalFromList(firstHalData, *firstHalData);
+ if(! halDataList)
+ return -1;
+
+ while(*halDataList) {
+ ret = HalUtlRemoveSelectedHalFromList(halDataList, *halDataList);
if(ret)
return (int64_t) ret;
@@ -249,15 +251,15 @@ int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData)
return CtlHalApiRemoved;
}
-int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData)
+int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **halDataList)
{
int64_t numberOfCtlHal = 0;
struct SpecificHalData *currentApi;
- if(! firstHalData)
+ if(! halDataList)
return -1;
- currentApi = *firstHalData;
+ currentApi = *halDataList;
while(currentApi) {
currentApi = currentApi->next;
@@ -267,14 +269,14 @@ int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData)
return numberOfCtlHal;
}
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName)
+struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **halDataList, char *apiName)
{
struct SpecificHalData *currentApi;
- if(! firstHalData || ! apiName)
+ if(! halDataList || ! *halDataList || ! apiName)
return NULL;
- currentApi = *firstHalData;
+ currentApi = *halDataList;
while(currentApi) {
if(! strcmp(apiName, currentApi->apiName))
@@ -286,14 +288,15 @@ struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **fi
return NULL;
}
-struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **firstHalData, int cardId)
+struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **halDataList, int cardId)
{
struct SpecificHalData *currentApi;
- if(! firstHalData)
+ if(! halDataList || ! *halDataList)
return NULL;
- currentApi = *firstHalData;
+ currentApi = *halDataList;
+
while(currentApi) {
if(currentApi->status == HAL_STATUS_READY && currentApi->sndCardId == cardId)
return currentApi;
@@ -305,7 +308,7 @@ struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData
}
/*******************************************************************************
- * Hal Manager data handling functions *
+ * Hal Manager data handling functions *
******************************************************************************/
uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
@@ -319,7 +322,7 @@ uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMg
return -2;
HalMgrGlobalData->info = strdup(info);
- if(! HalMgrGlobalData->apiName)
+ if(! HalMgrGlobalData->info)
return -3;
HalMgrGlobalData->apiHandle = apiHandle;
@@ -332,8 +335,8 @@ void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData)
if(! HalMgrGlobalData)
return;
- if(HalMgrGlobalData->first)
- HalUtlRemoveAllHalFromList(&HalMgrGlobalData->first);
+ if(HalMgrGlobalData->halDataList)
+ HalUtlRemoveAllHalFromList(&HalMgrGlobalData->halDataList);
free(HalMgrGlobalData->apiName);
free(HalMgrGlobalData->info);