summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-14 18:14:13 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-18 11:34:58 +0200
commit24046bfdb0568077a074b503d58a343a06f4234a (patch)
tree54ecdea5d0768d3d354a2ddbda1e309d574bbd14 /lib
parent66f27bce6355cc7df978a9d7a6bc725542057a01 (diff)
Refactoring 'streams data' linked list
Refactoring 'streams data' linked list code using liburcu. BUG-AGL: SPEC-2329 Change-Id: Idf9367c015d73574d96d83c82a9e8f5b7588a45d Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'lib')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c138
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h22
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c251
3 files changed, 207 insertions, 204 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index f3f4229..98e3fa0 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -32,6 +32,7 @@
******************************************************************************/
void HalUtlFreeSelectedProbedDeviceAllocation(struct InternalHalProbedDevice *probedDeviceToFree);
+void HalUtlFreeSelectedMixerDataAllocation(struct InternalHalMixerData *mixerDataToFree);
/*******************************************************************************
* Internal Hal - Generic function for linked list *
@@ -53,6 +54,12 @@ void *HalUtlAddNodeInList(struct cds_list_head *listHead, enum LinkedListType li
nodeToAdd = &((struct InternalHalProbedDevice *) returned)->node;
break;
+ case LINKED_LIST_FOR_MIXER_DATA:
+ returned = calloc(1, sizeof(struct InternalHalMixerData));
+ if(! returned)
+ return NULL;
+ nodeToAdd = &((struct InternalHalMixerData *) returned)->node;
+ break;
default:
return NULL;
@@ -75,6 +82,12 @@ int HalUtlRemoveNodeFromList(struct cds_list_head *listHead, void *dataToRemove,
HalUtlFreeSelectedProbedDeviceAllocation((struct InternalHalProbedDevice *) dataToRemove);
break;
+ case LINKED_LIST_FOR_MIXER_DATA:
+ cds_list_del(&((struct InternalHalMixerData *) dataToRemove)->node);
+
+ HalUtlFreeSelectedMixerDataAllocation((struct InternalHalMixerData *) dataToRemove);
+ break;
+
default:
return -2;
}
@@ -102,8 +115,14 @@ int HalUtlRemoveAllNodeFromList(struct cds_list_head *listHead, enum LinkedListT
return -2;
break;
+ case LINKED_LIST_FOR_MIXER_DATA:
+ if(HalUtlRemoveSelectedMixerData(listHead,
+ cds_list_entry(nodeToRemove, struct InternalHalMixerData, node)))
+ return -3;
+ break;
+
default:
- return -3;
+ return -4;
}
nodesRemoved++;
@@ -609,123 +628,55 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
* Internal Hal - Streams data handling functions *
******************************************************************************/
-struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList)
+void HalUtlFreeSelectedMixerDataAllocation(struct InternalHalMixerData *mixerDataToFree)
{
- struct InternalHalMixerData *currentMixerData;
-
- if(! mixerDataList)
- return NULL;
-
- currentMixerData = *mixerDataList;
- if(! currentMixerData) {
- currentMixerData = (struct InternalHalMixerData *) calloc(1, sizeof(struct InternalHalMixerData));
- if(! currentMixerData)
- return NULL;
+ if(! mixerDataToFree)
+ return;
- *mixerDataList = currentMixerData;
- }
- else {
- while(currentMixerData->next)
- currentMixerData = currentMixerData->next;
+ free(mixerDataToFree->verb);
+ free(mixerDataToFree->verbToCall);
+ free(mixerDataToFree->streamCardId);
- currentMixerData->next = calloc(1, sizeof(struct InternalHalMixerData));
- if(! currentMixerData->next)
- return NULL;
-
- currentMixerData = currentMixerData->next;
- }
+ free(mixerDataToFree);
+}
- return currentMixerData;
+struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct cds_list_head *mixerDataListHead)
+{
+ return (struct InternalHalMixerData *) HalUtlAddNodeInList(mixerDataListHead, LINKED_LIST_FOR_MIXER_DATA);
}
-int HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList,
+int HalUtlRemoveSelectedMixerData(struct cds_list_head *mixerDataListHead,
struct InternalHalMixerData *mixerDataToRemove)
{
- struct InternalHalMixerData *currentMixerData, *matchingMixerData;
-
- if(! mixerDataList || ! *mixerDataList || ! mixerDataToRemove)
- return -1;
-
- currentMixerData = *mixerDataList;
- if(currentMixerData == mixerDataToRemove) {
- *mixerDataList = currentMixerData->next;
- matchingMixerData = currentMixerData;
- }
- else {
- while(currentMixerData && currentMixerData->next != mixerDataToRemove)
- currentMixerData = currentMixerData->next;
-
- if(currentMixerData) {
- matchingMixerData = currentMixerData->next;
- currentMixerData->next = currentMixerData->next->next;
- }
- else {
- return -2;
- }
- }
-
- free(matchingMixerData->verb);
- free(matchingMixerData->verbToCall);
- free(matchingMixerData->streamCardId);
-
- free(matchingMixerData);
-
- return 0;
+ return HalUtlRemoveNodeFromList(mixerDataListHead, (void *) mixerDataToRemove, LINKED_LIST_FOR_MIXER_DATA);
}
-int HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList)
+int HalUtlRemoveAllMixerData(struct cds_list_head *mixerDataListHead)
{
- int mixerDataRemoved = 0;
-
- if(! mixerDataList)
- return -1;
-
- while(*mixerDataList) {
- if(HalUtlRemoveSelectedMixerData(mixerDataList, *mixerDataList))
- return -2;
-
- mixerDataRemoved++;
- }
-
- return mixerDataRemoved;
+ return HalUtlRemoveAllNodeFromList(mixerDataListHead, LINKED_LIST_FOR_MIXER_DATA);
}
-int HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList)
+int HalUtlGetNumberOfMixerDataInList(struct cds_list_head *mixerDataListHead)
{
- int numberOfMixerData = 0;
- struct InternalHalMixerData *currentMixerData;
-
- if(! mixerDataList)
- return -1;
-
- currentMixerData = *mixerDataList;
- while(currentMixerData) {
- currentMixerData = currentMixerData->next;
- numberOfMixerData++;
- }
-
- return numberOfMixerData;
+ return HalUtlGetNumberOfNodesInList(mixerDataListHead);
}
-struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList,
+struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct cds_list_head *mixerDataListHead,
char *verb,
char *verbToCall,
char *streamCardId)
{
struct InternalHalMixerData *currentMixerData;
- if(! mixerDataList || ! *mixerDataList || ! verb || ! verbToCall)
+ if(! mixerDataListHead || cds_list_empty(mixerDataListHead) || ! verb || ! verbToCall)
return NULL;
- currentMixerData = *mixerDataList;
- while(currentMixerData) {
+ cds_list_for_each_entry(currentMixerData, mixerDataListHead, node) {
if(! strcmp(verb, currentMixerData->verb) &&
! strcmp(verbToCall, currentMixerData->verbToCall) &&
((! streamCardId && ! currentMixerData->streamCardId) ||
(streamCardId && currentMixerData->streamCardId && ! strcmp(streamCardId, currentMixerData->streamCardId))))
return currentMixerData;
-
- currentMixerData = currentMixerData->next;
}
return NULL;
@@ -759,7 +710,7 @@ json_object *HalUtlGetJsonArrayForSpecificMixerData(afb_api_t apiHandle, struct
return currentMixerDataJ;
}
-json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct InternalHalMixerData **mixerDataList)
+json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_list_head *mixerDataListHead)
{
json_object *mixerDataArrayJ, *currentMixerDataJ;
@@ -776,8 +727,7 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct Inte
return NULL;
}
- currentMixerData = *mixerDataList;
- while(currentMixerData) {
+ cds_list_for_each_entry(currentMixerData, mixerDataListHead, node) {
currentMixerDataJ = HalUtlGetJsonArrayForSpecificMixerData(apiHandle, currentMixerData);
if(! currentMixerDataJ) {
AFB_API_ERROR(apiHandle, "Didn't succeed to generate current mixer data json object");
@@ -786,8 +736,6 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct Inte
}
json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
-
- currentMixerData = currentMixerData->next;
}
return mixerDataArrayJ;
@@ -864,7 +812,7 @@ int HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData
HalUtlRemoveAllProbedDevicesFromList(&matchingHal->internalHalData->probedDevicesListHead);
- HalUtlRemoveAllMixerData(&matchingHal->internalHalData->streamsData);
+ HalUtlRemoveAllMixerData(&matchingHal->internalHalData->streamsDataListHead);
HalUtlFreeAlsaCtlsMap(matchingHal->internalHalData->alsaMapT);
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index 8ac4c25..8bddbbb 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -36,7 +36,8 @@
// Enum for linked list type
enum LinkedListType {
- LINKED_LIST_FOR_DEPENDENCIES_DATA = 0
+ LINKED_LIST_FOR_DEPENDENCIES_DATA = 0,
+ LINKED_LIST_FOR_MIXER_DATA = 1
};
// Enum for hal status
@@ -100,7 +101,7 @@ struct InternalHalMixerData {
char *streamCardId;
afb_event_t event;
- struct InternalHalMixerData *next;
+ struct cds_list_head node;
};
// Structure to store specific internal hal data
@@ -111,7 +112,7 @@ struct InternalHalData {
struct cds_list_head probedDevicesListHead;
- struct InternalHalMixerData *streamsData;
+ struct cds_list_head streamsDataListHead;
afb_event_t streamUpdates;
struct InternalHalAlsaMapT *alsaMapT;
@@ -176,16 +177,17 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
enum DependencyInfoJsonFormat jsonFormat);
// Internal Hal - Streams data handling functions
-struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList);
-int HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList,
+struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct cds_list_head *mixerDataListHead);
+int HalUtlRemoveSelectedMixerData(struct cds_list_head *mixerDataListHead,
struct InternalHalMixerData *mixerDataToRemove);
-int HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList);
-int HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList);
-struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList,
- char *verb, char *verbToCall,
+int HalUtlRemoveAllMixerData(struct cds_list_head *mixerDataListHead);
+int HalUtlGetNumberOfMixerDataInList(struct cds_list_head *mixerDataListHead);
+struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct cds_list_head *mixerDataListHead,
+ char *verb,
+ char *verbToCall,
char *streamCardId);
json_object *HalUtlGetJsonArrayForSpecificMixerData(afb_api_t apiHandle, struct InternalHalMixerData *mixerData);
-json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct InternalHalMixerData **mixerDataList);
+json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_list_head *mixerDataListHead);
// Hal data handling functions
struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList);
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 9e03f33..ffc5578 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
@@ -31,19 +31,116 @@
* Actions to be call when a stream verb is called *
******************************************************************************/
+json_object *HalUtlCallSingleStream(afb_req_t request,
+ afb_api_t apiHandle,
+ CtlConfigT *ctrlConfig,
+ struct HalData *currentHalData,
+ char *apiToCall,
+ struct InternalHalMixerData *currentMixerData,
+ json_object *requestJson)
+{
+ char *returnedError = NULL, *returnedInfo = NULL;
+
+ json_object *responseJ = NULL;
+
+ if(afb_api_call_sync(apiHandle,
+ apiToCall,
+ currentMixerData->verbToCall,
+ json_object_get(requestJson),
+ &responseJ,
+ &returnedError,
+ &returnedInfo)) {
+ if(responseJ)
+ json_object_put(responseJ);
+ AFB_API_ERROR(apiHandle,
+ "Something went wrong during call to verb '%s' of api '%s' "
+ "with error '%s' and info '%s' (stream '%s')",
+ currentMixerData->verbToCall,
+ apiToCall,
+ returnedError ? returnedError : "not returned",
+ returnedInfo ? returnedInfo : "not returned",
+ currentMixerData->verb);
+ free(returnedError);
+ free(returnedInfo);
+ return NULL;
+ }
+
+ if(! responseJ) {
+ AFB_API_ERROR(apiHandle,
+ "Seems that %s call to api %s succeed but no response was returned (stream '%s')",
+ currentMixerData->verbToCall,
+ apiToCall,
+ currentMixerData->verb);
+ free(returnedError);
+ free(returnedInfo);
+ return NULL;
+ }
+
+ // TBD JAI : When mixer events will be available, use them instead of generating events at calls
+ if(! currentMixerData->event ||
+ (afb_event_push(currentMixerData->event, json_object_get(responseJ)) < 0)) {
+ AFB_API_ERROR(apiHandle, "Could not generate an event for stream %s", currentMixerData->verb);
+ }
+
+ return responseJ;
+}
+
+json_object *HalUtlCallAllStream(afb_req_t request,
+ afb_api_t apiHandle,
+ CtlConfigT *ctrlConfig,
+ struct HalData *currentHalData,
+ char *apiToCall,
+ struct cds_list_head *streamsDataListHead,
+ json_object *requestJson)
+{
+ struct InternalHalMixerData *currentMixerData;
+
+ json_object *responseJ = NULL, *toReturnJ;
+
+ toReturnJ = json_object_new_object();
+ if(! toReturnJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate response json object");
+ return NULL;
+ }
+
+ cds_list_for_each_entry(currentMixerData, streamsDataListHead, node) {
+ responseJ = HalUtlCallSingleStream(request,
+ apiHandle,
+ ctrlConfig,
+ currentHalData,
+ apiToCall,
+ currentMixerData,
+ requestJson);
+ if(! responseJ) {
+ AFB_API_ERROR(apiHandle,
+ "Seems that an error happened during %s call to api %s (stream '%s')",
+ currentMixerData->verbToCall,
+ apiToCall,
+ currentMixerData->verb);
+ json_object_put(toReturnJ);
+ return NULL;
+ }
+
+ json_object_object_add(toReturnJ, currentMixerData->verb, responseJ);
+ }
+
+ return toReturnJ;
+}
+
void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
{
- int idx, count;
+ char *apiToCall;
- char *apiToCall, *returnedError = NULL, *returnedInfo = NULL;
+ struct cds_list_head *streamsDataListHead = NULL;
afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
struct HalData *currentHalData;
+
struct InternalHalMixerData *currentMixerData = NULL;
- json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL, *verboseBooleanJ;
+ json_object *requestJson, *verboseBooleanJ, *toReturnJ;
apiHandle = afb_req_get_api(request);
if(! apiHandle) {
@@ -92,97 +189,31 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
return;
}
- currentMixerData = (struct InternalHalMixerData *) afb_req_get_vcbdata(request);
- if(! currentMixerData) {
- afb_req_fail(request, "hal_call_data", "Can't get current call data");
- return;
- }
-
switch(actionType) {
case ACTION_ON_MIXER_STREAM:
- count = 1;
- break;
+ currentMixerData = (struct InternalHalMixerData *) afb_req_get_vcbdata(request);
+ if(! currentMixerData) {
+ afb_req_fail(request, "hal_call_data", "Can't get stream to call data");
+ return;
+ }
- case ACTION_ON_MIXER_ALL_STREAM:
- count = (int) HalUtlGetNumberOfMixerDataInList(&currentMixerData);
- toReturnJ = json_object_new_object();
+ toReturnJ = HalUtlCallSingleStream(request,
+ apiHandle,
+ ctrlConfig,
+ currentHalData,
+ apiToCall,
+ currentMixerData,
+ requestJson);
if(! toReturnJ) {
- afb_req_fail(request,
- "response_json_object",
- "Didn't succeed to allocate response json object");
+ afb_req_fail_f(request,
+ "mixer_call",
+ "Seems that an error happened during %s call to api %s (stream '%s')",
+ currentMixerData->verbToCall,
+ apiToCall,
+ currentMixerData->verb);
return;
}
- break;
-
- default:
- afb_req_fail(request, "mixer_action_type", "Action type is unknown");
- return;
- }
-
- for(idx = 0; idx < count; idx++) {
- 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(! responseJ) {
- if(toReturnJ)
- json_object_put(toReturnJ);
- afb_req_fail_f(request,
- "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,
- idx,
- count);
- free(returnedError);
- free(returnedInfo);
- return;
- }
-
- // TBD JAI : When mixer events will be available, use them instead of generating events at calls
- if(! currentMixerData->event ||
- (afb_event_push(currentMixerData->event, json_object_get(responseJ)) < 0)) {
- AFB_API_ERROR(apiHandle, "Could not generate an event for stream %s", currentMixerData->verb);
- }
-
- switch(actionType) {
- case ACTION_ON_MIXER_STREAM:
- toReturnJ = responseJ;
- break;
-
- case ACTION_ON_MIXER_ALL_STREAM:
- json_object_object_add(toReturnJ, currentMixerData->verb, responseJ);
- currentMixerData = currentMixerData->next;
- break;
- default:
- break;
- }
- }
-
- switch(actionType) {
- case ACTION_ON_MIXER_STREAM:
afb_req_success_f(request,
toReturnJ,
"Action %s correctly transferred to %s without any error raised",
@@ -191,13 +222,35 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
break;
case ACTION_ON_MIXER_ALL_STREAM:
+ streamsDataListHead = (struct cds_list_head *) afb_req_get_vcbdata(request);
+ if(! streamsDataListHead) {
+ afb_req_fail(request, "hal_call_data", "Can't get stream list data");
+ return;
+ }
+
+ toReturnJ = HalUtlCallAllStream(request,
+ apiHandle,
+ ctrlConfig,
+ currentHalData,
+ apiToCall,
+ streamsDataListHead,
+ requestJson);
+ if(! toReturnJ) {
+ afb_req_fail_f(request,
+ "mixer_call",
+ "Seems that an error happened during call to all streams using api %s",
+ apiToCall);
+ return;
+ }
+
afb_req_success(request,
toReturnJ,
"Actions correctly transferred to all streams without any error raised");
break;
default:
- break;
+ afb_req_fail(request, "mixer_action_type", "Action type is unknown");
+ return;
}
}
@@ -241,7 +294,7 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
! currentHalData->internalHalData)
return NULL;
- createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentHalData->internalHalData->streamsData);
+ createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentHalData->internalHalData->streamsDataListHead);
if(! createdStreamData)
return NULL;
@@ -252,13 +305,13 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
if(! createdStreamData->verb ||
! createdStreamData->verbToCall ||
! createdStreamData->streamCardId) {
- HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsDataListHead, createdStreamData);
return NULL;
}
createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb);
if(! createdStreamData->event) {
- HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsDataListHead, createdStreamData);
return NULL;
}
@@ -271,7 +324,7 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
0,
0)) {
AFB_API_ERROR(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb);
- HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsDataListHead, createdStreamData);
return NULL;
}
@@ -282,7 +335,7 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
"cardId", createdStreamData->streamCardId);
if(wrapRet) {
AFB_API_ERROR(apiHandle,"Didn't succeed to allocate added stream event json object");
- HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsDataListHead, createdStreamData);
return NULL;
}
@@ -312,7 +365,6 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(afb_api_t apiHandle,
currentHalData = (struct HalData *) getExternalData(ctrlConfig);
if((! currentHalData) ||
(! currentHalData->internalHalData) ||
- (! currentHalData->internalHalData->streamsData) ||
(! currentHalData->internalHalData->streamUpdates))
return -3;
@@ -331,7 +383,7 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(afb_api_t apiHandle,
return -5;
}
- returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, toRemoveStreamData);
+ returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsDataListHead, toRemoveStreamData);
if(returnedErr) {
AFB_API_ERROR(apiHandle,
"Error %i while removing data for stream",
@@ -369,7 +421,7 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
! currentHalData->internalHalData)
return -3;
- toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentHalData->internalHalData->streamsData,
+ toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentHalData->internalHalData->streamsDataListHead,
verb,
verbToCall,
streamCardId);
@@ -395,6 +447,8 @@ int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle)
struct HalData *currentHalData;
+ struct InternalHalMixerData *currentMixerData, *savedMixerData;
+
if(! apiHandle)
return -1;
@@ -407,9 +461,8 @@ int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle)
(! currentHalData->internalHalData))
return -3;
- while(currentHalData->internalHalData->streamsData) {
- if(HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle,
- currentHalData->internalHalData->streamsData))
+ cds_list_for_each_entry_safe(currentMixerData, savedMixerData, &currentHalData->internalHalData->streamsDataListHead, node) {
+ if(HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle, currentMixerData))
return -4;
}