diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-09-17 15:19:19 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-10-08 15:57:27 +0200 |
commit | b45add1e046f562ff3d6260356774efe0296d879 (patch) | |
tree | 23c05978409262b4ba5e067fa3240caf848871bb /4a-hal/4a-hal-controllers | |
parent | daff7a6ee4900e54dee42f5528a32ef50bd5bcab (diff) |
Move mixer attach into its controller section
As the mixer section is obtained during a call of a controller section
callback (during api pre-initilization), 'attach' call to 'mixer'
has been moved in the same callback (called a second time during
api initialization).
Change-Id: I17f54aab1b9616649bfcb183297ba8128621a7c2
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers')
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c | 12 | ||||
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c | 21 |
2 files changed, 16 insertions, 17 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c index a5d9c7a..92eed86 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c @@ -72,8 +72,6 @@ static AFB_ApiVerbs CtlHalDynApiStaticVerbs[] = static int HalCtlsInitOneApi(AFB_ApiT apiHandle) { - int err; - CtlConfigT *ctrlConfig; struct SpecificHalData *currentCtlHalData; @@ -109,16 +107,10 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle) currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath); - if(currentCtlHalData->sndCardId < 0) { + if(currentCtlHalData->sndCardId < 0) currentCtlHalData->status = HAL_STATUS_UNAVAILABLE; - } - else { + else currentCtlHalData->status = HAL_STATUS_AVAILABLE; - if((err = HalCtlsAttachToMixer(apiHandle))) { - AFB_ApiError(apiHandle, "Error %i while attaching to mixer", err); - return -4; - } - } // TBD JAI: handle refresh of hal status for dynamic card (/dev/by-id) diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c index 54d06e3..22783d5 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c @@ -116,21 +116,23 @@ void HalCtlsDispatchApiEvent(afb_dynapi *apiHandle, const char *evtLabel, json_o int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *MixerJ) { + int err = 0; + CtlConfigT *ctrlConfig; struct SpecificHalData *currentHalData; if(! apiHandle || ! section) return -1; - if(MixerJ) { - ctrlConfig = (CtlConfigT *) afb_dynapi_get_userdata(apiHandle); - if(! ctrlConfig) - return -2; + ctrlConfig = (CtlConfigT *) afb_dynapi_get_userdata(apiHandle); + if(! ctrlConfig) + return -2; - currentHalData = (struct SpecificHalData *) ctrlConfig->external; - if(! currentHalData) - return -3; + currentHalData = (struct SpecificHalData *) ctrlConfig->external; + if(! currentHalData) + return -3; + if(MixerJ) { if(json_object_is_type(MixerJ, json_type_object)) currentHalData->ctlHalSpecificData->halMixerJ = MixerJ; else @@ -141,6 +143,11 @@ int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object wrap_json_unpack(MixerJ, "{s?:s}", "prefix", ¤tHalData->ctlHalSpecificData->prefix); } + else if(currentHalData->status == HAL_STATUS_AVAILABLE && + (err = HalCtlsAttachToMixer(apiHandle))) { + AFB_ApiError(apiHandle, "%s: Error %i while attaching to mixer", __func__, err); + return -6; + } return 0; } |