diff options
Diffstat (limited to '4a-hal')
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c | 12 | ||||
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.h | 10 |
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", ¤tStreamName)) { 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", ¤tStreamCardId)) { 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); |