summaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c')
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
index 9f23787..3f30436 100644
--- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -25,7 +25,6 @@
#include <ctl-config.h>
#include "4a-hal-utilities-data.h"
-#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-utilities-hal-streams-handler.h"
/*******************************************************************************
@@ -36,7 +35,7 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
{
int idx, count;
- char *apiToCall;
+ char *apiToCall, *returnedError = NULL, *returnedInfo = NULL;
afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
@@ -44,7 +43,7 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
struct SpecificHalData *currentCtlHalData;
struct CtlHalMixerData *currentMixerData = NULL;
- json_object *requestJson, *returnJ = NULL, *responseJ, *toReturnJ = NULL;
+ json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL;
if(! (apiHandle = afb_req_get_api(request))) {
afb_req_fail(request, "api_handle", "Can't get current hal controller api handle");
@@ -98,32 +97,48 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
break;
default:
- afb_req_fail(request, "hal_call_data", "Can't get current call data");
+ afb_req_fail(request, "mixer_action_type", "Action type is unknown");
return;
}
for(idx = 0; idx < count; idx++) {
- if(afb_api_call_sync_legacy(apiHandle,
- apiToCall,
- currentMixerData->verbToCall,
- json_object_get(requestJson),
- &returnJ)) {
- HalUtlHandleAppFwCallErrorInRequest(request, apiToCall, currentMixerData->verbToCall, returnJ, "call_action");
- json_object_put(returnJ);
+ if(afb_api_call_sync(apiHandle,
+ apiToCall,
+ currentMixerData->verbToCall,
+ json_object_get(requestJson),
+ &responseJ,
+ &returnedError,
+ &returnedInfo)) {
+ if(responseJ)
+ json_object_put(responseJ);
if(toReturnJ)
json_object_put(toReturnJ);
+ afb_req_fail_f(request,
+ "mixer_call",
+ "Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s' (call to mixer %i out of %i)",
+ currentMixerData->verbToCall,
+ apiToCall,
+ returnedError ? returnedError : "not returned",
+ returnedInfo ? returnedInfo : "not returned",
+ idx,
+ count);
+ free(returnedError);
+ free(returnedInfo);
return;
}
- if(wrap_json_unpack(returnJ, "{s:o}", "response", &responseJ)) {
+ if(! responseJ) {
+ if(toReturnJ)
+ json_object_put(toReturnJ);
afb_req_fail_f(request,
- "Seems that %s call to api %s succeed, but no response was found in : '%s'",
+ "mixer_call",
+ "Seems that %s call to api %s succeed but no response was returned (call to mixer %i out of %i)",
currentMixerData->verbToCall,
apiToCall,
- json_object_get_string(returnJ));
- json_object_put(returnJ);
- if(toReturnJ)
- json_object_put(toReturnJ);
+ idx,
+ count);
+ free(returnedError);
+ free(returnedInfo);
return;
}
@@ -137,28 +152,17 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
switch(actionType) {
case ACTION_ON_MIXER_STREAM:
- toReturnJ = json_object_get(responseJ);
+ toReturnJ = responseJ;
break;
case ACTION_ON_MIXER_PLAYBACK:
case ACTION_ON_MIXER_CAPTURE:
- json_object_object_add(toReturnJ, currentMixerData->verbToCall, json_object_get(responseJ));
- break;
-
- case ACTION_ON_MIXER_ALL_STREAM:
- json_object_object_add(toReturnJ, currentMixerData->verb, json_object_get(responseJ));
- break;
-
- default:
+ json_object_object_add(toReturnJ, currentMixerData->verbToCall, responseJ);
+ currentMixerData = currentMixerData->next;
break;
- }
- json_object_put(returnJ);
-
- switch(actionType) {
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
case ACTION_ON_MIXER_ALL_STREAM:
+ json_object_object_add(toReturnJ, currentMixerData->verb, responseJ);
currentMixerData = currentMixerData->next;
break;