summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-05-23 10:41:50 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-05-24 16:35:06 +0200
commit7095c40c09e2afec2382e1307b8bb134496282e3 (patch)
tree3030bbaf2c40b5087912129d5e654e136d006d5a /lib
parente20fca4d144c431dd58face1be7d996ce15815f1 (diff)
Rework mixer answer handling
Rework mixer answer handling to make it simpler and to avoid fanciful returns. Add some error prints to help diagnostic in case of mixer answer handling error. BUG-AGL : SPEC-2329 Change-Id: I14fe86496585bdc66b8aa761f4ff2c56333c5515 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'lib')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c108
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h1
2 files changed, 87 insertions, 22 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 806387a..9e03f33 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
@@ -291,14 +291,66 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
return createdStreamData;
}
+int HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(afb_api_t apiHandle,
+ struct InternalHalMixerData *toRemoveStreamData)
+{
+ int returnedErr, wrapRet;
+
+ json_object *streamRemovedEventJ;
+
+ CtlConfigT *ctrlConfig;
+
+ struct HalData *currentHalData;
+
+ if(! apiHandle || ! toRemoveStreamData)
+ return -1;
+
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
+ return -2;
+
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if((! currentHalData) ||
+ (! currentHalData->internalHalData) ||
+ (! currentHalData->internalHalData->streamsData) ||
+ (! currentHalData->internalHalData->streamUpdates))
+ return -3;
+
+ if(afb_api_del_verb(apiHandle, toRemoveStreamData->verb, NULL)) {
+ AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", toRemoveStreamData->verb);
+ return -4;
+ }
+
+ 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 -5;
+ }
+
+ returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, toRemoveStreamData);
+ if(returnedErr) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i while removing data for stream",
+ returnedErr);
+ json_object_put(streamRemovedEventJ);
+ return -6;
+ }
+
+ afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ);
+
+ return 0;
+}
+
int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId)
{
- int returnedErr = 0, wrapRet;
-
- json_object *streamRemovedEventJ;
+ int returnedErr;
CtlConfigT *ctrlConfig;
@@ -324,30 +376,42 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
if(! toRemoveStreamData)
return -4;
- if(afb_api_del_verb(apiHandle, verb, NULL)) {
- AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb);
- json_object_put(streamRemovedEventJ);
+ returnedErr = HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle,
+ toRemoveStreamData);
+ if(returnedErr) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i while removing verb and data for stream : '%s'",
+ returnedErr,
+ verb);
return -5;
}
- returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, toRemoveStreamData);
- if(returnedErr) {
- AFB_API_ERROR(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb);
- json_object_put(streamRemovedEventJ);
- return -6;
- }
+ return 0;
+}
- 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;
- }
+int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle)
+{
+ CtlConfigT *ctrlConfig;
- afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ);
+ struct HalData *currentHalData;
+
+ if(! apiHandle)
+ return -1;
+
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
+ return -2;
+
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if((! currentHalData) ||
+ (! currentHalData->internalHalData))
+ return -3;
+
+ while(currentHalData->internalHalData->streamsData) {
+ if(HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle,
+ currentHalData->internalHalData->streamsData))
+ return -4;
+ }
return 0;
} \ No newline at end of file
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
index e6f0d99..3345da3 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -43,5 +43,6 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId);
+int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle);
#endif /* _HAL_UTILITIES_HAL_STREAMS_CREATION_INCLUDE_ */ \ No newline at end of file