summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c92
1 files changed, 51 insertions, 41 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
index 1574f83..2bd85be 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
@@ -24,7 +24,6 @@
#include <afb/afb-binding.h>
-#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-hal-streams-handler.h"
@@ -203,16 +202,14 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle)
{
int err = 0, mixerError;
- char *apiToCall, *returnedStatus = NULL, *returnedInfo = NULL;
-
- enum CallError returnedError;
+ char *apiToCall, *returnedError = NULL, *returnedInfo = NULL;
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData, *concurentHalData = NULL;
struct SpecificHalData **firstHalData;
- json_object *returnJ = NULL, *toReturnJ;
+ json_object *responseJ = NULL;
if(! apiHandle) {
AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
@@ -257,32 +254,35 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle)
return -6;
}
- if(afb_api_call_sync_legacy(apiHandle, apiToCall, MIXER_ATTACH_VERB, json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), &returnJ)) {
- returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_ATTACH_VERB, returnJ, &returnedStatus, &returnedInfo);
+ if(afb_api_call_sync(apiHandle,
+ apiToCall,
+ MIXER_ATTACH_VERB,
+ json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ),
+ &responseJ,
+ &returnedError,
+ &returnedInfo)) {
AFB_API_ERROR(apiHandle,
- "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
- (int) returnedError,
+ "Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s'",
MIXER_ATTACH_VERB,
apiToCall,
- returnedStatus ? returnedStatus : "not returned",
+ returnedError ? returnedError : "not returned",
returnedInfo ? returnedInfo : "not returned");
err = -7;
}
- else if(! json_object_object_get_ex(returnJ, "response", &toReturnJ)) {
+ else if(! responseJ) {
AFB_API_ERROR(apiHandle,
- "Seems that %s call to api %s succeed, but response is not valid : '%s'",
+ "Seems that %s call to api %s succeed but no response was returned",
MIXER_ATTACH_VERB,
- apiToCall,
- json_object_get_string(returnJ));
+ apiToCall);
err = -8;
}
- else if((mixerError = HalCtlsHandleMixerAttachResponse(apiHandle, currentCtlHalData->ctlHalSpecificData, toReturnJ)) != (int) MIXER_NO_ERROR) {
+ else if((mixerError = HalCtlsHandleMixerAttachResponse(apiHandle, currentCtlHalData->ctlHalSpecificData, responseJ)) != (int) MIXER_NO_ERROR) {
AFB_API_ERROR(apiHandle,
"Seems that %s call to api %s succeed but this warning was risen by response decoder : %i '%s'",
MIXER_ATTACH_VERB,
apiToCall,
mixerError,
- json_object_get_string(toReturnJ));
+ json_object_get_string(responseJ));
err = -9;
}
else {
@@ -290,13 +290,15 @@ int HalCtlsAttachToMixer(afb_api_t apiHandle)
"Seems that %s call to api %s succeed with no warning raised : '%s'",
MIXER_ATTACH_VERB,
apiToCall,
- json_object_get_string(toReturnJ));
-
+ json_object_get_string(responseJ));
currentCtlHalData->status = HAL_STATUS_READY;
}
- if(returnJ)
- json_object_put(returnJ);
+ if(responseJ)
+ json_object_put(responseJ);
+
+ free(returnedError);
+ free(returnedInfo);
return err;
}
@@ -305,14 +307,10 @@ int HalCtlsGetInfoFromMixer(afb_api_t apiHandle,
char *apiToCall,
json_object *requestJson,
json_object **toReturnJ,
- char **returnedStatus,
+ char **returnedError,
char **returnedInfo)
{
- int err = 0;
-
- enum CallError returnedError;
-
- json_object *returnJ, *responseJ;
+ json_object *responseJ = NULL;
if(! apiHandle) {
AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
@@ -329,24 +327,38 @@ int HalCtlsGetInfoFromMixer(afb_api_t apiHandle,
return -3;
}
- if(afb_api_call_sync_legacy(apiHandle, apiToCall, MIXER_INFO_VERB, json_object_get(requestJson), &returnJ)) {
- returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_INFO_VERB, returnJ, returnedStatus, returnedInfo);
+ if(*returnedError || *returnedInfo) {
+ AFB_API_ERROR(apiHandle, "'returnedError' and 'returnedInfo' strings should be empty and set to 'NULL'");
+ return -4;
+ }
+
+ if(*toReturnJ) {
+ AFB_API_ERROR(apiHandle, "'toReturnJ' should be empty and set to 'NULL'");
+ return -5;
+ }
+
+ if(afb_api_call_sync(apiHandle,
+ apiToCall,
+ MIXER_INFO_VERB,
+ json_object_get(requestJson),
+ &responseJ,
+ returnedError,
+ returnedInfo)) {
AFB_API_ERROR(apiHandle,
- "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
- (int) returnedError,
+ "Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s'",
apiToCall,
MIXER_INFO_VERB,
- *returnedStatus ? *returnedStatus : "not returned",
+ *returnedError ? *returnedError : "not returned",
*returnedInfo ? *returnedInfo : "not returned");
- err = -4;
+ return -6;
}
- else if(! json_object_object_get_ex(returnJ, "response", &responseJ)) {
+ else if(! responseJ) {
AFB_API_ERROR(apiHandle,
- "Seems that %s call to api %s succeed, but response is not valid : '%s'",
+ "Seems that %s call to api %s succeed but no response was returned",
MIXER_INFO_VERB,
- apiToCall,
- json_object_get_string(returnJ));
- err = -5;
+ apiToCall);
+ json_object_put(responseJ);
+ return -7;
}
else {
AFB_API_NOTICE(apiHandle,
@@ -354,10 +366,8 @@ int HalCtlsGetInfoFromMixer(afb_api_t apiHandle,
MIXER_INFO_VERB,
apiToCall,
json_object_get_string(responseJ));
-
- *toReturnJ = json_object_get(responseJ);
+ *toReturnJ = responseJ;
}
- json_object_put(returnJ);
- return err;
+ return 0;
} \ No newline at end of file