diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-04-18 16:35:27 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-05-24 16:33:30 +0200 |
commit | fcb21344181cd6d487bb59a7e8065a7068a887fd (patch) | |
tree | 933f7ab1de7de1858b5c4b826c8109917bc9d7a2 | |
parent | 147e1222379a6ee5b7434a014f51ff6657b6ed3e (diff) |
Remove use of a global variable for hal-manager
Remove use of a global variable for hal-manager data.
BUG-AGL: SPEC-2329
Change-Id: Ifc5a85aedb75f89a364de1411c1e12f293095550
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r-- | src/4a-hal-manager/4a-hal-manager.c | 22 | ||||
-rw-r--r-- | src/4a-hal-manager/4a-hal-manager.h | 3 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-mixer-link.c | 22 |
3 files changed, 12 insertions, 35 deletions
diff --git a/src/4a-hal-manager/4a-hal-manager.c b/src/4a-hal-manager/4a-hal-manager.c index 567e9eb..ce1aed5 100644 --- a/src/4a-hal-manager/4a-hal-manager.c +++ b/src/4a-hal-manager/4a-hal-manager.c @@ -32,9 +32,6 @@ // Default api to print log when apihandle not available afb_api_t AFB_default; -// Local (static) Hal manager data structure -static struct HalMgrData localHalMgrGlobalData; - /******************************************************************************* * HAL Manager verbs table * ******************************************************************************/ @@ -53,16 +50,6 @@ afb_verb_t HalManagerApiStaticVerbs[] = }; /******************************************************************************* - * HAL Manager get 'HalData' linked list * - from HAL list function * - ******************************************************************************/ - -struct HalData **HalMngGetHalDataList(void) -{ - return &localHalMgrGlobalData.halDataList; -} - -/******************************************************************************* * Dynamic API functions for hal manager * ******************************************************************************/ @@ -142,6 +129,7 @@ int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) int afbBindingEntry(afb_api_t apiHandle) { + struct HalMgrData *halMgrData; if(! apiHandle) return -1; @@ -151,12 +139,16 @@ int afbBindingEntry(afb_api_t apiHandle) AFB_API_NOTICE(apiHandle, "Binding start"); + halMgrData = (struct HalMgrData *) calloc(1, sizeof(struct HalMgrData)); + if(! halMgrData) + return -2; + // Load Hal-Manager using Api v3 - if(HalMgrCreateApi(apiHandle, &localHalMgrGlobalData)) + if(HalMgrCreateApi(apiHandle, halMgrData)) return -3; // Load internals Hal using Api v3 - if(InternalHalCreateAllApi(apiHandle, &localHalMgrGlobalData)) + if(InternalHalCreateAllApi(apiHandle, halMgrData)) return -4; return 0; diff --git a/src/4a-hal-manager/4a-hal-manager.h b/src/4a-hal-manager/4a-hal-manager.h index 4a53bdd..d5f11e5 100644 --- a/src/4a-hal-manager/4a-hal-manager.h +++ b/src/4a-hal-manager/4a-hal-manager.h @@ -23,7 +23,4 @@ #define HAL_MANAGER_API_NAME "4a-hal-manager" #define HAL_MANAGER_API_INFO "Manager for 4A HAL APIs" -// HAL Manager get 'HalData' linked list -struct HalData **HalMngGetHalDataList(void); - #endif /* _HALMGR_BINDING_INCLUDE_ */
\ No newline at end of file diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.c b/src/4a-internals-hal/4a-internals-hal-mixer-link.c index 3183081..553d58e 100644 --- a/src/4a-internals-hal/4a-internals-hal-mixer-link.c +++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.c @@ -28,8 +28,6 @@ #include "4a-hal-utilities-hal-streams-handler.h" -#include "../4a-hal-manager/4a-hal-manager.h" - #include "4a-internals-hal-mixer-link.h" #include "4a-internals-hal-cb.h" @@ -222,7 +220,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) CtlConfigT *ctrlConfig; - struct HalData *currentHalData, *concurentHalData = NULL; + struct HalData *currentHalData; json_object *responseJ = NULL; @@ -256,20 +254,10 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) break; } - 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'", - currentHalData->apiName, - currentHalData->sndCardId, - concurentHalData->apiName); - return -5; - } - apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { AFB_API_ERROR(apiHandle, "Can't get mixer api"); - return -6; + return -5; } if(afb_api_call_sync(apiHandle, @@ -285,14 +273,14 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) apiToCall, returnedError ? returnedError : "not returned", returnedInfo ? returnedInfo : "not returned"); - err = -7; + err = -6; } else if(! responseJ) { AFB_API_ERROR(apiHandle, "Seems that %s call to api %s succeed but no response was returned", MIXER_ATTACH_VERB, apiToCall); - err = -8; + err = -7; } else { mixerError = InternalHalHandleMixerAttachResponse(apiHandle, currentHalData->internalHalData, responseJ); @@ -303,7 +291,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) apiToCall, mixerError, json_object_get_string(responseJ)); - err = -9; + err = -8; } else { AFB_API_NOTICE(apiHandle, |