diff options
Diffstat (limited to 'lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c')
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c index 550faaa..c38bfdd 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c @@ -43,7 +43,7 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) struct HalData *currentHalData; struct InternalHalMixerData *currentMixerData = NULL; - json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL; + json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL, *verboseBooleanJ; apiHandle = afb_req_get_api(request); if(! apiHandle) { @@ -69,8 +69,17 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) return; } - if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) - json_object_object_add(requestJson, "verbose", json_object_new_boolean(1)); + if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) { + verboseBooleanJ = json_object_new_boolean(1); + if(! verboseBooleanJ) { + afb_req_fail(request, + "verbose_boolean_allocation", + "Didn't succeed to allocate verbose value json boolean"); + return; + } + + json_object_object_add(requestJson, "verbose", verboseBooleanJ); + } apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { @@ -99,6 +108,12 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) case ACTION_ON_MIXER_ALL_STREAM: count = (int) HalUtlGetNumberOfMixerDataInList(¤tMixerData); toReturnJ = json_object_new_object(); + if(! toReturnJ) { + afb_req_fail(request, + "response_json_object", + "Didn't succeed to allocate response json object"); + return; + } break; default: @@ -237,6 +252,8 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap char *verbToCall, char *streamCardId) { + int wrapRet; + json_object *streamAddedEventJ; CtlConfigT *ctrlConfig; @@ -290,11 +307,16 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap return NULL; } - wrap_json_pack(&streamAddedEventJ, - "{s:s, s:s, s:s}", - "action", "added", - "name", createdStreamData->verb, - "cardId", createdStreamData->streamCardId); + wrapRet = wrap_json_pack(&streamAddedEventJ, + "{s:s, s:s, s:s}", + "action", "added", + "name", createdStreamData->verb, + "cardId", createdStreamData->streamCardId); + if(wrapRet) { + AFB_API_ERROR(apiHandle,"Didn't succeed to allocate added stream event json object"); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); + return NULL; + } afb_event_push(currentHalData->internalHalData->streamUpdates, streamAddedEventJ); @@ -306,7 +328,7 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, char *verbToCall, char *streamCardId) { - int returnedErr = 0; + int returnedErr = 0, wrapRet; json_object *streamRemovedEventJ; @@ -334,12 +356,6 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, if(! toRemoveStreamData) return -4; - wrap_json_pack(&streamRemovedEventJ, - "{s:s, s:s, s:s}", - "action", "removed", - "name", toRemoveStreamData->verb, - "cardId", toRemoveStreamData->streamCardId); - if(afb_api_del_verb(apiHandle, verb, NULL)) { AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb); json_object_put(streamRemovedEventJ); @@ -353,6 +369,16 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, return -6; } + wrapRet = wrap_json_pack(&streamRemovedEventJ, + "{s:s, s:s, s:s}", + "action", "removed", + "name", toRemoveStreamData->verb, + "cardId", toRemoveStreamData->streamCardId); + if(wrapRet) { + AFB_API_ERROR(apiHandle,"Didn't succeed to allocate removed stream event json object"); + return -7; + } + afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ); return 0; |