summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-03 19:07:26 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:51:00 +0200
commit8bbaffadc1a5bcfc9b14174793f034565baecb52 (patch)
treee81c16bb3d37307e34951782dabac742da39079f /4a-hal/4a-hal-controllers
parent6629b727ca8554e7f27891af91d315addc532b47 (diff)
Use error codes when handling mixer init response
Use error codes when handling mixer initialization response. Change-Id: Ie62b022f1a653be18766a09f1803995a77ae8582 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-mixer-handler.c12
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h10
2 files changed, 16 insertions, 6 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c
index fa5ca4e..789913d 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c
@@ -32,7 +32,7 @@
int HalCtlsHandleMixerAttachResponse(AFB_ReqT request, struct CtlHalStreamsDataT *currentHalStreamsData, json_object *mixerResponseJ)
{
- int err = 0;
+ int err = (int) MIXER_NO_ERROR;
unsigned int idx;
char *currentStreamName, *currentStreamCardId;
@@ -46,7 +46,7 @@ int HalCtlsHandleMixerAttachResponse(AFB_ReqT request, struct CtlHalStreamsDataT
apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
if(! apiHandle) {
AFB_REQUEST_WARNING(request, "%s: Can't get current hal api handle", __func__);
- return -1;
+ return (int) MIXER_ERROR_API_UNAVAILABLE;
}
switch(json_object_get_type(mixerResponseJ)) {
@@ -59,7 +59,7 @@ int HalCtlsHandleMixerAttachResponse(AFB_ReqT request, struct CtlHalStreamsDataT
default:
currentHalStreamsData->count = 0;
AFB_REQUEST_WARNING(request, "%s: no streams returned", __func__);
- return -2;
+ return (int) MIXER_ERROR_NO_STREAMS;
}
currentHalStreamsData->data = (struct CtlHalStreamData *) calloc(currentHalStreamsData->count, sizeof(struct CtlHalStreamData));
@@ -76,11 +76,11 @@ int HalCtlsHandleMixerAttachResponse(AFB_ReqT request, struct CtlHalStreamsDataT
if(wrap_json_unpack(currentStreamJ, "{s:s}", "uid", &currentStreamName)) {
AFB_REQUEST_WARNING(request, "%s: can't find name in current stream object", __func__);
- err -= 10;
+ err += (int) MIXER_ERROR_STREAM_NAME_UNAVAILABLE;
}
else if(wrap_json_unpack(currentStreamJ, "{s:s}", "alsa", &currentStreamCardId)) {
AFB_REQUEST_WARNING(request, "%s: can't find card id in current stream object", __func__);
- err -= 1000;
+ err += (int) MIXER_ERROR_STREAM_CARDID_UNAVAILABLE;
}
else {
currentHalStreamsData->data[idx].name = strdup(currentStreamName);
@@ -94,7 +94,7 @@ int HalCtlsHandleMixerAttachResponse(AFB_ReqT request, struct CtlHalStreamsDataT
if(HalUtlLoadVerbs(apiHandle, CtlHalDynApiStreamVerbs)) {
AFB_REQUEST_WARNING(request, "%s: error while creating verbs for streams", __func__);
- err -= 100000;
+ err += (int) MIXER_ERROR_COULDNT_ADD_STREAMS_AS_VERB;
}
return err;
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h
index f06b649..b9c0ecd 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h
@@ -24,6 +24,16 @@
#include "../4a-hal-utilities/4a-hal-utilities-data.h"
+// Enum for the type of error detected
+enum MixerStatus {
+ MIXER_NO_ERROR=0,
+ MIXER_ERROR_API_UNAVAILABLE=-1,
+ MIXER_ERROR_NO_STREAMS=-2,
+ MIXER_ERROR_STREAM_NAME_UNAVAILABLE=-10,
+ MIXER_ERROR_STREAM_CARDID_UNAVAILABLE=-1000,
+ MIXER_ERROR_COULDNT_ADD_STREAMS_AS_VERB =-100000,
+};
+
// HAL controllers handle mixer response function
int HalCtlsHandleMixerAttachResponse(afb_request *request, struct CtlHalStreamsDataT *currentHalStreamsData, json_object *MixerResponseJ);