summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-03 19:16:32 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:51:00 +0200
commit67fc2c25d727888cb45a847971771f34674b68ff (patch)
tree4fab47f096de6a897f8f33028ad8072d7bd07815 /4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
parent70108117e5f392eff2710d5d6a0cd04e400e4cde (diff)
Handle hal status using card presence and mixer init
Test audio card presence at hal startup using alsacore call. Handling a new state of hal. Move alsacore link files into 4a-hal-controllers. Check state of hal before mixer initialization call. Actualize hal state if mixer initlialization ends well. Add a sndCardId filed to 'SpecificHalData' structure which will contain audio card if (from alsa). Change-Id: I2e82a14ee6ba6e63f06fe2b498587783941b7b98 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.c21
1 files changed, 19 insertions, 2 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 b37000d..2d0f400 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -28,6 +28,7 @@
#include "4a-hal-controllers-cb.h"
#include "4a-hal-controllers-mixer-handler.h"
+#include "4a-hal-controllers-alsacore-link.h"
/*******************************************************************************
* HAL controllers sections parsing functions *
@@ -126,7 +127,10 @@ void HalCtlsActionOnStream(afb_request *request)
return;
}
- // TODO JAI: check status of hal before doing anything
+ if(currentCtlHalData->status != HAL_STATUS_AVAILABLE) {
+ afb_request_fail(request, "hal_unavailable", "Seems that hal is not available");
+ return;
+ }
// TODO JAI : remove verb to call prefix, each hal should have its own api in softmixer, and each streams should be created as verb by mixer
verbToCallSize = (int) strlen(mixerVerbName) + (int) strlen(request->verb) + 2;
@@ -251,7 +255,18 @@ void HalCtlsInitMixer(afb_request *request)
return;
}
- // TODO JAI: test hal status (card is detected)
+ switch(currentCtlHalData->status) {
+ case HAL_STATUS_UNAVAILABLE:
+ afb_request_fail(request, "hal_unavailable", "Seems that the hal corresponding card was not found by alsacore at startup");
+ return;
+
+ case HAL_STATUS_READY:
+ afb_request_success(request, NULL, "Seems that the hal mixer is already initialized");
+ return;
+
+ case HAL_STATUS_AVAILABLE:
+ break;
+ }
if(afb_dynapi_call_sync(apiHandle, apiToCall, "create", json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), &returnJ)) {
HalUtlHandleAppFwCallErrorInRequest(request, apiToCall, "create", returnJ, "mixer_create");
@@ -271,6 +286,8 @@ void HalCtlsInitMixer(afb_request *request)
toReturnJ,
"Seems that create call to api %s succeed with no warning raised",
apiToCall);
+
+ currentCtlHalData->status = HAL_STATUS_READY;
}
else {
afb_request_fail_f(request,