diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-17 11:23:28 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-10-17 11:25:55 +0200 |
commit | 47b281c130bf6ff9f4f744c56c78e3ab983e0751 (patch) | |
tree | 6f1ec3421194d5c17d0c85dbdf0ae54cfbabd908 | |
parent | 6236c29b391fda6454aaf8083a24552370f5e62f (diff) |
Prevent binder exit when hal initialization fails
No longer returns an error in hal api initialization function
when an non-blocking error happens (e.g. card-sound not found).
This will prevent application framework binder exit.
BUG-AGL: SPEC-2906
Change-Id: I0ef5e5f624fc0021771f40f37ce5663510a7e03e
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.h | 7 | ||||
-rw-r--r-- | src/4a-hal-manager/4a-hal-manager.c | 5 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-api-loader.c | 2 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-mixer-link.c | 14 |
4 files changed, 17 insertions, 11 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h index 5b25f58..a2b28dd 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.h +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h @@ -42,9 +42,10 @@ enum LinkedListType { // Enum for hal status enum HalStatus { - HAL_STATUS_UNAVAILABLE = 0, - HAL_STATUS_AVAILABLE = 1, - HAL_STATUS_READY = 2 + HAL_STATUS_INIT_FAILED = 0, + HAL_STATUS_UNAVAILABLE = 1, + HAL_STATUS_AVAILABLE = 2, + HAL_STATUS_READY = 3 }; // Enum for probed devices (dependencies) class diff --git a/src/4a-hal-manager/4a-hal-manager.c b/src/4a-hal-manager/4a-hal-manager.c index d08d83f..da33db8 100644 --- a/src/4a-hal-manager/4a-hal-manager.c +++ b/src/4a-hal-manager/4a-hal-manager.c @@ -76,9 +76,10 @@ static int HalMgrInitApi(afb_api_t apiHandle) if(! currentHalData->apiName) return -4; - if(afb_api_require_api(apiHandle, currentHalData->apiName, 1)) { + if(afb_api_require_api(apiHandle, currentHalData->apiName, 1) || + currentHalData->status == HAL_STATUS_INIT_FAILED) { AFB_API_ERROR(apiHandle, - "Error caught during '%s' api require, this api won't be reachable", + "Error caught during '%s' api initialization, this api won't be reachable", currentHalData->apiName); toDeleteApiName = strdup(currentHalData->apiName); diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c index ca53e01..5334bdf 100644 --- a/src/4a-internals-hal/4a-internals-hal-api-loader.c +++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c @@ -114,7 +114,7 @@ static int InternalHalInitOneApi(afb_api_t apiHandle) err = CtlConfigExec(apiHandle, ctrlConfig); if(err < 0) { AFB_API_ERROR(apiHandle, "Error %i caught when trying to apply current internal hal controller sections", err); - return -5; + currentHalData->status = HAL_STATUS_INIT_FAILED; } if(err > 0) 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 f69be5a..56dc840 100644 --- a/src/4a-internals-hal/4a-internals-hal-mixer-link.c +++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.c @@ -172,9 +172,13 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) } switch(currentHalData->status) { + case HAL_STATUS_INIT_FAILED: + AFB_API_ERROR(apiHandle, "Seems that the hal initialization failed, will not be able to attach this hal"); + return -4; + case HAL_STATUS_UNAVAILABLE: AFB_API_ERROR(apiHandle, "Seems that the hal corresponding card was not found by alsacore at startup"); - return -4; + return -5; case HAL_STATUS_READY: AFB_API_NOTICE(apiHandle, "Seems that the hal mixer is already initialized"); @@ -187,7 +191,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { AFB_API_ERROR(apiHandle, "Can't get mixer api"); - return -5; + return -6; } dependencyJ = HalUtlGetJsonArrayForAllDependencies(apiHandle, @@ -195,7 +199,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) DEPENDENCY_COMPACT_JSON); if(! dependencyJ) { AFB_API_ERROR(apiHandle, "Didn't succeed to generate available dependencies compact json array"); - return -6; + return -7; } requestJ = wrap_json_clone(currentHalData->internalHalData->halMixerJ); @@ -214,7 +218,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) apiToCall, returnedError ? returnedError : "not returned", returnedInfo ? returnedInfo : "not returned"); - err = -7; + err = -8; } else if(! responseJ) { AFB_API_WARNING(apiHandle, @@ -231,7 +235,7 @@ int InternalHalAttachToMixer(afb_api_t apiHandle) apiToCall, mixerError, json_object_get_string(responseJ)); - err = -8; + err = -9; } else if(mixerError > 0) { AFB_API_WARNING(apiHandle, |