From b45add1e046f562ff3d6260356774efe0296d879 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Mon, 17 Sep 2018 15:19:19 +0200 Subject: 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 --- 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c') 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; } -- cgit 1.2.3-korg