summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Desneux <stephane.desneux@iot.bzh>2019-10-17 13:41:13 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-10-17 13:41:13 +0000
commit588c9c91614985b85ebf67b17415f9aff30dd8ac (patch)
treefe8913a88764434d1cd3021e31282d7f96866fb1
parente9230768a7027bb7b3ecb69cfaad587ab3f918b5 (diff)
parent1b07640d75f5a3c70655c629340e0263a21a2ff8 (diff)
Merge "Add function to 'detach' dependency from mixer"
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h4
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.c82
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.h2
3 files changed, 87 insertions, 1 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index 38cade6..69ba747 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -61,7 +61,9 @@ enum DependencyMixerStatus {
DEPENDENCY_NO_MIXER_LINK = 0,
DEPENDENCY_MIXER_LINK_USELESS = 1,
DEPENDENCY_MIXER_ATTACH_SUCCEED = 2,
- DEPENDENCY_MIXER_ATTACH_FAILED = 3
+ DEPENDENCY_MIXER_ATTACH_FAILED = 3,
+ DEPENDENCY_MIXER_DETACH_SUCCEED = 4,
+ DEPENDENCY_MIXER_DETACH_FAILED = 5
};
// Enum for probed devices (dependencies) info format requested
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.c b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
index a1b87b0..19fb3a0 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
@@ -259,6 +259,7 @@ int InternalHalAttachDependencyToMixer(afb_api_t apiHandle, struct InternalHalPr
probedDeviceToAttach->mixerLinkStatus = DEPENDENCY_MIXER_ATTACH_FAILED;
else
probedDeviceToAttach->mixerLinkStatus = DEPENDENCY_MIXER_ATTACH_SUCCEED;
+
if(responseJ)
json_object_put(responseJ);
@@ -268,6 +269,87 @@ int InternalHalAttachDependencyToMixer(afb_api_t apiHandle, struct InternalHalPr
return err;
}
+int InternalHalDetachDependencyToMixer(afb_api_t apiHandle, struct InternalHalProbedDevice *probedDeviceToDetach)
+{
+ int err, toReturn = 0;
+
+ char *apiToCall, *returnedError = NULL, *returnedInfo = NULL;
+
+ CtlConfigT *ctrlConfig;
+
+ struct HalData *currentHalData;
+
+ json_object *requestJ, *dependencyJ, *responseJ = NULL;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle");
+ return -1;
+ }
+
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal controller config");
+ return -2;
+ }
+
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData) {
+ AFB_API_ERROR(apiHandle, "Can't get current internal hal controller data");
+ return -3;
+ }
+
+ apiToCall = currentHalData->internalHalData->mixerApiName;
+ if(! apiToCall) {
+ AFB_API_ERROR(apiHandle, "Can't get mixer api");
+ return -4;
+ }
+
+ dependencyJ = HalUtlGetJsonForSpecificDependenciesUsingUid(apiHandle,
+ &currentHalData->internalHalData->probedDevicesListHead,
+ probedDeviceToDetach->uid,
+ DEPENDENCY_COMPACT_JSON);
+ if(! dependencyJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to get dependency %s compact json array", probedDeviceToDetach->uid);
+ return -5;
+ }
+
+ err = wrap_json_pack(&requestJ, "{s:o}", "dependencies", dependencyJ);
+ if(err) {
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to allocate detach dependency %s request json", probedDeviceToDetach->uid);
+ return -6;
+ }
+
+ if(afb_api_call_sync(apiHandle,
+ apiToCall,
+ MIXER_DETACH_VERB,
+ requestJ,
+ &responseJ,
+ &returnedError,
+ &returnedInfo)) {
+ AFB_API_ERROR(apiHandle,
+ "Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s'",
+ MIXER_DETACH_VERB,
+ apiToCall,
+ returnedError ? returnedError : "not returned",
+ returnedInfo ? returnedInfo : "not returned");
+ toReturn = -7;
+ }
+
+ if(toReturn)
+ probedDeviceToDetach->mixerLinkStatus = DEPENDENCY_MIXER_DETACH_FAILED;
+ else
+ probedDeviceToDetach->mixerLinkStatus = DEPENDENCY_MIXER_DETACH_SUCCEED;
+
+ if(responseJ)
+ json_object_put(responseJ);
+
+ free(returnedError);
+ free(returnedInfo);
+
+ return toReturn;
+}
+
int InternalHalGetInfoFromMixer(afb_api_t apiHandle,
char *apiToCall,
json_object *requestJson,
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.h b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
index b22b5b2..af80844 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.h
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
@@ -29,12 +29,14 @@
#include "4a-hal-utilities-data.h"
#define MIXER_ATTACH_VERB "attach"
+#define MIXER_DETACH_VERB "detach"
#define MIXER_INFO_VERB "info"
#define HAL_ALL_STREAMS_VERB "all-streams"
// Internals HAL handle mixer calls functions
int InternalHalAttachDependencyToMixer(afb_api_t apiHandle, struct InternalHalProbedDevice *probedDeviceToAttach);
+int InternalHalDetachDependencyToMixer(afb_api_t apiHandle, struct InternalHalProbedDevice *probedDeviceToDetach);
int InternalHalGetInfoFromMixer(afb_api_t apiHandle,
char *apiToCall,
json_object *requestJson,