diff options
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-data.c | 101 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-data.h | 24 | ||||
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c | 2 | ||||
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c | 4 | ||||
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c | 15 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager-cb.c | 9 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager.c | 8 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager.h | 4 |
8 files changed, 85 insertions, 82 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); diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h index 5dd7bea..1389aa6 100644 --- a/4a-hal-utilities/4a-hal-utilities-data.h +++ b/4a-hal-utilities/4a-hal-utilities-data.h @@ -91,23 +91,23 @@ struct HalMgrData { afb_api_t apiHandle; - struct SpecificHalData *first; + struct SpecificHalData *halDataList; }; // 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); +struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **mixerDataList); +int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, struct CtlHalMixerData *mixerDataToRemove); +int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList); +int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList); +struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **mixerDataList, 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); -int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData); -int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData); -struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName); -struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **firstHalData, int cardId); +struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **halDataList); +int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **halDataList, struct SpecificHalData *ApiToRemove); +int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList); +int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **halDataList); +struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **halDataList, char *apiName); +struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **halDataList, int cardId); // Exported verbs for 'struct HalMgrData' handling uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info); diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c index 4a1ca8f..a6f6895 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c @@ -175,7 +175,7 @@ int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrG } // Allocation of current hal controller data - currentCtlHalData = HalUtlAddHalApiToHalList(&HalMgrGlobalData->first); + currentCtlHalData = HalUtlAddHalApiToHalList(&HalMgrGlobalData->halDataList); if(! currentCtlHalData) return -4; diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c index 98d8d53..c38b057 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c @@ -402,7 +402,7 @@ int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object * * HAL controllers verbs functions * ******************************************************************************/ -json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct CtlHalMixerData **firstMixerData, enum MixerDataType dataType) +json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct CtlHalMixerData **mixerDataList, enum MixerDataType dataType) { json_object *mixerDataArrayJ, *currentMixerDataJ; @@ -419,7 +419,7 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct Ct return NULL; } - currentMixerData = *firstMixerData; + currentMixerData = *mixerDataList; while(currentMixerData) { switch(dataType) { diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c index a9908de..1839261 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c @@ -38,7 +38,7 @@ * HAL controllers handle mixer calls functions * ******************************************************************************/ -int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **firstMixerData, json_object *currentDataJ, enum MixerDataType dataType) +int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **mixerDataList, json_object *currentDataJ, enum MixerDataType dataType) { int idx, mixerDataNb, verbStart, size; int err = (int) MIXER_NO_ERROR; @@ -106,14 +106,14 @@ int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **firstMi case MIXER_DATA_PLAYBACKS: case MIXER_DATA_CAPTURES: - currentMixerData = HalUtlAddMixerDataToMixerDataList(firstMixerData); + currentMixerData = HalUtlAddMixerDataToMixerDataList(mixerDataList); currentMixerData->verb = strdup((dataType == MIXER_DATA_PLAYBACKS) ? HAL_PLAYBACK_ID : HAL_CAPTURE_ID); currentMixerData->verbToCall = strdup(currentDataVerbName); if((! currentMixerData->verb) || (! currentMixerData->verbToCall)) { - HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData); + HalUtlRemoveSelectedMixerData(mixerDataList, currentMixerData); err += (int) MIXER_ERROR_STREAM_ALLOCATION_FAILED; } break; @@ -129,7 +129,7 @@ int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **firstMi HAL_PLAYBACK_ID, "Playback action transferred to mixer", HalUtlActionOnPlayback, - (void *) *firstMixerData, + (void *) *mixerDataList, NULL, 0, 0)) { @@ -143,7 +143,7 @@ int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **firstMi HAL_CAPTURE_ID, "Capture action transferred to mixer", HalUtlActionOnCapture, - (void *) *firstMixerData, + (void *) *mixerDataList, NULL, 0, 0)) { @@ -207,7 +207,6 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) CtlConfigT *ctrlConfig; struct SpecificHalData *currentCtlHalData, *concurentHalData = NULL; - struct SpecificHalData **firstHalData; json_object *responseJ = NULL; @@ -239,8 +238,8 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) break; } - firstHalData = HalMngGetFirstHalData(); - if((concurentHalData = HalUtlSearchReadyHalDataByCardId(firstHalData, currentCtlHalData->sndCardId))) { + concurentHalData = HalUtlSearchReadyHalDataByCardId(HalMngGetHalDataList(), currentCtlHalData->sndCardId); + if(concurentHalData) { AFB_API_ERROR(apiHandle, "Trying to attach mixer for hal '%s' but the alsa device %i is already in use with mixer by hal '%s'", currentCtlHalData->apiName, diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c index f919afe..77ae52f 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c @@ -77,7 +77,7 @@ void HalMgrLoaded(afb_req_t request) return; } - currentHalData = HalMgrGlobalData->first; + currentHalData = HalMgrGlobalData->halDataList; if(! currentHalData) { afb_req_success(request, NULL, "No Hal Api loaded"); @@ -174,7 +174,7 @@ void HalMgrLoad(afb_req_t request) return; } - addedHal = HalUtlAddHalApiToHalList(&HalMgrGlobalData->first); + addedHal = HalUtlAddHalApiToHalList(&HalMgrGlobalData->halDataList); addedHal->internal = 0; // TBD JAI : initialize external to unavailable once event from external hal will be handled @@ -232,7 +232,8 @@ void HalMgrUnload(afb_req_t request) return; } - if(! (HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName))) { + HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->halDataList, apiName); + if(! HalToRemove) { afb_req_fail(request, "requested_api", "Can't find api to remove"); return; } @@ -242,7 +243,7 @@ void HalMgrUnload(afb_req_t request) return; } - if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->first, HalToRemove)) { + if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->halDataList, HalToRemove)) { afb_req_fail(request, "unregister_error", "Didn't succeed to remove specified api"); return; } diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c index 75177e7..017199f 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager.c @@ -54,13 +54,13 @@ afb_verb_t HalManagerApiStaticVerbs[] = }; /******************************************************************************* - * HAL Manager get first 'SpecificHalData' structure * + * HAL Manager get 'SpecificHalData' linked list * from HAL list function * ******************************************************************************/ -struct SpecificHalData **HalMngGetFirstHalData(void) +struct SpecificHalData **HalMngGetHalDataList(void) { - return &localHalMgrGlobalData.first; + return &localHalMgrGlobalData.halDataList; } /******************************************************************************* @@ -85,7 +85,7 @@ static int HalMgrInitApi(afb_api_t apiHandle) if(HalUtlInitializeHalMgrData(apiHandle, HalMgrGlobalData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO)) return -3; - currentCtlHalData = HalMgrGlobalData->first; + currentCtlHalData = HalMgrGlobalData->halDataList; while(currentCtlHalData) { if(! currentCtlHalData->apiName) diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.h b/4a-hal/4a-hal-manager/4a-hal-manager.h index 9749edc..b9eabba 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager.h +++ b/4a-hal/4a-hal-manager/4a-hal-manager.h @@ -23,7 +23,7 @@ #define HAL_MANAGER_API_NAME "4a-hal-manager" #define HAL_MANAGER_API_INFO "Manager for 4A HAL APIs" -// HAL Manager get first 'SpecificHalData' structure from HAL list function -struct SpecificHalData **HalMngGetFirstHalData(void); +// HAL Manager get 'SpecificHalData' linked list +struct SpecificHalData **HalMngGetHalDataList(void); #endif /* _HALMGR_BINDING_INCLUDE_ */
\ No newline at end of file |