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/4a-hal-controllers-cb.c | |
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/4a-hal-controllers-cb.c')
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c | 21 |
1 files changed, 14 insertions, 7 deletions
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; } |