diff options
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-alsa-data.c | 4 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-alsa-data.h | 22 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-data.c | 183 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-data.h | 64 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c | 79 | ||||
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h | 8 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager-cb.c | 35 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager.c | 41 | ||||
-rw-r--r-- | 4a-hal/4a-hal-manager/4a-hal-manager.h | 4 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.c (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c) | 92 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.h (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h) | 24 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-api-loader.c (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c) | 106 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-api-loader.h (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h) | 10 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-cb.c (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c) | 249 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-cb.h (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h) | 22 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.c (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c) | 107 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.h (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h) | 22 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-value-handler.c (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c) | 79 | ||||
-rw-r--r-- | 4a-hal/4a-internals-hal/4a-internals-hal-value-handler.h (renamed from 4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h) | 32 | ||||
-rw-r--r-- | 4a-hal/CMakeLists.txt | 14 | ||||
-rw-r--r-- | plugins/lib/bluealsa/hal-bluealsa.c | 9 |
21 files changed, 631 insertions, 575 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/4a-hal-utilities/4a-hal-utilities-alsa-data.c index 79cc8eb..6409253 100644 --- a/4a-hal-utilities/4a-hal-utilities-alsa-data.c +++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.c @@ -24,10 +24,10 @@ #include "4a-hal-utilities-alsa-data.h" /******************************************************************************* - * Free contents of 'CtlHalAlsaMapT' data structure * + * Free contents of 'InternalHalAlsaMapT' data structure * ******************************************************************************/ -uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap) +uint8_t HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap) { int idx; diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/4a-hal-utilities/4a-hal-utilities-alsa-data.h index ef0aba1..fe70210 100644 --- a/4a-hal-utilities/4a-hal-utilities-alsa-data.h +++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.h @@ -28,14 +28,14 @@ #include <ctl-config.h> -struct CtlHalAlsaDBScale { +struct InternalHalAlsaDBScale { int min; int max; int step; int mute; }; -struct CtlHalAlsaCtlProperties { +struct InternalHalAlsaCtlProperties { snd_ctl_elem_type_t type; int count; int minval; @@ -43,32 +43,32 @@ struct CtlHalAlsaCtlProperties { int step; // TBD JAI : use them const char **enums; - struct CtlHalAlsaDBScale *dbscale; + struct InternalHalAlsaDBScale *dbscale; }; -struct CtlHalAlsaCtl { +struct InternalHalAlsaCtl { char *name; int numid; int value; - struct CtlHalAlsaCtlProperties alsaCtlProperties; - struct CtlHalAlsaCtlProperties *alsaCtlCreation; + struct InternalHalAlsaCtlProperties alsaCtlProperties; + struct InternalHalAlsaCtlProperties *alsaCtlCreation; }; -struct CtlHalAlsaMap { +struct InternalHalAlsaMap { const char *uid; char *info; afb_event_t alsaControlEvent; - struct CtlHalAlsaCtl ctl; + struct InternalHalAlsaCtl ctl; json_object *actionJ; CtlActionT *action; }; -struct CtlHalAlsaMapT { - struct CtlHalAlsaMap *ctls; +struct InternalHalAlsaMapT { + struct InternalHalAlsaMap *ctls; unsigned int ctlsCount; }; // Free contents of 'CtlHalAlsaMapT' data structure -uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap); +uint8_t HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap); #endif /* _HAL_UTILITIES_ALSA_DATA_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c index 0790ed3..314190f 100644 --- a/4a-hal-utilities/4a-hal-utilities-data.c +++ b/4a-hal-utilities/4a-hal-utilities-data.c @@ -28,19 +28,19 @@ #include "4a-hal-utilities-alsa-data.h" /******************************************************************************* - * Specfic Hal controller streams data handling functions * + * Internal Hal - Streams data handling functions * ******************************************************************************/ -struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **mixerDataList) +struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList) { - struct CtlHalMixerData *currentMixerData; + struct InternalHalMixerData *currentMixerData; if(! mixerDataList) return NULL; currentMixerData = *mixerDataList; if(! currentMixerData) { - currentMixerData = (struct CtlHalMixerData *) calloc(1, sizeof(struct CtlHalMixerData)); + currentMixerData = (struct InternalHalMixerData *) calloc(1, sizeof(struct InternalHalMixerData)); if(! currentMixerData) return NULL; @@ -50,7 +50,7 @@ struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData while(currentMixerData->next) currentMixerData = currentMixerData->next; - currentMixerData->next = calloc(1, sizeof(struct CtlHalMixerData)); + currentMixerData->next = calloc(1, sizeof(struct InternalHalMixerData)); if(! currentMixerData->next) return NULL; @@ -60,9 +60,9 @@ struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData return currentMixerData; } -int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, struct CtlHalMixerData *mixerDataToRemove) +int8_t HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList, struct InternalHalMixerData *mixerDataToRemove) { - struct CtlHalMixerData *currentMixerData, *matchingMixerData; + struct InternalHalMixerData *currentMixerData, *matchingMixerData; if(! mixerDataList || ! *mixerDataList || ! mixerDataToRemove) return -1; @@ -94,7 +94,7 @@ int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, str return 0; } -int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList) +int64_t HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList) { int8_t ret; int64_t mixerDataRemoved = 0; @@ -113,16 +113,15 @@ int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList) return mixerDataRemoved; } -int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList) +int64_t HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList) { int64_t numberOfMixerData = 0; - struct CtlHalMixerData *currentMixerData; + struct InternalHalMixerData *currentMixerData; if(! mixerDataList) return -1; currentMixerData = *mixerDataList; - while(currentMixerData) { currentMixerData = currentMixerData->next; numberOfMixerData++; @@ -131,9 +130,9 @@ int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList) return numberOfMixerData; } -struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId) +struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId) { - struct CtlHalMixerData *currentMixerData; + struct InternalHalMixerData *currentMixerData; if(! mixerDataList || ! verb) return NULL; @@ -153,89 +152,89 @@ struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData } /******************************************************************************* - * Specfic Hal data handling functions * + * Hal data handling functions * ******************************************************************************/ -struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **halDataList) +struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList) { - struct SpecificHalData *currentApi; + struct HalData *currentHalData; if(! halDataList) return NULL; - currentApi = *halDataList; - if(! currentApi) { - currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData)); - if(! currentApi) + currentHalData = *halDataList; + if(! currentHalData) { + currentHalData = (struct HalData *) calloc(1, sizeof(struct HalData)); + if(! currentHalData) return NULL; - *halDataList = currentApi; + *halDataList = currentHalData; } else { - while(currentApi->next) - currentApi = currentApi->next; + while(currentHalData->next) + currentHalData = currentHalData->next; - currentApi->next = calloc(1, sizeof(struct SpecificHalData)); - if(! currentApi->next) + currentHalData->next = calloc(1, sizeof(struct HalData)); + if(! currentHalData->next) return NULL; - currentApi = currentApi->next; + currentHalData = currentHalData->next; } - return currentApi; + return currentHalData; } -int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **halDataList, struct SpecificHalData *apiToRemove) +int8_t HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData *halToRemove) { - struct SpecificHalData *currentApi, *matchingApi; + struct HalData *currentHalData, *matchingHal; - if(! halDataList || ! *halDataList || ! apiToRemove) + if(! halDataList || ! *halDataList || ! halToRemove) return -1; - currentApi = *halDataList; - if(currentApi == apiToRemove) { - *halDataList = currentApi->next; - matchingApi = currentApi; + currentHalData = *halDataList; + if(currentHalData == halToRemove) { + *halDataList = currentHalData->next; + matchingHal = currentHalData; } else { - while(currentApi && currentApi->next != apiToRemove) - currentApi = currentApi->next; + while(currentHalData && currentHalData->next != halToRemove) + currentHalData = currentHalData->next; - if(currentApi) { - matchingApi = currentApi->next; - currentApi->next = currentApi->next->next; + if(currentHalData) { + matchingHal = currentHalData->next; + currentHalData->next = currentHalData->next->next; } else { return -2; } } - free(matchingApi->apiName); - free(matchingApi->sndCardPath); - free(matchingApi->info); - free(matchingApi->author); - free(matchingApi->version); - free(matchingApi->date); + free(matchingHal->apiName); + free(matchingHal->sndCardPath); + free(matchingHal->info); + free(matchingHal->author); + free(matchingHal->version); + free(matchingHal->date); - if(matchingApi->internal) { - HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData); - HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalPlaybacksData); - HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalCapturesData); + if(matchingHal->internal) { + HalUtlRemoveAllMixerData(&matchingHal->internalHalData->streamsData); + HalUtlRemoveAllMixerData(&matchingHal->internalHalData->playbacksData); + HalUtlRemoveAllMixerData(&matchingHal->internalHalData->capturesData); - HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT); + HalUtlFreeAlsaCtlsMap(matchingHal->internalHalData->alsaMapT); - free(matchingApi->ctlHalSpecificData); + free(matchingHal->internalHalData); } - free(matchingApi); + free(matchingHal); return 0; } -int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList) +int64_t HalUtlRemoveAllHalFromList(struct HalData **halDataList) { int8_t ret; - int64_t CtlHalApiRemoved = 0; + int64_t halRemoved = 0; if(! halDataList) return -1; @@ -245,63 +244,63 @@ int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList) if(ret) return (int64_t) ret; - CtlHalApiRemoved++; + halRemoved++; } - return CtlHalApiRemoved; + return halRemoved; } -int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **halDataList) +int64_t HalUtlGetNumberOfHalInList(struct HalData **halDataList) { - int64_t numberOfCtlHal = 0; - struct SpecificHalData *currentApi; + int64_t numberOfHal = 0; + struct HalData *currentHalData; if(! halDataList) return -1; - currentApi = *halDataList; + currentHalData = *halDataList; - while(currentApi) { - currentApi = currentApi->next; - numberOfCtlHal++; + while(currentHalData) { + currentHalData = currentHalData->next; + numberOfHal++; } - return numberOfCtlHal; + return numberOfHal; } -struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **halDataList, char *apiName) +struct HalData *HalUtlSearchHalDataByApiName(struct HalData **halDataList, char *apiName) { - struct SpecificHalData *currentApi; + struct HalData *currentHalData; if(! halDataList || ! *halDataList || ! apiName) return NULL; - currentApi = *halDataList; + currentHalData = *halDataList; - while(currentApi) { - if(! strcmp(apiName, currentApi->apiName)) - return currentApi; + while(currentHalData) { + if(! strcmp(apiName, currentHalData->apiName)) + return currentHalData; - currentApi = currentApi->next; + currentHalData = currentHalData->next; } return NULL; } -struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **halDataList, int cardId) +struct HalData *HalUtlSearchReadyHalDataByCardId(struct HalData **halDataList, int cardId) { - struct SpecificHalData *currentApi; + struct HalData *currentHalData; if(! halDataList || ! *halDataList) return NULL; - currentApi = *halDataList; + currentHalData = *halDataList; - while(currentApi) { - if(currentApi->status == HAL_STATUS_READY && currentApi->sndCardId == cardId) - return currentApi; + while(currentHalData) { + if(currentHalData->status == HAL_STATUS_READY && currentHalData->sndCardId == cardId) + return currentHalData; - currentApi = currentApi->next; + currentHalData = currentHalData->next; } return NULL; @@ -311,35 +310,35 @@ struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData * Hal Manager data handling functions * ******************************************************************************/ -uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info) +uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *halMgrData, char *apiName, char *info) { - if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info) + if(! apiHandle || ! halMgrData || ! apiName || ! info) return -1; // Allocate and fill apiName and info strings - HalMgrGlobalData->apiName = strdup(apiName); - if(! HalMgrGlobalData->apiName) + halMgrData->apiName = strdup(apiName); + if(! halMgrData->apiName) return -2; - HalMgrGlobalData->info = strdup(info); - if(! HalMgrGlobalData->info) + halMgrData->info = strdup(info); + if(! halMgrData->info) return -3; - HalMgrGlobalData->apiHandle = apiHandle; + halMgrData->apiHandle = apiHandle; return 0; } -void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData) +void HalUtlRemoveHalMgrData(struct HalMgrData *halMgrData) { - if(! HalMgrGlobalData) + if(! halMgrData) return; - if(HalMgrGlobalData->halDataList) - HalUtlRemoveAllHalFromList(&HalMgrGlobalData->halDataList); + if(halMgrData->halDataList) + HalUtlRemoveAllHalFromList(&halMgrData->halDataList); - free(HalMgrGlobalData->apiName); - free(HalMgrGlobalData->info); + free(halMgrData->apiName); + free(halMgrData->info); - free(HalMgrGlobalData); + free(halMgrData); }
\ No newline at end of file diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h index 1389aa6..f3de1a6 100644 --- a/4a-hal-utilities/4a-hal-utilities-data.h +++ b/4a-hal-utilities/4a-hal-utilities-data.h @@ -30,7 +30,7 @@ #define HAL_STREAM_UPDATES_EVENT_NAME "stream-updates" -// Enum for sharing hal (controller or external) status +// Enum for hal status enum HalStatus { HAL_STATUS_UNAVAILABLE=0, HAL_STATUS_AVAILABLE=1, @@ -38,35 +38,35 @@ enum HalStatus { }; // Structure to store stream data -struct CtlHalMixerData { +struct InternalHalMixerData { char *verb; char *verbToCall; char *streamCardId; afb_event_t event; - struct CtlHalMixerData *next; + struct InternalHalMixerData *next; }; -// Structure to store specific controller hal data -struct CtlHalSpecificData { +// Structure to store specific internal hal data +struct InternalHalData { char *mixerApiName; char *prefix; json_object *halMixerJ; - struct CtlHalMixerData *ctlHalStreamsData; + struct InternalHalMixerData *streamsData; afb_event_t streamUpdates; - struct CtlHalMixerData *ctlHalPlaybacksData; - struct CtlHalMixerData *ctlHalCapturesData; + struct InternalHalMixerData *playbacksData; + struct InternalHalMixerData *capturesData; - struct CtlHalAlsaMapT *ctlHalAlsaMapT; + struct InternalHalAlsaMapT *alsaMapT; afb_api_t apiHandle; CtlConfigT *ctrlConfig; }; -// Structure to store specific hal (controller or external) data -struct SpecificHalData { +// Structure to store specific hal (internal or external) data +struct HalData { char *apiName; enum HalStatus status; char *sndCardPath; @@ -79,9 +79,9 @@ struct SpecificHalData { char *date; // Can be beefed up if needed - struct CtlHalSpecificData *ctlHalSpecificData; // Can be NULL if external api + struct InternalHalData *internalHalData; // Can be NULL if external api - struct SpecificHalData *next; + struct HalData *next; }; // Structure to store hal manager data @@ -91,26 +91,26 @@ struct HalMgrData { afb_api_t apiHandle; - struct SpecificHalData *halDataList; + struct HalData *halDataList; }; -// Specfic Hal controller streams data handling functions -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 **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); -void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData); +// Internal Hal - Streams data handling functions +struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList); +int8_t HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList, struct InternalHalMixerData *mixerDataToRemove); +int64_t HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList); +int64_t HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList); +struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId); + +// Hal data handling functions +struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList); +int8_t HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData *halToRemove); +int64_t HalUtlRemoveAllHalFromList(struct HalData **halDataList); +int64_t HalUtlGetNumberOfHalInList(struct HalData **halDataList); +struct HalData *HalUtlSearchHalDataByApiName(struct HalData **halDataList, char *apiName); +struct HalData *HalUtlSearchReadyHalDataByCardId(struct HalData **halDataList, int cardId); + +// Hal Manager data handling functions +uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *halMgrData, char *apiName, char *info); +void HalUtlRemoveHalMgrData(struct HalMgrData *halMgrData); #endif /* _HAL_UTILITIES_DATA_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c index 3f30436..ed06b27 100644 --- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c +++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c @@ -40,8 +40,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) afb_api_t apiHandle; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; - struct CtlHalMixerData *currentMixerData = NULL; + struct HalData *currentHalData; + struct InternalHalMixerData *currentMixerData = NULL; json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL; @@ -55,7 +55,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) return; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); return; } @@ -68,18 +69,19 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) json_object_object_add(requestJson, "verbose", json_object_new_boolean(1)); - apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName; + apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { afb_req_fail(request, "mixer_api", "Can't get mixer api"); return; } - if(currentCtlHalData->status != HAL_STATUS_READY) { + if(currentHalData->status != HAL_STATUS_READY) { afb_req_fail(request, "hal_not_ready", "Seems that hal is not ready"); return; } - if(! (currentMixerData = (struct CtlHalMixerData *) afb_req_get_vcbdata(request))) { + currentMixerData = (struct InternalHalMixerData *) afb_req_get_vcbdata(request); + if(! currentMixerData) { afb_req_fail(request, "hal_call_data", "Can't get current call data"); return; } @@ -227,27 +229,32 @@ void HalUtlActionOnAllStream(afb_req_t request) * Add stream data and verb function * ******************************************************************************/ -struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, - char *verb, - char *verbToCall, - char *streamCardId) +struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, + char *verb, + char *verbToCall, + char *streamCardId) { json_object *streamAddedEventJ; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentSpecificHalData; - struct CtlHalMixerData *createdStreamData; + struct HalData *currentHalData; + struct InternalHalMixerData *createdStreamData; if(! apiHandle || ! verb || ! verbToCall || ! streamCardId) return NULL; - if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) || - (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) || - (! currentSpecificHalData->ctlHalSpecificData)) + ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle); + if(! ctrlConfig) return NULL; - if(! (createdStreamData = HalUtlAddMixerDataToMixerDataList(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData))) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData || + ! currentHalData->internalHalData) + return NULL; + + createdStreamData = HalUtlAddMixerDataToMixerDataList(¤tHalData->internalHalData->streamsData); + if(! createdStreamData) return NULL; createdStreamData->verb = strdup(verb); @@ -257,12 +264,12 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand if((! createdStreamData->verb) || (! createdStreamData->verbToCall) || (! createdStreamData->streamCardId)) { - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) { - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } @@ -275,7 +282,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand 0, 0)) { AFB_API_ERROR(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb); - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } @@ -285,7 +292,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand "name", createdStreamData->verb, "cardId", createdStreamData->streamCardId); - afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamAddedEventJ); + afb_event_push(currentHalData->internalHalData->streamUpdates, streamAddedEventJ); return createdStreamData; } @@ -301,23 +308,28 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, CtlConfigT *ctrlConfig; - struct SpecificHalData *currentSpecificHalData; - struct CtlHalMixerData *toRemoveStreamData; + struct HalData *currentHalData; + struct InternalHalMixerData *toRemoveStreamData; if(! apiHandle || ! verb || ! verbToCall || ! streamCardId) return -1; - if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) || - (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) || - (! currentSpecificHalData->ctlHalSpecificData)) + ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle); + if(! ctrlConfig) return -2; - if(! (toRemoveStreamData = HalUtlSearchMixerDataByProperties(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, - verb, - verbToCall, - streamCardId))) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData || + ! currentHalData->internalHalData) return -3; + toRemoveStreamData = HalUtlSearchMixerDataByProperties(¤tHalData->internalHalData->streamsData, + verb, + verbToCall, + streamCardId); + if(! toRemoveStreamData) + return -4; + wrap_json_pack(&streamRemovedEventJ, "{s:s, s:s, s:s}", "action", "removed", @@ -327,16 +339,17 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, if(afb_api_del_verb(apiHandle, verb, NULL)) { AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb); json_object_put(streamRemovedEventJ); - return -4; + return -5; } - if((returnedErr = HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) { + returnedErr = HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, toRemoveStreamData); + if(returnedErr) { AFB_API_ERROR(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb); json_object_put(streamRemovedEventJ); - return -5; + return -6; } - afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamRemovedEventJ); + afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ); return 0; }
\ No newline at end of file diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h index ca065e7..028dd1f 100644 --- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h +++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h @@ -39,10 +39,10 @@ void HalUtlActionOnCapture(afb_req_t request); void HalUtlActionOnAllStream(afb_req_t request); // Add/Remove stream data and verb functions -struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, - char *verb, - char *verbToCall, - char *streamCardId); +struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, + char *verb, + char *verbToCall, + char *streamCardId); int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, char *verb, char *verbToCall, 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 77ae52f..32fbb25 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c @@ -62,8 +62,8 @@ void HalMgrLoaded(afb_req_t request) char cardIdString[32]; afb_api_t apiHandle; - struct HalMgrData *HalMgrGlobalData; - struct SpecificHalData *currentHalData; + struct HalMgrData *halMgrData; + struct HalData *currentHalData; json_object *requestJson, *requestAnswer, *apiObject; @@ -72,12 +72,13 @@ void HalMgrLoaded(afb_req_t request) return; } - if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) { + halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle); + if(! halMgrData) { afb_req_fail(request, "hal_manager_data", "Can't get hal manager data"); return; } - currentHalData = HalMgrGlobalData->halDataList; + currentHalData = halMgrData->halDataList; if(! currentHalData) { afb_req_success(request, NULL, "No Hal Api loaded"); @@ -136,8 +137,8 @@ void HalMgrLoad(afb_req_t request) char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL; afb_api_t apiHandle; - struct HalMgrData *HalMgrGlobalData; - struct SpecificHalData *addedHal; + struct HalMgrData *halMgrData; + struct HalData *addedHal; json_object *requestJson, *apiReceivedMetadata; @@ -146,7 +147,8 @@ void HalMgrLoad(afb_req_t request) return; } - if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) { + halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle); + if(! halMgrData) { afb_req_fail(request, "hal_manager_data", "Can't get hal manager data"); return; } @@ -174,7 +176,7 @@ void HalMgrLoad(afb_req_t request) return; } - addedHal = HalUtlAddHalApiToHalList(&HalMgrGlobalData->halDataList); + addedHal = HalUtlAddHalToHalList(&halMgrData->halDataList); addedHal->internal = 0; // TBD JAI : initialize external to unavailable once event from external hal will be handled @@ -207,8 +209,8 @@ void HalMgrUnload(afb_req_t request) char *apiName; afb_api_t apiHandle; - struct HalMgrData *HalMgrGlobalData; - struct SpecificHalData *HalToRemove; + struct HalMgrData *halMgrData; + struct HalData *halToRemove; json_object *requestJson; @@ -217,7 +219,8 @@ void HalMgrUnload(afb_req_t request) return; } - if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) { + halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle); + if(! halMgrData) { afb_req_fail(request, "hal_manager_data", "Can't get hal manager data"); return; } @@ -232,18 +235,18 @@ void HalMgrUnload(afb_req_t request) return; } - HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->halDataList, apiName); - if(! HalToRemove) { + halToRemove = HalUtlSearchHalDataByApiName(&halMgrData->halDataList, apiName); + if(! halToRemove) { afb_req_fail(request, "requested_api", "Can't find api to remove"); return; } - if(HalToRemove->internal) { - afb_req_fail(request, "requested_api", "Can't remove an internal controller api"); + if(halToRemove->internal) { + afb_req_fail(request, "requested_api", "Can't remove an internal hal"); return; } - if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->halDataList, HalToRemove)) { + if(HalUtlRemoveSelectedHalFromList(&halMgrData->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 017199f..4d2fbf1 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager.c @@ -25,7 +25,7 @@ #include "4a-hal-utilities-data.h" #include "4a-hal-utilities-verbs-loader.h" -#include "../4a-hal-controllers/4a-hal-controllers-api-loader.h" +#include "../4a-internals-hal/4a-internals-hal-api-loader.h" #include "4a-hal-manager.h" #include "4a-hal-manager-cb.h" @@ -54,11 +54,11 @@ afb_verb_t HalManagerApiStaticVerbs[] = }; /******************************************************************************* - * HAL Manager get 'SpecificHalData' linked list * + * HAL Manager get 'HalData' linked list * from HAL list function * ******************************************************************************/ -struct SpecificHalData **HalMngGetHalDataList(void) +struct HalData **HalMngGetHalDataList(void) { return &localHalMgrGlobalData.halDataList; } @@ -69,8 +69,8 @@ struct SpecificHalData **HalMngGetHalDataList(void) static int HalMgrInitApi(afb_api_t apiHandle) { - struct SpecificHalData *currentCtlHalData; - struct HalMgrData *HalMgrGlobalData; + struct HalData *currentHalData; + struct HalMgrData *halMgrData; if(! apiHandle) return -1; @@ -79,21 +79,22 @@ static int HalMgrInitApi(afb_api_t apiHandle) AFB_default = apiHandle; // Retrieve section config from api handle - if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) + halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle); + if(! halMgrData) return -2; - if(HalUtlInitializeHalMgrData(apiHandle, HalMgrGlobalData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO)) + if(HalUtlInitializeHalMgrData(apiHandle, halMgrData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO)) return -3; - currentCtlHalData = HalMgrGlobalData->halDataList; + currentHalData = halMgrData->halDataList; - while(currentCtlHalData) { - if(! currentCtlHalData->apiName) + while(currentHalData) { + if(! currentHalData->apiName) return -4; - else if(afb_api_require_api(apiHandle, currentCtlHalData->apiName, 1)) + else if(afb_api_require_api(apiHandle, currentHalData->apiName, 1)) return -5; - currentCtlHalData = currentCtlHalData->next; + currentHalData = currentHalData->next; } return 0; @@ -101,15 +102,15 @@ static int HalMgrInitApi(afb_api_t apiHandle) static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle) { - struct HalMgrData *HalMgrGlobalData; + struct HalMgrData *halMgrData; if(! cbdata || ! apiHandle) return -1; - HalMgrGlobalData = (struct HalMgrData *) cbdata; + halMgrData = (struct HalMgrData *) cbdata; // Save closure as api's data context - afb_api_set_userdata(apiHandle, HalMgrGlobalData); + afb_api_set_userdata(apiHandle, halMgrData); // Add static controls verbs if(HalUtlLoadVerbs(apiHandle, HalManagerApiStaticVerbs)) { @@ -128,13 +129,13 @@ static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle) return 0; } -int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData) +int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) { - if(! apiHandle || ! HalMgrGlobalData) + if(! apiHandle || ! halMgrData) return -1; // Create one API - return afb_api_new_api(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, HalMgrGlobalData) ? 0 : -1; + return afb_api_new_api(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, halMgrData) ? 0 : -1; } /******************************************************************************* @@ -158,8 +159,8 @@ int afbBindingEntry(afb_api_t apiHandle) if(rc < 0) status--; - // Load Hal-Ctls using Api v3 - rc = HalCtlsCreateAllApi(apiHandle, &localHalMgrGlobalData); + // Load internals Hal using Api v3 + rc = InternalHalCreateAllApi(apiHandle, &localHalMgrGlobalData); if(rc < 0) status -= rc; diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.h b/4a-hal/4a-hal-manager/4a-hal-manager.h index b9eabba..4a53bdd 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 'SpecificHalData' linked list -struct SpecificHalData **HalMngGetHalDataList(void); +// HAL Manager get 'HalData' linked list +struct HalData **HalMngGetHalDataList(void); #endif /* _HALMGR_BINDING_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.c index 214fca9..d092ddf 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c +++ b/4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.c @@ -31,8 +31,8 @@ #include "4a-hal-utilities-alsa-data.h" #include "4a-hal-utilities-data.h" -#include "4a-hal-controllers-alsacore-link.h" -#include "4a-hal-controllers-value-handler.h" +#include "4a-internals-hal-alsacore-link.h" +#include "4a-internals-hal-value-handler.h" /******************************************************************************* * Map to alsa control types * @@ -52,7 +52,7 @@ static const char *const snd_ctl_elem_type_names[] = { * Alsa control types map from string function * ******************************************************************************/ -snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label) +snd_ctl_elem_type_t InternalHalMapsAlsaTypeToEnum(const char *label) { int idx; static int length = sizeof(snd_ctl_elem_type_names) / sizeof(char *); @@ -66,10 +66,10 @@ snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label) } /******************************************************************************* - * HAL controllers alsacore calls funtions * + * Internals HAL - Alsacore calls funtions * ******************************************************************************/ -int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath) +int InternalHalGetCardIdByCardPath(afb_api_t apiHandle, char *devPath) { int errorToReturn, cardId; @@ -135,7 +135,7 @@ int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath) return errorToReturn; } -int HalCtlsSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId) +int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId) { int err = 0; @@ -169,7 +169,7 @@ int HalCtlsSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId) return err; } -int HalCtlsGetAlsaCtlInfo(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedDataJ) +int InternalHalGetAlsaCtlInfo(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl, json_object **returnedDataJ) { int err = 0; @@ -247,13 +247,14 @@ int HalCtlsGetAlsaCtlInfo(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCt return err; } -int HalCtlsUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl) +int InternalHalUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl) { int err = 0; json_object *returnedDataJ; - if((err = HalCtlsGetAlsaCtlInfo(apiHandle, cardId, currentAlsaCtl, &returnedDataJ))) { + err = InternalHalGetAlsaCtlInfo(apiHandle, cardId, currentAlsaCtl, &returnedDataJ); + if(err) { return err; } // TBD JAI : get dblinear/dbminmax/... values @@ -280,7 +281,7 @@ int HalCtlsUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct Ctl return err; } -int HalCtlsGetAlsaCtlValues(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedValuesJ) +int InternalHalGetAlsaCtlValues(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl, json_object **returnedValuesJ) { int err = 0; @@ -288,7 +289,8 @@ int HalCtlsGetAlsaCtlValues(afb_api_t apiHandle, char *cardId, struct CtlHalAlsa *returnedValuesJ = NULL; - if((err = HalCtlsGetAlsaCtlInfo(apiHandle, cardId, currentAlsaCtl, &returnedDataJ))) { + err = InternalHalGetAlsaCtlInfo(apiHandle, cardId, currentAlsaCtl, &returnedDataJ); + if(err) { return err; } else if(wrap_json_unpack(returnedDataJ, "{s:o}", "val", &returnedValuesArrayJ)) { @@ -319,7 +321,7 @@ int HalCtlsGetAlsaCtlValues(afb_api_t apiHandle, char *cardId, struct CtlHalAlsa return err; } -int HalCtlsSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ) +int InternalHalSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ) { int err = 0; @@ -374,7 +376,7 @@ int HalCtlsSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_ob return err; } -int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate) +int InternalHalCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *alsaCtlToCreate) { int err = 0; @@ -456,10 +458,10 @@ int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl } /******************************************************************************* - * HAL controllers alsacore controls request callback * + * Internals HAL - Alsacore controls request callback * ******************************************************************************/ -void HalCtlsActionOnAlsaCtl(afb_req_t request) +void InternalHalActionOnAlsaCtl(afb_req_t request) { char cardIdString[6]; @@ -467,8 +469,8 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; - struct CtlHalAlsaMap *currentAlsaCtl; + struct HalData *currentHalData; + struct InternalHalAlsaMap *currentAlsaCtl; json_object *requestJson, *valueJ, @@ -489,17 +491,19 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) return; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); return; } - if(currentCtlHalData->status == HAL_STATUS_UNAVAILABLE) { + if(currentHalData->status == HAL_STATUS_UNAVAILABLE) { afb_req_fail(request, "hal_unavailable", "Seems that hal is not available"); return; } - if(! (currentAlsaCtl = (struct CtlHalAlsaMap *) afb_req_get_vcbdata(request))) { + currentAlsaCtl = (struct InternalHalAlsaMap *) afb_req_get_vcbdata(request); + if(! currentAlsaCtl) { afb_req_fail(request, "alsa_control_data", "Can't get current alsa control data"); return; } @@ -509,17 +513,17 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) return; } - snprintf(cardIdString, 6, "hw:%i", currentCtlHalData->sndCardId); + snprintf(cardIdString, 6, "hw:%i", currentHalData->sndCardId); - if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &previousControlValuesJ)) { + if(InternalHalGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &previousControlValuesJ)) { afb_req_fail_f(request, "previous_values", "Error when trying to get unchanged alsa control values"); return; } - else if(HalCtlsConvertJsonValues(apiHandle, - ¤tAlsaCtl->ctl.alsaCtlProperties, - previousControlValuesJ, - &normalizedPreviousControlValuesJ, - CONVERSION_ALSACORE_TO_NORMALIZED)) { + else if(InternalHalConvertJsonValues(apiHandle, + ¤tAlsaCtl->ctl.alsaCtlProperties, + previousControlValuesJ, + &normalizedPreviousControlValuesJ, + CONVERSION_ALSACORE_TO_NORMALIZED)) { afb_req_fail_f(request, "request_json", "Error when trying to normalize unchanged alsa control values json '%s'", @@ -554,11 +558,11 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) } if((! json_object_is_type(valueJ, json_type_string)) && - HalCtlsConvertJsonValues(apiHandle, - ¤tAlsaCtl->ctl.alsaCtlProperties, - valueJ, - &convertedJ, - CONVERSION_NORMALIZED_TO_ALSACORE)) { + InternalHalConvertJsonValues(apiHandle, + ¤tAlsaCtl->ctl.alsaCtlProperties, + valueJ, + &convertedJ, + CONVERSION_NORMALIZED_TO_ALSACORE)) { afb_req_fail_f(request, "request_json", "Error when trying to convert request values '%s'", @@ -568,11 +572,11 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) return; } else if(json_object_is_type(valueJ, json_type_string) && - HalCtlsChangePreviousValuesUsingJson(apiHandle, - ¤tAlsaCtl->ctl.alsaCtlProperties, - valueJ, - previousControlValuesJ, - &convertedJ)) { + InternalHalChangePreviousValuesUsingJson(apiHandle, + ¤tAlsaCtl->ctl.alsaCtlProperties, + valueJ, + previousControlValuesJ, + &convertedJ)) { afb_req_fail_f(request, "previous_values", "Error when trying to generate changed alsa control values (values : '%s', previous :'%s')", @@ -585,7 +589,7 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) json_object_put(previousControlValuesJ); - if(HalCtlsSetAlsaCtlValue(apiHandle, cardIdString, currentAlsaCtl->ctl.numid, convertedJ)) { + if(InternalHalSetAlsaCtlValue(apiHandle, cardIdString, currentAlsaCtl->ctl.numid, convertedJ)) { afb_req_fail_f(request, "alsa_control_call_error", "Error while trying to set value on alsa control %i, device '%s', converted message '%s'", @@ -599,16 +603,16 @@ void HalCtlsActionOnAlsaCtl(afb_req_t request) json_object_put(convertedJ); - if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &appliedControlValuesJ)) { + if(InternalHalGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &appliedControlValuesJ)) { afb_req_fail_f(request, "applied_values", "Error when trying to get applied alsa control values"); json_object_put(normalizedPreviousControlValuesJ); return; } - else if(HalCtlsConvertJsonValues(apiHandle, - ¤tAlsaCtl->ctl.alsaCtlProperties, - appliedControlValuesJ, - &normalizedAppliedControlValuesJ, - CONVERSION_ALSACORE_TO_NORMALIZED)) { + else if(InternalHalConvertJsonValues(apiHandle, + ¤tAlsaCtl->ctl.alsaCtlProperties, + appliedControlValuesJ, + &normalizedAppliedControlValuesJ, + CONVERSION_ALSACORE_TO_NORMALIZED)) { afb_req_fail_f(request, "request_json", "Error when trying to normalize applied values json '%s'", diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.h index 5081b49..065e017 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h +++ b/4a-hal/4a-internals-hal/4a-internals-hal-alsacore-link.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _HAL_CTLS_ALSACORE_LINK_INCLUDE_ -#define _HAL_CTLS_ALSACORE_LINK_INCLUDE_ +#ifndef _INTERNALS_HAL_ALSACORE_LINK_INCLUDE_ +#define _INTERNALS_HAL_ALSACORE_LINK_INCLUDE_ #include <stdio.h> @@ -38,16 +38,16 @@ #define ALSACORE_ADDCTL_VERB "addcustomctl" // Alsa control types map from string function -snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label); +snd_ctl_elem_type_t InternalHalMapsAlsaTypeToEnum(const char *label); -// HAL controllers alsacore calls funtions -int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath); -int HalCtlsSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId); -int HalCtlsUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl); -int HalCtlsSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ); -int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate); +// Internals HAL alsacore calls funtions +int InternalHalGetCardIdByCardPath(afb_api_t apiHandle, char *devPath); +int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId); +int InternalHalUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl); +int InternalHalSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ); +int InternalHalCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *alsaCtlToCreate); -// HAL controllers alsacore controls request callback -void HalCtlsActionOnAlsaCtl(afb_req_t request); +// Internals HAL alsacore controls request callback +void InternalHalActionOnAlsaCtl(afb_req_t request); -#endif /* _HAL_CTLS_ALSACORE_LINK_INCLUDE_ */
\ No newline at end of file +#endif /* _INTERNALS_HAL_ALSACORE_LINK_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-internals-hal/4a-internals-hal-api-loader.c index a6f6895..94891b8 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c +++ b/4a-hal/4a-internals-hal/4a-internals-hal-api-loader.c @@ -28,28 +28,27 @@ #include <ctl-config.h> #include "4a-hal-utilities-verbs-loader.h" - -#include "4a-hal-controllers-api-loader.h" -#include "4a-hal-controllers-alsacore-link.h" -#include "4a-hal-controllers-cb.h" -#include "4a-hal-controllers-mixer-link.h" +#include "4a-internals-hal-api-loader.h" +#include "4a-internals-hal-alsacore-link.h" +#include "4a-internals-hal-cb.h" +#include "4a-internals-hal-mixer-link.h" // Default api to print log when apihandle not available afb_api_t AFB_default; /******************************************************************************* - * Json parsing functions using app controller * + * Json parsing functions using controller * ******************************************************************************/ // Config Section definition static CtlSectionT ctrlSectionsDefault[] = { - { .key = "resources", .loadCB = PluginConfig }, - { .key = "halmixer", .loadCB = HalCtlsHalMixerConfig }, - { .key = "onload", .loadCB = OnloadConfig }, - { .key = "controls", .loadCB = ControlConfig }, - { .key = "events", .loadCB = EventConfig }, - { .key = "halmap", .loadCB = HalCtlsHalMapConfig }, + { .key = "resources", .loadCB = PluginConfig }, + { .key = "halmixer", .loadCB = InternalHalHalMixerConfig }, + { .key = "onload", .loadCB = OnloadConfig }, + { .key = "controls", .loadCB = ControlConfig }, + { .key = "events", .loadCB = EventConfig }, + { .key = "halmap", .loadCB = InternalHalHalMapConfig }, { .key = NULL } }; @@ -58,23 +57,23 @@ static CtlSectionT ctrlSectionsDefault[] = ******************************************************************************/ // Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT -static afb_verb_t CtlHalApiStaticVerbs[] = +static afb_verb_t InternalHalApiStaticVerbs[] = { /* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */ - { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures/controls for this api" }, - { .verb = "subscribe", .callback = HalCtlsSubscribe, .info = "Subscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" }, - { .verb = "unsubscribe", .callback = HalCtlsUnsubscribe, .info = "Unsubscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" }, + { .verb = "info", .callback = InternalHalInfo, .info = "List available streams/playbacks/captures/controls for this api" }, + { .verb = "subscribe", .callback = InternalHalSubscribe, .info = "Subscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" }, + { .verb = "unsubscribe", .callback = InternalHalUnsubscribe, .info = "Unsubscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" }, { .verb = NULL } // Marker for end of the array }; /******************************************************************************* - * Dynamic API functions for app controller * + * Dynamic API functions for internals hal * ******************************************************************************/ -static int HalCtlsInitOneApi(afb_api_t apiHandle) +static int InternalHalInitOneApi(afb_api_t apiHandle) { CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; + struct HalData *currentHalData; if(! apiHandle) return -1; @@ -86,39 +85,40 @@ static int HalCtlsInitOneApi(afb_api_t apiHandle) if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) return -2; - currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig); - if(! currentCtlHalData) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) return -3; - // Fill SpecificHalDatadata structure - currentCtlHalData->internal = 1; + // Fill HalDatadata structure + currentHalData->internal = 1; - currentCtlHalData->sndCardPath = (char *) ctrlConfig->uid; - currentCtlHalData->info = (char *) ctrlConfig->info; + currentHalData->sndCardPath = (char *) ctrlConfig->uid; + currentHalData->info = (char *) ctrlConfig->info; - currentCtlHalData->author = (char *) ctrlConfig->author; - currentCtlHalData->version = (char *) ctrlConfig->version; - currentCtlHalData->date = (char *) ctrlConfig->date; + currentHalData->author = (char *) ctrlConfig->author; + currentHalData->version = (char *) ctrlConfig->version; + currentHalData->date = (char *) ctrlConfig->date; - currentCtlHalData->ctlHalSpecificData->apiHandle = apiHandle; - currentCtlHalData->ctlHalSpecificData->ctrlConfig = ctrlConfig; + currentHalData->internalHalData->apiHandle = apiHandle; + currentHalData->internalHalData->ctrlConfig = ctrlConfig; - currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath); + currentHalData->sndCardId = InternalHalGetCardIdByCardPath(apiHandle, currentHalData->sndCardPath); - if(! (currentCtlHalData->ctlHalSpecificData->streamUpdates = afb_api_make_event(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME))) + currentHalData->internalHalData->streamUpdates = afb_api_make_event(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME); + if(! currentHalData->internalHalData->streamUpdates) return -4; - if(currentCtlHalData->sndCardId < 0) - currentCtlHalData->status = HAL_STATUS_UNAVAILABLE; + if(currentHalData->sndCardId < 0) + currentHalData->status = HAL_STATUS_UNAVAILABLE; else - currentCtlHalData->status = HAL_STATUS_AVAILABLE; + currentHalData->status = HAL_STATUS_AVAILABLE; // TBD JAI: handle refresh of hal status for dynamic card (/dev/by-id) return CtlConfigExec(apiHandle, ctrlConfig); } -static int HalCtlsLoadOneApi(void *cbdata, afb_api_t apiHandle) +static int InternalHalLoadOneApi(void *cbdata, afb_api_t apiHandle) { int err; CtlConfigT *ctrlConfig; @@ -133,7 +133,7 @@ static int HalCtlsLoadOneApi(void *cbdata, afb_api_t apiHandle) afb_api_set_userdata(apiHandle, ctrlConfig); // Add static controls verbs - if(HalUtlLoadVerbs(apiHandle, CtlHalApiStaticVerbs)) { + if(HalUtlLoadVerbs(apiHandle, InternalHalApiStaticVerbs)) { AFB_API_ERROR(apiHandle, "Load Section : fail to register static V2 verbs"); return 1; } @@ -146,20 +146,20 @@ static int HalCtlsLoadOneApi(void *cbdata, afb_api_t apiHandle) return err; // Declare an event manager for this Api - afb_api_on_event(apiHandle, HalCtlsDispatchApiEvent); + afb_api_on_event(apiHandle, InternalHalDispatchApiEvent); // Init Api function (does not receive user closure ???) - afb_api_on_init(apiHandle, HalCtlsInitOneApi); + afb_api_on_init(apiHandle, InternalHalInitOneApi); return 0; } -int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrGlobalData) +int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *halMgrData) { CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; + struct HalData *currentHalData; - if(! apiHandle || ! path || ! HalMgrGlobalData) + if(! apiHandle || ! path || ! halMgrData) return -1; // Create one Api per file @@ -175,26 +175,26 @@ int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrG } // Allocation of current hal controller data - currentCtlHalData = HalUtlAddHalApiToHalList(&HalMgrGlobalData->halDataList); - if(! currentCtlHalData) + currentHalData = HalUtlAddHalToHalList(&halMgrData->halDataList); + if(! currentHalData) return -4; - currentCtlHalData->apiName = (char *) ctrlConfig->api; + currentHalData->apiName = (char *) ctrlConfig->api; - // Stores current hal controller data in controller config - setExternalData(ctrlConfig, (void *) currentCtlHalData); + // Stores hal data in controller config + setExternalData(ctrlConfig, (void *) currentHalData); - // Allocation of the structure that will be used to store specific hal controller data - currentCtlHalData->ctlHalSpecificData = calloc(1, sizeof(struct CtlHalSpecificData)); + // Allocation of the structure that will be used to store internal hal data + currentHalData->internalHalData = calloc(1, sizeof(struct InternalHalData)); // Create one API - if(! afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig)) + if(! afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, InternalHalLoadOneApi, ctrlConfig)) return -5; return 0; } -int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData) +int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) { int index, status = 0; char *dirList, *fileName, *fullPath; @@ -204,7 +204,7 @@ int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData json_object *configJ, *entryJ; - if(! apiHandle || ! HalMgrGlobalData) + if(! apiHandle || ! halMgrData) return -1; // Hugely hack to make all V2 AFB_DEBUG to work in fileutils @@ -235,7 +235,7 @@ int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData strncat(filePath, "/", sizeof(filePath) - 1); strncat(filePath, fileName, sizeof(filePath) - 1); - if(HalCtlsCreateApi(apiHandle, filePath, HalMgrGlobalData) < 0) + if(InternalHalCreateApi(apiHandle, filePath, halMgrData) < 0) status--; } diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h b/4a-hal/4a-internals-hal/4a-internals-hal-api-loader.h index dd33108..fa878e2 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h +++ b/4a-hal/4a-internals-hal/4a-internals-hal-api-loader.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _HAL_CTLS_API_LOADER_INCLUDE_ -#define _HAL_CTLS_API_LOADER_INCLUDE_ +#ifndef _INTERNALS_HAL_API_LOADER_INCLUDE_ +#define _INTERNALS_HAL_API_LOADER_INCLUDE_ #include <stdio.h> @@ -25,7 +25,7 @@ #include "4a-hal-utilities-data.h" // Verbs that can be use to create api -int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrGlobalData); -int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData); +int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *halMgrData); +int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData); -#endif /* _HAL_CTLS_API_LOADER_INCLUDE_ */
\ No newline at end of file +#endif /* _INTERNALS_HAL_API_LOADER_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-internals-hal/4a-internals-hal-cb.c index c38b057..0102d8d 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-internals-hal/4a-internals-hal-cb.c @@ -26,36 +26,37 @@ #include "4a-hal-utilities-data.h" -#include "4a-hal-controllers-cb.h" -#include "4a-hal-controllers-alsacore-link.h" -#include "4a-hal-controllers-mixer-link.h" -#include "4a-hal-controllers-value-handler.h" +#include "4a-internals-hal-cb.h" +#include "4a-internals-hal-alsacore-link.h" +#include "4a-internals-hal-mixer-link.h" +#include "4a-internals-hal-value-handler.h" /******************************************************************************* - * HAL controller event handler function * + * Internals HAL Event handler function * ******************************************************************************/ -void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ) +void InternalHalDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ) { int numid, idx = 0, cardidx; CtlConfigT *ctrlConfig; CtlSourceT source; - struct SpecificHalData *currentHalData; - struct CtlHalAlsaMapT *currentHalAlsaCtlsT; + struct HalData *currentHalData; + struct InternalHalAlsaMapT *currentHalAlsaCtlsT; json_object *valuesJ, *normalizedValuesJ; AFB_API_DEBUG(apiHandle, "Evtname=%s [msg=%s]", evtLabel, json_object_get_string(eventJ)); if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) { - AFB_API_ERROR(apiHandle, "Can't get current hal controller config"); + AFB_API_ERROR(apiHandle, "Can't get current internal hal controller config"); return; } - if(! (currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { - AFB_API_WARNING(apiHandle, "Can't get current hal controller data"); + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { + AFB_API_WARNING(apiHandle, "Can't get current internal hal controller data"); return; } @@ -71,7 +72,7 @@ void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_obj return; } - currentHalAlsaCtlsT = currentHalData->ctlHalSpecificData->ctlHalAlsaMapT; + currentHalAlsaCtlsT = currentHalData->internalHalData->alsaMapT; // Search for corresponding numid in halCtls, if found, launch callback (if available) for(idx = 0; idx < currentHalAlsaCtlsT->ctlsCount; idx++) { @@ -90,11 +91,11 @@ void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_obj } if((! currentHalAlsaCtlsT->ctls[idx].alsaControlEvent) || - HalCtlsConvertJsonValues(apiHandle, - ¤tHalAlsaCtlsT->ctls[idx].ctl.alsaCtlProperties, - valuesJ, - &normalizedValuesJ, - CONVERSION_ALSACORE_TO_NORMALIZED) || + InternalHalConvertJsonValues(apiHandle, + ¤tHalAlsaCtlsT->ctls[idx].ctl.alsaCtlProperties, + valuesJ, + &normalizedValuesJ, + CONVERSION_ALSACORE_TO_NORMALIZED) || (afb_event_push(currentHalAlsaCtlsT->ctls[idx].alsaControlEvent, normalizedValuesJ) < 0)) { AFB_API_ERROR(apiHandle, "Couldn't generate an event for known halmap %s (alsa control id %i)", @@ -124,15 +125,15 @@ void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_obj } /******************************************************************************* - * HAL controllers sections parsing functions * + * Internals HAL - 'halmixer' section parsing/handling functions * ******************************************************************************/ -int HalCtlsHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ) +int InternalHalHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ) { int err = 0; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentHalData; + struct HalData *currentHalData; if(! apiHandle || ! section) return -1; @@ -140,30 +141,37 @@ int HalCtlsHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) return -2; - if(! (currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) return -3; if(MixerJ) { if(json_object_is_type(MixerJ, json_type_object)) - currentHalData->ctlHalSpecificData->halMixerJ = MixerJ; + currentHalData->internalHalData->halMixerJ = MixerJ; else return -4; - if(wrap_json_unpack(MixerJ, "{s:s}", "mixerapi", ¤tHalData->ctlHalSpecificData->mixerApiName)) + if(wrap_json_unpack(MixerJ, "{s:s}", "mixerapi", ¤tHalData->internalHalData->mixerApiName)) return -5; - wrap_json_unpack(MixerJ, "{s?:s}", "prefix", ¤tHalData->ctlHalSpecificData->prefix); + wrap_json_unpack(MixerJ, "{s?:s}", "prefix", ¤tHalData->internalHalData->prefix); } - else if(currentHalData->status == HAL_STATUS_AVAILABLE && - (err = HalCtlsAttachToMixer(apiHandle))) { - AFB_API_ERROR(apiHandle, "%s: Error %i while attaching to mixer", __func__, err); - return -6; + else if(currentHalData->status == HAL_STATUS_AVAILABLE) { + err = InternalHalAttachToMixer(apiHandle); + if(err) { + AFB_API_ERROR(apiHandle, "Error %i while attaching to mixer", err); + return -6; + } } return 0; } -int HalCtlsProcessOneHalMapObject(afb_api_t apiHandle, struct CtlHalAlsaMap *alsaMap, json_object *AlsaMapJ) +/******************************************************************************* + * Internals HAL - 'halmap' section parsing/handling functions * + ******************************************************************************/ + +int InternalHalProcessOneHalMapObject(afb_api_t apiHandle, struct InternalHalAlsaMap *alsaMap, json_object *AlsaMapJ) { char *action = NULL, *typename = NULL; @@ -203,9 +211,12 @@ int HalCtlsProcessOneHalMapObject(afb_api_t apiHandle, struct CtlHalAlsaMap *als return -3; } - if(typename && (alsaMap->ctl.alsaCtlCreation->type = HalCtlsMapsAlsaTypeToEnum(typename)) == SND_CTL_ELEM_TYPE_NONE) { - AFB_API_ERROR(apiHandle, "Couldn't get alsa type from string %s in:\n-- %s", typename, json_object_get_string(alsaJ)); - return -4; + if(typename) { + alsaMap->ctl.alsaCtlCreation->type = InternalHalMapsAlsaTypeToEnum(typename); + if(alsaMap->ctl.alsaCtlCreation->type == SND_CTL_ELEM_TYPE_NONE) { + AFB_API_ERROR(apiHandle, "Couldn't get alsa type from string %s in:\n-- %s", typename, json_object_get_string(alsaJ)); + return -4; + } } if(! alsaMap->ctl.name) @@ -232,7 +243,7 @@ int HalCtlsProcessOneHalMapObject(afb_api_t apiHandle, struct CtlHalAlsaMap *als return 0; } -int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaMap *alsaMap) +int InternalHalHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaMap *alsaMap) { int err; @@ -246,12 +257,12 @@ int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHa } if(alsaMap->ctl.alsaCtlCreation) { - if(HalCtlsCreateAlsaCtl(apiHandle, cardId, &alsaMap->ctl)) { + if(InternalHalCreateAlsaCtl(apiHandle, cardId, &alsaMap->ctl)) { AFB_API_ERROR(apiHandle, "An error happened when trying to create a new alsa control"); return -2; } } - else if(HalCtlsUpdateAlsaCtlProperties(apiHandle, cardId, &alsaMap->ctl)) { + else if(InternalHalUpdateAlsaCtlProperties(apiHandle, cardId, &alsaMap->ctl)) { AFB_API_ERROR(apiHandle, "An error happened when trying to get existing alsa control info"); return -3; } @@ -261,11 +272,11 @@ int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHa valueJ = json_object_new_int(alsaMap->ctl.value); err = 0; - if(HalCtlsConvertJsonValues(apiHandle, &alsaMap->ctl.alsaCtlProperties, valueJ, &convertedValueJ, CONVERSION_NORMALIZED_TO_ALSACORE)) { + if(InternalHalConvertJsonValues(apiHandle, &alsaMap->ctl.alsaCtlProperties, valueJ, &convertedValueJ, CONVERSION_NORMALIZED_TO_ALSACORE)) { AFB_API_ERROR(apiHandle, "Error when trying to convert initiate value json '%s'", json_object_get_string(valueJ)); err = -4; } - else if(HalCtlsSetAlsaCtlValue(apiHandle, cardId, alsaMap->ctl.numid, convertedValueJ)) { + else if(InternalHalSetAlsaCtlValue(apiHandle, cardId, alsaMap->ctl.numid, convertedValueJ)) { AFB_API_ERROR(apiHandle, "Error while trying to set initial value on alsa control %i, device '%s', value '%s'", alsaMap->ctl.numid, @@ -293,7 +304,7 @@ int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHa } } - if(afb_api_add_verb(apiHandle, alsaMap->uid, alsaMap->info, HalCtlsActionOnAlsaCtl, (void *) alsaMap, NULL, 0, 0)) { + if(afb_api_add_verb(apiHandle, alsaMap->uid, alsaMap->info, InternalHalActionOnAlsaCtl, (void *) alsaMap, NULL, 0, 0)) { AFB_API_ERROR(apiHandle, "Didn't succeed to create verb for current alsa control to load action using alsa object:\n-- %s", json_object_get_string(alsaMap->actionJ)); @@ -303,42 +314,42 @@ int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHa return 0; } -int HalCtlsProcessAllHalMap(afb_api_t apiHandle, json_object *AlsaMapJ, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT) +int InternalHalProcessAllHalMap(afb_api_t apiHandle, json_object *AlsaMapJ, struct InternalHalAlsaMapT *currentInternalHalAlsaMapT) { int idx, err = 0; - struct CtlHalAlsaMap *ctlMaps; + struct InternalHalAlsaMap *ctlMaps; json_type alsaMapType; alsaMapType = json_object_get_type(AlsaMapJ); switch(alsaMapType) { case json_type_array: - currentCtlHalAlsaMapT->ctlsCount = (unsigned int) json_object_array_length(AlsaMapJ); + currentInternalHalAlsaMapT->ctlsCount = (unsigned int) json_object_array_length(AlsaMapJ); break; case json_type_object: - currentCtlHalAlsaMapT->ctlsCount = 1; + currentInternalHalAlsaMapT->ctlsCount = 1; break; default: - currentCtlHalAlsaMapT->ctlsCount = 0; - currentCtlHalAlsaMapT->ctls = NULL; - AFB_API_WARNING(apiHandle, "Couldn't get content of 'halmap' section in:\n-- %s", json_object_get_string(AlsaMapJ)); + currentInternalHalAlsaMapT->ctlsCount = 0; + currentInternalHalAlsaMapT->ctls = NULL; + AFB_API_WARNING(apiHandle, "Couldn't get content of 'halmap' section in : '%s'", json_object_get_string(AlsaMapJ)); return -1; } - ctlMaps = calloc(currentCtlHalAlsaMapT->ctlsCount, sizeof(struct CtlHalAlsaMap)); + ctlMaps = calloc(currentInternalHalAlsaMapT->ctlsCount, sizeof(struct InternalHalAlsaMap)); - for(idx = 0; idx < currentCtlHalAlsaMapT->ctlsCount; idx++) - err += HalCtlsProcessOneHalMapObject(apiHandle, &ctlMaps[idx], alsaMapType == json_type_array ? json_object_array_get_idx(AlsaMapJ, idx) : AlsaMapJ); + for(idx = 0; idx < currentInternalHalAlsaMapT->ctlsCount; idx++) + err += InternalHalProcessOneHalMapObject(apiHandle, &ctlMaps[idx], alsaMapType == json_type_array ? json_object_array_get_idx(AlsaMapJ, idx) : AlsaMapJ); - currentCtlHalAlsaMapT->ctls = ctlMaps; + currentInternalHalAlsaMapT->ctls = ctlMaps; return err; } -int HalCtlsHandleAllHalMap(afb_api_t apiHandle, int sndCardId, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT) +int InternalHalHandleAllHalMap(afb_api_t apiHandle, int sndCardId, struct InternalHalAlsaMapT *currentInternalHalAlsaMapT) { int idx, err = 0; @@ -346,30 +357,30 @@ int HalCtlsHandleAllHalMap(afb_api_t apiHandle, int sndCardId, struct CtlHalAlsa snprintf(cardIdString, 6, "hw:%i", sndCardId); - HalCtlsSubscribeToAlsaCardEvent(apiHandle, cardIdString); + InternalHalSubscribeToAlsaCardEvent(apiHandle, cardIdString); - for(idx = 0; idx < currentCtlHalAlsaMapT->ctlsCount; idx++) - err += HalCtlsHandleOneHalMapObject(apiHandle, cardIdString, ¤tCtlHalAlsaMapT->ctls[idx]); + for(idx = 0; idx < currentInternalHalAlsaMapT->ctlsCount; idx++) + err += InternalHalHandleOneHalMapObject(apiHandle, cardIdString, ¤tInternalHalAlsaMapT->ctls[idx]); return err; } -int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *AlsaMapJ) +int InternalHalHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *AlsaMapJ) { CtlConfigT *ctrlConfig; - struct SpecificHalData *currentHalData; + struct HalData *currentHalData; if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) return -1; - currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig); + currentHalData = (struct HalData *) getExternalData(ctrlConfig); if(! currentHalData) return -2; if(AlsaMapJ) { - currentHalData->ctlHalSpecificData->ctlHalAlsaMapT = calloc(1, sizeof(struct CtlHalAlsaMapT)); + currentHalData->internalHalData->alsaMapT = calloc(1, sizeof(struct InternalHalAlsaMapT)); - if(HalCtlsProcessAllHalMap(apiHandle, AlsaMapJ, currentHalData->ctlHalSpecificData->ctlHalAlsaMapT)) { + if(InternalHalProcessAllHalMap(apiHandle, AlsaMapJ, currentHalData->internalHalData->alsaMapT)) { AFB_API_ERROR(apiHandle, "Failed to process 'halmap' section"); return -3; } @@ -382,15 +393,15 @@ int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object * AFB_API_ERROR(apiHandle, "Hal alsa card id is not valid, 'halmap' section data can't be handle"); return -6; } - else if(! currentHalData->ctlHalSpecificData->ctlHalAlsaMapT) { + else if(! currentHalData->internalHalData->alsaMapT) { AFB_API_WARNING(apiHandle, "'halmap' section data is empty"); return 2; } - else if(! (currentHalData->ctlHalSpecificData->ctlHalAlsaMapT->ctlsCount > 0)) { + else if(! (currentHalData->internalHalData->alsaMapT->ctlsCount > 0)) { AFB_API_WARNING(apiHandle, "No alsa controls defined in 'halmap' section"); return 3; } - else if(HalCtlsHandleAllHalMap(apiHandle, currentHalData->sndCardId, currentHalData->ctlHalSpecificData->ctlHalAlsaMapT)) { + else if(InternalHalHandleAllHalMap(apiHandle, currentHalData->sndCardId, currentHalData->internalHalData->alsaMapT)) { AFB_API_ERROR(apiHandle, "Failed to handle 'halmap' section"); return -9; } @@ -399,17 +410,19 @@ int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object * } /******************************************************************************* - * HAL controllers verbs functions * + * Internals HAL verbs functions * ******************************************************************************/ -json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct CtlHalMixerData **mixerDataList, enum MixerDataType dataType) +json_object *InternalHalGetJsonArrayForMixerDataTable(afb_api_t apiHandle, + struct InternalHalMixerData **mixerDataList, + enum MixerDataType dataType) { json_object *mixerDataArrayJ, *currentMixerDataJ; - struct CtlHalMixerData *currentMixerData; + struct InternalHalMixerData *currentMixerData; if(! apiHandle) { - AFB_API_ERROR(apiHandle, "Can't get current hal controller api handle"); + AFB_API_ERROR(apiHandle, "Api handle is not valid"); return NULL; } @@ -451,14 +464,14 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct Ct return mixerDataArrayJ; } -json_object *HalCtlsGetJsonArrayForControls(afb_api_t apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT) +json_object *InternalHalGetJsonArrayForControls(afb_api_t apiHandle, struct InternalHalAlsaMapT *currentAlsaMapDataT) { unsigned int idx; json_object *alsaMapDataArray, *currentAlsaMapData; if(! apiHandle) { - AFB_API_ERROR(apiHandle, "Can't get current hal controller api handle"); + AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle"); return NULL; } @@ -484,29 +497,30 @@ json_object *HalCtlsGetJsonArrayForControls(afb_api_t apiHandle, struct CtlHalAl return alsaMapDataArray; } -void HalCtlsInfo(afb_req_t request) +void InternalHalInfo(afb_req_t request) { char *apiToCall, *returnedError = NULL, *returnedInfo = NULL; afb_api_t apiHandle; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; + struct HalData *currentHalData; json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray, *controlsArray; if(! (apiHandle = afb_req_get_api(request))) { - afb_req_fail(request, "api_handle", "Can't get current hal controller api handle"); + afb_req_fail(request, "api_handle", "Can't get current internal hal api handle"); return; } if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) { - afb_req_fail(request, "hal_controller_config", "Can't get current hal controller config"); + afb_req_fail(request, "hal_controller_config", "Can't get current internal hal controller config"); return; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { - afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { + afb_req_fail(request, "hal_controller_data", "Can't get current internal hal controller data"); return; } @@ -514,13 +528,13 @@ void HalCtlsInfo(afb_req_t request) AFB_REQ_NOTICE(request, "Can't get request json"); } else if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) { - apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName; + apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { afb_req_fail(request, "mixer_api", "Can't get mixer api"); return; } - if(HalCtlsGetInfoFromMixer(apiHandle, apiToCall, requestJson, &toReturnJ, &returnedError, &returnedInfo)) { + if(InternalHalGetInfoFromMixer(apiHandle, apiToCall, requestJson, &toReturnJ, &returnedError, &returnedInfo)) { afb_req_fail_f(request, "mixer_info", "Call to mixer info verb didn't succeed with status '%s' and info '%s'", @@ -533,29 +547,33 @@ void HalCtlsInfo(afb_req_t request) return; } - if(! (streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, - ¤tCtlHalData->ctlHalSpecificData->ctlHalStreamsData, - MIXER_DATA_STREAMS))) { + streamsArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle, + ¤tHalData->internalHalData->streamsData, + MIXER_DATA_STREAMS); + if(! streamsArray) { afb_req_fail(request, "streams_data", "Didn't succeed to generate streams data array"); return; } - if(! (playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, - ¤tCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData, - MIXER_DATA_PLAYBACKS))) { + playbacksArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle, + ¤tHalData->internalHalData->playbacksData, + MIXER_DATA_PLAYBACKS); + if(! playbacksArray) { afb_req_fail(request, "playbacks_data", "Didn't succeed to generate playbacks data array"); return; } - if(! (capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, - ¤tCtlHalData->ctlHalSpecificData->ctlHalCapturesData, - MIXER_DATA_CAPTURES))) { + capturesArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle, + ¤tHalData->internalHalData->capturesData, + MIXER_DATA_CAPTURES); + if(! capturesArray) { afb_req_fail(request, "captures_data", "Didn't succeed to generate captures data array"); return; } - if(! (controlsArray = HalCtlsGetJsonArrayForControls(apiHandle, - currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT))) { + controlsArray = InternalHalGetJsonArrayForControls(apiHandle, + currentHalData->internalHalData->alsaMapT); + if(! controlsArray) { afb_req_fail(request, "controls_data", "Didn't succeed to generate controls data array"); return; } @@ -570,7 +588,7 @@ void HalCtlsInfo(afb_req_t request) afb_req_success(request, requestAnswer, "Requested data"); } -void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeType subscribeUnsubscribeType) +void InternalHalSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeType subscribeUnsubscribeType) { int arrayIdx, searchIdx, count, subscriptionFound, subscriptionDoneNb = 0; @@ -579,34 +597,35 @@ void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeTyp afb_api_t apiHandle; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; - struct CtlHalMixerData *currentStreamData; - struct CtlHalAlsaMapT *halAlsaMapT; + struct HalData *currentHalData; + struct InternalHalMixerData *currentStreamData; + struct InternalHalAlsaMapT *InternalHalAlsaMapT; json_object *requestJson, *requestedSubscriptionsJ, *requestedSubscriptionJ = NULL; json_type requestJsonType; if(! (apiHandle = afb_req_get_api(request))) { - afb_req_fail(request, "api_handle", "Can't get current hal controller api handle"); + afb_req_fail(request, "api_handle", "Can't get current internal hal api handle"); return; } if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) { - afb_req_fail(request, "hal_controller_config", "Can't get current hal controller config"); + afb_req_fail(request, "hal_controller_config", "Can't get current internal hal controller config"); return; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { - afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { + afb_req_fail(request, "hal_controller_data", "Can't get current internal hal controller data"); return; } - if(! currentCtlHalData->ctlHalSpecificData) { - afb_req_fail(request, "hal_controller_data", "Can't get current hal specific data"); + if(! currentHalData->internalHalData) { + afb_req_fail(request, "hal_controller_data", "Current internal hal data is not valid"); return; } - halAlsaMapT = currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT; + InternalHalAlsaMapT = currentHalData->internalHalData->alsaMapT; if(! (requestJson = afb_req_json(request))) { afb_req_fail(request, "request_json", "Can't get request json"); @@ -647,17 +666,17 @@ void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeTyp currentSubscriptionString = (char *) json_object_get_string(requestedSubscriptionJ); if(! strcasecmp(currentSubscriptionString, HAL_STREAM_UPDATES_EVENT_NAME)) { - if(currentCtlHalData->ctlHalSpecificData->streamUpdates && + if(currentHalData->internalHalData->streamUpdates && subscribeUnsubscribeType == SUBSCRIPTION && - afb_req_subscribe(request, currentCtlHalData->ctlHalSpecificData->streamUpdates)) { + afb_req_subscribe(request, currentHalData->internalHalData->streamUpdates)) { afb_req_fail_f(request, "request_stream_list_updates_event", "Error while trying to subscribe to stream list updates event"); return; } - else if(currentCtlHalData->ctlHalSpecificData->streamUpdates && + else if(currentHalData->internalHalData->streamUpdates && subscribeUnsubscribeType == UNSUBSCRIPTION && - afb_req_unsubscribe(request, currentCtlHalData->ctlHalSpecificData->streamUpdates)) { + afb_req_unsubscribe(request, currentHalData->internalHalData->streamUpdates)) { afb_req_fail_f(request, "request_stream_list_updates_event", "Error while trying to unsubscribe to stream list updates event"); @@ -668,7 +687,7 @@ void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeTyp subscriptionDoneNb++; } - currentStreamData = currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData; + currentStreamData = currentHalData->internalHalData->streamsData; while(currentStreamData && (! subscriptionFound)) { if(! strcasecmp(currentSubscriptionString, currentStreamData->verb)) { @@ -701,25 +720,25 @@ void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeTyp } searchIdx = 0; - while((searchIdx < (halAlsaMapT ? halAlsaMapT->ctlsCount : 0)) && + while((searchIdx < (InternalHalAlsaMapT ? InternalHalAlsaMapT->ctlsCount : 0)) && (! subscriptionFound)) { - if(! strcasecmp(currentSubscriptionString, halAlsaMapT->ctls[searchIdx].uid)) { - if(halAlsaMapT->ctls[searchIdx].alsaControlEvent && + if(! strcasecmp(currentSubscriptionString, InternalHalAlsaMapT->ctls[searchIdx].uid)) { + if(InternalHalAlsaMapT->ctls[searchIdx].alsaControlEvent && subscribeUnsubscribeType == SUBSCRIPTION && - afb_req_subscribe(request, halAlsaMapT->ctls[searchIdx].alsaControlEvent)) { + afb_req_subscribe(request, InternalHalAlsaMapT->ctls[searchIdx].alsaControlEvent)) { afb_req_fail_f(request, "request_control_event", "Error while trying to subscribe to %s halmap controls events", - halAlsaMapT->ctls[searchIdx].uid); + InternalHalAlsaMapT->ctls[searchIdx].uid); return; } - else if(halAlsaMapT->ctls[searchIdx].alsaControlEvent && + else if(InternalHalAlsaMapT->ctls[searchIdx].alsaControlEvent && subscribeUnsubscribeType == UNSUBSCRIPTION && - afb_req_unsubscribe(request, halAlsaMapT->ctls[searchIdx].alsaControlEvent)) { + afb_req_unsubscribe(request, InternalHalAlsaMapT->ctls[searchIdx].alsaControlEvent)) { afb_req_fail_f(request, "request_stream_event", "Error while trying to unsubscribe to %s halmap controls events", - halAlsaMapT->ctls[searchIdx].uid); + InternalHalAlsaMapT->ctls[searchIdx].uid); return; } @@ -760,12 +779,12 @@ void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeTyp count); } -void HalCtlsSubscribe(afb_req_t request) +void InternalHalSubscribe(afb_req_t request) { - HalCtlsSubscribeUnsubscribe(request, SUBSCRIPTION); + InternalHalSubscribeUnsubscribe(request, SUBSCRIPTION); } -void HalCtlsUnsubscribe(afb_req_t request) +void InternalHalUnsubscribe(afb_req_t request) { - HalCtlsSubscribeUnsubscribe(request, UNSUBSCRIPTION); -}
\ No newline at end of file + InternalHalSubscribeUnsubscribe(request, UNSUBSCRIPTION); +} diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h b/4a-hal/4a-internals-hal/4a-internals-hal-cb.h index 60e24da..ff35656 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h +++ b/4a-hal/4a-internals-hal/4a-internals-hal-cb.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _HAL_CTLS_CB_INCLUDE_ -#define _HAL_CTLS_CB_INCLUDE_ +#ifndef _INTERNALS_HAL_CB_INCLUDE_ +#define _INTERNALS_HAL_CB_INCLUDE_ #include <stdio.h> @@ -30,16 +30,16 @@ enum SubscribeUnsubscribeType { UNSUBSCRIPTION = 2 }; -// HAL controller event handler function -void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ); +// Internals HAL event handler function +void InternalHalDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ); -// HAL controllers sections parsing functions -int HalCtlsHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ); -int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *AlsaMapJ); +// Internals HAL sections parsing functions +int InternalHalHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ); +int InternalHalHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *AlsaMapJ); -// HAL controllers verbs functions -void HalCtlsInfo(afb_req_t request); -void HalCtlsSubscribe(afb_req_t request); -void HalCtlsUnsubscribe(afb_req_t request); +// Internals HAL verbs functions +void InternalHalInfo(afb_req_t request); +void InternalHalSubscribe(afb_req_t request); +void InternalHalUnsubscribe(afb_req_t request); #endif /* _HALMGR_CB_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.c index 1839261..95e9099 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c +++ b/4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.c @@ -31,14 +31,17 @@ #include "../4a-hal-manager/4a-hal-manager.h" -#include "4a-hal-controllers-mixer-link.h" -#include "4a-hal-controllers-cb.h" +#include "4a-internals-hal-mixer-link.h" +#include "4a-internals-hal-cb.h" /******************************************************************************* - * HAL controllers handle mixer calls functions * + * Internals HAL handle mixer calls functions * ******************************************************************************/ -int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **mixerDataList, json_object *currentDataJ, enum MixerDataType dataType) +int InternalHalHandleMixerData(afb_api_t apiHandle, + struct InternalHalMixerData **mixerDataList, + json_object *currentDataJ, + enum MixerDataType dataType) { int idx, mixerDataNb, verbStart, size; int err = (int) MIXER_NO_ERROR; @@ -48,7 +51,7 @@ int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **mixerDa json_type currentDataType; json_object *currentJ; - struct CtlHalMixerData *currentMixerData; + struct InternalHalMixerData *currentMixerData; currentDataType = json_object_get_type(currentDataJ); switch(currentDataType) { @@ -155,7 +158,7 @@ int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **mixerDa return err; } -int HalCtlsHandleMixerAttachResponse(afb_api_t apiHandle, struct CtlHalSpecificData *currentHalSpecificData, json_object *mixerResponseJ) +int InternalHalHandleMixerAttachResponse(afb_api_t apiHandle, struct InternalHalData *currentHalSpecificData, json_object *mixerResponseJ) { int err = (int) MIXER_NO_ERROR; @@ -171,23 +174,32 @@ int HalCtlsHandleMixerAttachResponse(afb_api_t apiHandle, struct CtlHalSpecificD return (int) MIXER_ERROR_DATA_UNAVAILABLE; } - if(mixerStreamsJ && (err += HalCtlsHandleMixerData(apiHandle, ¤tHalSpecificData->ctlHalStreamsData, mixerStreamsJ, MIXER_DATA_STREAMS))) - AFB_API_ERROR(apiHandle, "Error during handling response mixer streams data '%s'", json_object_get_string(mixerStreamsJ)); + if(mixerStreamsJ) { + err += InternalHalHandleMixerData(apiHandle, ¤tHalSpecificData->streamsData, mixerStreamsJ, MIXER_DATA_STREAMS); + if(err) + AFB_API_ERROR(apiHandle, "Error during handling response mixer streams data '%s'", json_object_get_string(mixerStreamsJ)); + } - if(mixerPlaybacksJ && (err += HalCtlsHandleMixerData(apiHandle, ¤tHalSpecificData->ctlHalPlaybacksData, mixerPlaybacksJ, MIXER_DATA_PLAYBACKS))) - AFB_API_ERROR(apiHandle, "Error during handling response mixer playbacks data '%s'", json_object_get_string(mixerPlaybacksJ)); + if(mixerPlaybacksJ) { + err += InternalHalHandleMixerData(apiHandle, ¤tHalSpecificData->playbacksData, mixerPlaybacksJ, MIXER_DATA_PLAYBACKS); + if(err) + AFB_API_ERROR(apiHandle, "Error during handling response mixer playbacks data '%s'", json_object_get_string(mixerPlaybacksJ)); + } - if(mixerCapturesJ && (err += HalCtlsHandleMixerData(apiHandle, ¤tHalSpecificData->ctlHalCapturesData, mixerCapturesJ, MIXER_DATA_CAPTURES))) - AFB_API_ERROR(apiHandle, "Error during handling response mixer captures data '%s'", json_object_get_string(mixerCapturesJ)); + if(mixerCapturesJ) { + err += InternalHalHandleMixerData(apiHandle, ¤tHalSpecificData->capturesData, mixerCapturesJ, MIXER_DATA_CAPTURES); + if(err) + AFB_API_ERROR(apiHandle, "Error during handling response mixer captures data '%s'", json_object_get_string(mixerCapturesJ)); + } - if(! currentHalSpecificData->ctlHalStreamsData) { + if(! currentHalSpecificData->streamsData) { AFB_API_WARNING(apiHandle, "No stream detected in mixer response, %s verb won't be created", HAL_ALL_STREAMS_VERB); } else if(afb_api_add_verb(apiHandle, HAL_ALL_STREAMS_VERB, "Send a stream action on all streams", HalUtlActionOnAllStream, - (void *) currentHalSpecificData->ctlHalStreamsData, + (void *) currentHalSpecificData->streamsData, NULL, 0, 0)) { @@ -198,7 +210,7 @@ int HalCtlsHandleMixerAttachResponse(afb_api_t apiHandle, struct CtlHalSpecificD return err; } -int HalCtlsAttachToMixer(afb_api_t apiHandle) +int InternalHalAttachToMixer(afb_api_t apiHandle) { int err = 0, mixerError; @@ -206,12 +218,12 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData, *concurentHalData = NULL; + struct HalData *currentHalData, *concurentHalData = NULL; json_object *responseJ = NULL; if(! apiHandle) { - AFB_API_ERROR(apiHandle, "Can't get current hal api handle"); + AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle"); return -1; } @@ -220,12 +232,13 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) return -2; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { AFB_API_ERROR(apiHandle, "Can't get current hal controller data"); return -3; } - switch(currentCtlHalData->status) { + switch(currentHalData->status) { case HAL_STATUS_UNAVAILABLE: AFB_API_ERROR(apiHandle, "Seems that the hal corresponding card was not found by alsacore at startup"); return -4; @@ -238,17 +251,18 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) break; } - concurentHalData = HalUtlSearchReadyHalDataByCardId(HalMngGetHalDataList(), currentCtlHalData->sndCardId); + concurentHalData = HalUtlSearchReadyHalDataByCardId(HalMngGetHalDataList(), currentHalData->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, - currentCtlHalData->sndCardId, + currentHalData->apiName, + currentHalData->sndCardId, concurentHalData->apiName); return -5; } - if(! (apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName)) { + apiToCall = currentHalData->internalHalData->mixerApiName; + if(! apiToCall) { AFB_API_ERROR(apiHandle, "Can't get mixer api"); return -6; } @@ -256,7 +270,7 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) if(afb_api_call_sync(apiHandle, apiToCall, MIXER_ATTACH_VERB, - json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), + json_object_get(currentHalData->internalHalData->halMixerJ), &responseJ, &returnedError, &returnedInfo)) { @@ -275,22 +289,25 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) apiToCall); err = -8; } - else if((mixerError = HalCtlsHandleMixerAttachResponse(apiHandle, currentCtlHalData->ctlHalSpecificData, responseJ)) != (int) MIXER_NO_ERROR) { - AFB_API_ERROR(apiHandle, - "Seems that %s call to api %s succeed but this warning was risen by response decoder : %i '%s'", - MIXER_ATTACH_VERB, - apiToCall, - mixerError, - json_object_get_string(responseJ)); - err = -9; - } else { - AFB_API_NOTICE(apiHandle, - "Seems that %s call to api %s succeed with no warning raised : '%s'", - MIXER_ATTACH_VERB, - apiToCall, - json_object_get_string(responseJ)); - currentCtlHalData->status = HAL_STATUS_READY; + mixerError = InternalHalHandleMixerAttachResponse(apiHandle, currentHalData->internalHalData, responseJ); + if(mixerError != (int) MIXER_NO_ERROR) { + AFB_API_ERROR(apiHandle, + "Seems that %s call to api %s succeed but this warning was risen by response decoder : %i '%s'", + MIXER_ATTACH_VERB, + apiToCall, + mixerError, + json_object_get_string(responseJ)); + err = -9; + } + else { + AFB_API_NOTICE(apiHandle, + "Seems that %s call to api %s succeed with no warning raised : '%s'", + MIXER_ATTACH_VERB, + apiToCall, + json_object_get_string(responseJ)); + currentHalData->status = HAL_STATUS_READY; + } } if(responseJ) @@ -302,12 +319,12 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle) return err; } -int HalCtlsGetInfoFromMixer(afb_api_t apiHandle, - char *apiToCall, - json_object *requestJson, - json_object **toReturnJ, - char **returnedError, - char **returnedInfo) +int InternalHalGetInfoFromMixer(afb_api_t apiHandle, + char *apiToCall, + json_object *requestJson, + json_object **toReturnJ, + char **returnedError, + char **returnedInfo) { json_object *responseJ = NULL; diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.h index 744830c..6c1f827 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h +++ b/4a-hal/4a-internals-hal/4a-internals-hal-mixer-link.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _HAL_CTLS_SOFTMIXER_LINK_INCLUDE_ -#define _HAL_CTLS_SOFTMIXER_LINK_INCLUDE_ +#ifndef _INTERNALS_HAL_SOFTMIXER_LINK_INCLUDE_ +#define _INTERNALS_HAL_SOFTMIXER_LINK_INCLUDE_ #include <stdio.h> @@ -58,13 +58,13 @@ enum MixerStatus { MIXER_ERROR_STREAM_ALLOCATION_FAILED =-10000 }; -// HAL controllers handle mixer calls functions -int HalCtlsAttachToMixer(afb_api_t apiHandle); -int HalCtlsGetInfoFromMixer(afb_api_t apiHandle, - char *apiToCall, - json_object *requestJson, - json_object **toReturnJ, - char **returnedError, - char **returnedInfo); +// Internals HAL handle mixer calls functions +int InternalHalAttachToMixer(afb_api_t apiHandle); +int InternalHalGetInfoFromMixer(afb_api_t apiHandle, + char *apiToCall, + json_object *requestJson, + json_object **toReturnJ, + char **returnedError, + char **returnedInfo); -#endif /* _HAL_CTLS_SOFTMIXER_LINK_INCLUDE_ */
\ No newline at end of file +#endif /* _INTERNALS_HAL_SOFTMIXER_LINK_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c b/4a-hal/4a-internals-hal/4a-internals-hal-value-handler.c index 4e9b56d..64083a9 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c +++ b/4a-hal/4a-internals-hal/4a-internals-hal-value-handler.c @@ -27,14 +27,14 @@ #include <afb/afb-binding.h> -#include "4a-hal-controllers-value-handler.h" -#include "4a-hal-controllers-alsacore-link.h" +#include "4a-internals-hal-value-handler.h" +#include "4a-internals-hal-alsacore-link.h" /******************************************************************************* * Simple conversion value to/from percentage functions * ******************************************************************************/ -int HalCtlsConvertValueToPercentage(double val, double min, double max) +int InternalHalConvertValueToPercentage(double val, double min, double max) { double range; @@ -47,7 +47,7 @@ int HalCtlsConvertValueToPercentage(double val, double min, double max) return (int) round(val / range * 100); } -int HalCtlsConvertPercentageToValue(int percentage, int min, int max) +int InternalHalConvertPercentageToValue(int percentage, int min, int max) { int range; @@ -62,11 +62,11 @@ int HalCtlsConvertPercentageToValue(int percentage, int min, int max) * Convert json object from percentage to value * ******************************************************************************/ -int HalCtlsConvertJsonValueForIntegerControl(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *toConvertJ, - json_object **ConvertedJ, - enum ConversionType requestedConversion) +int InternalHalConvertJsonValueForIntegerControl(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *toConvertJ, + json_object **ConvertedJ, + enum ConversionType requestedConversion) { int initialValue, convertedValue; @@ -89,10 +89,9 @@ int HalCtlsConvertJsonValueForIntegerControl(afb_api_t apiHandle, return -2; } - convertedValue = HalCtlsConvertPercentageToValue(initialValue, - alsaCtlProperties->minval, - alsaCtlProperties->maxval); - + convertedValue = InternalHalConvertPercentageToValue(initialValue, + alsaCtlProperties->minval, + alsaCtlProperties->maxval); if(convertedValue == -INT_MAX) { AFB_API_ERROR(apiHandle, "Didn't succeed to convert %i (using min %i et max %i)", @@ -110,10 +109,9 @@ int HalCtlsConvertJsonValueForIntegerControl(afb_api_t apiHandle, break; case CONVERSION_ALSACORE_TO_NORMALIZED: - convertedValue = HalCtlsConvertValueToPercentage(initialValue, - alsaCtlProperties->minval, - alsaCtlProperties->maxval); - + convertedValue = InternalHalConvertValueToPercentage(initialValue, + alsaCtlProperties->minval, + alsaCtlProperties->maxval); if(convertedValue == -INT_MAX) { AFB_API_ERROR(apiHandle, "Didn't succeed to convert %i (using min %i et max %i)", @@ -139,11 +137,11 @@ int HalCtlsConvertJsonValueForIntegerControl(afb_api_t apiHandle, return 0; } -int HalCtlsConvertJsonValueForBooleanControl(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *toConvertJ, - json_object **ConvertedJ, - enum ConversionType requestedConversion) +int InternalHalConvertJsonValueForBooleanControl(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *toConvertJ, + json_object **ConvertedJ, + enum ConversionType requestedConversion) { int initialValue; @@ -192,11 +190,11 @@ int HalCtlsConvertJsonValueForBooleanControl(afb_api_t apiHandle, return 0; } -int HalCtlsConvertJsonValues(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *toConvertJ, - json_object **ConvertedJ, - enum ConversionType requestedConversion) +int InternalHalConvertJsonValues(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *toConvertJ, + json_object **ConvertedJ, + enum ConversionType requestedConversion) { int conversionError = 0, idx, count; @@ -219,11 +217,12 @@ int HalCtlsConvertJsonValues(afb_api_t apiHandle, switch(alsaCtlProperties->type) { case SND_CTL_ELEM_TYPE_INTEGER: case SND_CTL_ELEM_TYPE_INTEGER64: - if((conversionError = HalCtlsConvertJsonValueForIntegerControl(apiHandle, + conversionError = InternalHalConvertJsonValueForIntegerControl(apiHandle, alsaCtlProperties, toConvertObjectJ, &convertedValueJ, - requestedConversion))) { + requestedConversion); + if(conversionError) { AFB_API_ERROR(apiHandle, "Error %i happened in when trying to convert index %i for integer control ('%s')", conversionError, @@ -235,11 +234,12 @@ int HalCtlsConvertJsonValues(afb_api_t apiHandle, break; case SND_CTL_ELEM_TYPE_BOOLEAN: - if((conversionError = HalCtlsConvertJsonValueForBooleanControl(apiHandle, + conversionError = InternalHalConvertJsonValueForBooleanControl(apiHandle, alsaCtlProperties, toConvertObjectJ, &convertedValueJ, - requestedConversion))) { + requestedConversion); + if(conversionError) { AFB_API_ERROR(apiHandle, "Error %i happened in when trying to convert index %i for boolean control ('%s')", conversionError, @@ -266,11 +266,11 @@ int HalCtlsConvertJsonValues(afb_api_t apiHandle, return 0; } -int HalCtlsChangePreviousValuesUsingJson(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *requestedPercentageVariationJ, - json_object *previousControlValuesJ, - json_object **ChangedJ) +int InternalHalChangePreviousValuesUsingJson(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *requestedPercentageVariationJ, + json_object *previousControlValuesJ, + json_object **ChangedJ) { int requestedPercentageVariation, requestedVariation, toChangeValue, changedValue, idx, count; @@ -307,10 +307,9 @@ int HalCtlsChangePreviousValuesUsingJson(afb_api_t apiHandle, return -3; } - requestedVariation = HalCtlsConvertPercentageToValue((int) abs(requestedPercentageVariation), - alsaCtlProperties->minval, - alsaCtlProperties->maxval); - + requestedVariation = InternalHalConvertPercentageToValue((int) abs(requestedPercentageVariation), + alsaCtlProperties->minval, + alsaCtlProperties->maxval); if(requestedVariation == -INT_MAX) { AFB_API_ERROR(apiHandle, "Didn't succeed to convert %i (using min %i et max %i)", diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h b/4a-hal/4a-internals-hal/4a-internals-hal-value-handler.h index 03b47e7..f0288ac 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h +++ b/4a-hal/4a-internals-hal/4a-internals-hal-value-handler.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _HAL_CTLS_VALUE_CONVERSION_INCLUDE_ -#define _HAL_CTLS_VALUE_CONVERSION_INCLUDE_ +#ifndef _INTERNALS_HAL_VALUE_CONVERSION_INCLUDE_ +#define _INTERNALS_HAL_VALUE_CONVERSION_INCLUDE_ #include <stdio.h> @@ -24,7 +24,7 @@ #include <afb/afb-binding.h> -#include "4a-hal-controllers-alsacore-link.h" +#include "4a-internals-hal-alsacore-link.h" // Enum for the type of conversion requested enum ConversionType { @@ -33,21 +33,21 @@ enum ConversionType { }; // Simple conversion value to/from percentage functions -int HalCtlsConvertValueToPercentage(double val, double min, double max); -int HalCtlsConvertPercentageToValue(int percentage, int min, int max); +int InternalHalConvertValueToPercentage(double val, double min, double max); +int InternalHalConvertPercentageToValue(int percentage, int min, int max); // Convert json object from percentage to value -int HalCtlsConvertJsonValues(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *toConvertJ, - json_object **ConvertedJ, - enum ConversionType requestedConversion); +int InternalHalConvertJsonValues(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *toConvertJ, + json_object **ConvertedJ, + enum ConversionType requestedConversion); // Increase/Decrease previous values using percentage passed in Json -int HalCtlsChangePreviousValuesUsingJson(afb_api_t apiHandle, - struct CtlHalAlsaCtlProperties *alsaCtlProperties, - json_object *requestedPercentageVariationJ, - json_object *previousControlValuesJ, - json_object **ChangedJ); +int InternalHalChangePreviousValuesUsingJson(afb_api_t apiHandle, + struct InternalHalAlsaCtlProperties *alsaCtlProperties, + json_object *requestedPercentageVariationJ, + json_object *previousControlValuesJ, + json_object **ChangedJ); -#endif /* _HAL_CTLS_VALUE_CONVERSION_INCLUDE_ */
\ No newline at end of file +#endif /* _INTERNALS_HAL_VALUE_CONVERSION_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/CMakeLists.txt b/4a-hal/CMakeLists.txt index 0c722c5..b863c5f 100644 --- a/4a-hal/CMakeLists.txt +++ b/4a-hal/CMakeLists.txt @@ -23,13 +23,13 @@ PROJECT_TARGET_ADD(4a-hal) # Define project Targets add_library(${TARGET_NAME} MODULE - ${TARGET_NAME}-manager/${TARGET_NAME}-manager.c - ${TARGET_NAME}-manager/${TARGET_NAME}-manager-cb.c - ${TARGET_NAME}-controllers/${TARGET_NAME}-controllers-alsacore-link.c - ${TARGET_NAME}-controllers/${TARGET_NAME}-controllers-api-loader.c - ${TARGET_NAME}-controllers/${TARGET_NAME}-controllers-cb.c - ${TARGET_NAME}-controllers/${TARGET_NAME}-controllers-mixer-link.c - ${TARGET_NAME}-controllers/${TARGET_NAME}-controllers-value-handler.c + 4a-hal-manager/4a-hal-manager.c + 4a-hal-manager/4a-hal-manager-cb.c + 4a-internals-hal/4a-internals-hal-alsacore-link.c + 4a-internals-hal/4a-internals-hal-api-loader.c + 4a-internals-hal/4a-internals-hal-cb.c + 4a-internals-hal/4a-internals-hal-mixer-link.c + 4a-internals-hal/4a-internals-hal-value-handler.c ) # Binder exposes a unique public entry point diff --git a/plugins/lib/bluealsa/hal-bluealsa.c b/plugins/lib/bluealsa/hal-bluealsa.c index 415b160..58c4b54 100644 --- a/plugins/lib/bluealsa/hal-bluealsa.c +++ b/plugins/lib/bluealsa/hal-bluealsa.c @@ -68,15 +68,16 @@ CTLP_INIT(plugin, callbacks) { json_object *actionsToAdd = NULL; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentHalData; + struct HalData *currentHalData; if (!(ctrlConfig = (CtlConfigT *) afb_api_get_userdata(plugin->api))) { - AFB_API_ERROR(plugin->api, "Can't get current hal controller config"); + AFB_API_ERROR(plugin->api, "Can't get current internal hal controller config"); goto fail; } - if (!(currentHalData = (struct SpecificHalData *) ctrlConfig->external)) { - AFB_API_ERROR(plugin->api, "Can't get current hal controller data"); + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if (!currentHalData) { + AFB_API_ERROR(plugin->api, "Can't get current internal hal controller data"); goto fail; } |