diff options
-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; } |