aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-10 09:49:24 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:43 +0100
commite3f74a9f59c05df601aa26554612fc68901c1646 (patch)
treede604ee593e46f57595a068dc261e048defd7668
parent4f44ee8f17789ac27cd1e29a451ac450c7dbeb06 (diff)
Use linked-list to handle hal stream list
Use linked-list instead of an array to handle hal stream list. Usefull to add/remove dynamic stream (e.g. bluetooth). Change-Id: I39bbf0f16941f1c4642c916fdc5143a683c6460c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c142
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.h21
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c104
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c135
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h8
6 files changed, 268 insertions, 144 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
index 4bb19a8..b5d0293 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -29,27 +29,126 @@
* Specfic Hal controller streams data handling functions *
******************************************************************************/
-uint8_t HalUtlRemoveAllCtlHalStreamsData(struct CtlHalMixerDataT *ctlHalStreamsData)
+struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **firstMixerData)
{
- unsigned int cpt;
+ struct CtlHalMixerData *currentMixerData;
- if(! ctlHalStreamsData)
+ if(! firstMixerData)
+ return NULL;
+
+ currentMixerData = *firstMixerData;
+
+ if(! currentMixerData) {
+ currentMixerData = (struct CtlHalMixerData *) calloc(1, sizeof(struct CtlHalMixerData));
+ if(! currentMixerData)
+ return NULL;
+
+ *firstMixerData = currentMixerData;
+ }
+ else {
+ while(currentMixerData->next)
+ currentMixerData = currentMixerData->next;
+
+ currentMixerData->next = calloc(1, sizeof(struct CtlHalMixerData));
+ if(! currentMixerData)
+ return NULL;
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return currentMixerData;
+}
+
+int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, struct CtlHalMixerData *mixerDataToRemove)
+{
+ struct CtlHalMixerData *currentMixerData, *matchingMixerData;
+
+ if(! firstMixerData || ! mixerDataToRemove)
return -1;
- if(! ctlHalStreamsData->count)
- return -2;
+ currentMixerData = *firstMixerData;
- for(cpt = 0; cpt < ctlHalStreamsData->count; cpt++) {
- free(ctlHalStreamsData->data[cpt].verb);
- free(ctlHalStreamsData->data[cpt].verbToCall);
- free(ctlHalStreamsData->data[cpt].streamCardId);
+ if(currentMixerData == mixerDataToRemove) {
+ *firstMixerData = 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(ctlHalStreamsData->data);
+ free(matchingMixerData->verb);
+ free(matchingMixerData->verbToCall);
+ free(matchingMixerData->streamCardId);
+
+ free(matchingMixerData);
return 0;
}
+int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData)
+{
+ int8_t ret;
+ int64_t mixerDataRemoved = 0;
+
+ while(*firstMixerData) {
+ ret = HalUtlRemoveSelectedMixerData(firstMixerData, *firstMixerData);
+ if(ret)
+ return (int64_t) ret;
+
+ mixerDataRemoved++;
+ }
+
+ return mixerDataRemoved;
+}
+
+int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData)
+{
+ int64_t numberOfMixerData = 0;
+ struct CtlHalMixerData *currentMixerData;
+
+ if(! firstMixerData)
+ return -1;
+
+ currentMixerData = *firstMixerData;
+
+ while(currentMixerData) {
+ currentMixerData = currentMixerData->next;
+ numberOfMixerData++;
+ }
+
+ return numberOfMixerData;
+}
+
+struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **firstMixerData, char *verb, char *verbToCall, char *streamCardId)
+{
+ struct CtlHalMixerData *currentMixerData;
+
+ if(! firstMixerData || ! verb)
+ return NULL;
+
+ currentMixerData = *firstMixerData;
+
+ while(currentMixerData) {
+ if((! strcmp(verb, currentMixerData->verb)) &&
+ (! strcmp(verbToCall, currentMixerData->verbToCall)) &&
+ (! strcmp(streamCardId, currentMixerData->streamCardId)))
+ return currentMixerData;
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return NULL;
+}
+
/*******************************************************************************
* Specfic Hal data handling functions *
******************************************************************************/
@@ -81,8 +180,6 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstH
currentApi = currentApi->next;
}
- memset(currentApi, 0, sizeof(struct SpecificHalData));
-
return currentApi;
}
@@ -112,16 +209,17 @@ int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, st
}
}
- if(! matchingApi->internal) {
- free(matchingApi->apiName);
- free(matchingApi->sndCardPath);
- free(matchingApi->info);
- free(matchingApi->author);
- free(matchingApi->version);
- free(matchingApi->date);
- }
- else {
- HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
+ free(matchingApi->apiName);
+ free(matchingApi->sndCardPath);
+ free(matchingApi->info);
+ free(matchingApi->author);
+ free(matchingApi->version);
+ free(matchingApi->date);
+
+ if(matchingApi->internal) {
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalPlaybacksData);
+ HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalCapturesData);
HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT);
diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h
index 031fa9b..a2f1f1a 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-data.h
@@ -41,12 +41,8 @@ struct CtlHalMixerData {
char *verbToCall;
char *streamCardId;
AFB_EventT event;
-};
-// Structure to store stream data table
-struct CtlHalMixerDataT {
- struct CtlHalMixerData *data;
- unsigned int count;
+ struct CtlHalMixerData *next;
};
// Structure to store specific controller hal data
@@ -55,9 +51,11 @@ struct CtlHalSpecificData {
char *prefix;
json_object *halMixerJ;
- struct CtlHalMixerDataT ctlHalStreamsData;
- struct CtlHalMixerDataT ctlHalPlaybacksData;
- struct CtlHalMixerDataT ctlHalCapturesData;
+ struct CtlHalMixerData *ctlHalStreamsData;
+
+ struct CtlHalMixerData *ctlHalPlaybacksData;
+ struct CtlHalMixerData *ctlHalCapturesData;
+
struct CtlHalAlsaMapT *ctlHalAlsaMapT;
AFB_ApiT apiHandle;
@@ -93,6 +91,13 @@ struct HalMgrData {
struct SpecificHalData *first;
};
+// Specfic Hal controller streams data handling functions
+struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **firstMixerData);
+int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **firstMixerData, struct CtlHalMixerData *mixerDataToRemove);
+int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **firstMixerData);
+int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **firstMixerData);
+struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **firstMixerData, char *verb, char *verbToCall, char *streamCardId);
+
// Exported verbs for 'struct SpecificHalData' handling
struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData);
int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *ApiToRemove);
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 72515e7..0f63be7 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -104,8 +104,6 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
currentCtlHalData->ctlHalSpecificData->apiHandle = apiHandle;
currentCtlHalData->ctlHalSpecificData->ctrlConfig = ctrlConfig;
- currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData.count = 0;
-
currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath);
if(currentCtlHalData->sndCardId < 0)
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
index ba2454a..e501e53 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -419,7 +419,6 @@ void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
struct SpecificHalData *currentCtlHalData;
struct CtlHalMixerData *currentMixerData = NULL;
- struct CtlHalMixerDataT *currentMixerDataT = NULL;
json_object *requestJson, *returnJ = NULL, *responseJ, *toReturnJ = NULL;
@@ -461,25 +460,20 @@ void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
return;
}
+ if(! (currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request))) {
+ AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ return;
+ }
+
switch(actionType) {
case ACTION_ON_MIXER_STREAM:
- currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request);
- if(! currentMixerData) {
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
- return;
- }
count = 1;
break;
case ACTION_ON_MIXER_PLAYBACK:
case ACTION_ON_MIXER_CAPTURE:
case ACTION_ON_MIXER_ALL_STREAM:
- currentMixerDataT = (struct CtlHalMixerDataT *) AFB_ReqVCBData(request);
- if(! currentMixerDataT) {
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
- return;
- }
- count = currentMixerDataT->count;
+ count = (int) HalUtlGetNumberOfMixerDataInList(&currentMixerData);
toReturnJ = json_object_new_object();
break;
@@ -489,17 +483,6 @@ void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
}
for(idx = 0; idx < count; idx++) {
- switch(actionType) {
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
- case ACTION_ON_MIXER_ALL_STREAM:
- currentMixerData = &currentMixerDataT->data[idx];
- break;
-
- default:
- break;
- }
-
if(AFB_ServiceSync(apiHandle,
apiToCall,
currentMixerData->verbToCall,
@@ -551,6 +534,17 @@ void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
}
json_object_put(returnJ);
+
+ switch(actionType) {
+ case ACTION_ON_MIXER_PLAYBACK:
+ case ACTION_ON_MIXER_CAPTURE:
+ case ACTION_ON_MIXER_ALL_STREAM:
+ currentMixerData = currentMixerData->next;
+ break;
+
+ default:
+ break;
+ }
}
switch(actionType) {
@@ -605,54 +599,53 @@ void HalCtlsActionOnAllStream(AFB_ReqT request)
HalCtlsActionOnMixer(request, ACTION_ON_MIXER_ALL_STREAM);
}
-json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentMixerDataT, enum MixerDataType dataType)
+json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMixerData, enum MixerDataType dataType)
{
- unsigned int idx;
+ json_object *mixerDataArrayJ, *currentMixerDataJ;
- json_object *mixerDataArray, *currentMixerData;
+ struct CtlHalMixerData *currentMixerData;
if(! apiHandle) {
AFB_ApiError(apiHandle, "Can't get current hal controller api handle");
return NULL;
}
- if(! currentMixerDataT) {
- AFB_ApiError(apiHandle, "Can't get mixer data table to handle");
- return NULL;
- }
-
- mixerDataArray = json_object_new_array();
- if(! mixerDataArray) {
+ mixerDataArrayJ = json_object_new_array();
+ if(! mixerDataArrayJ) {
AFB_ApiError(apiHandle, "Can't generate json mixer data array");
return NULL;
}
- for(idx = 0; idx < currentMixerDataT->count; idx++) {
+ currentMixerData = *firstMixerData;
+
+ while(currentMixerData) {
switch(dataType) {
case MIXER_DATA_STREAMS:
- wrap_json_pack(&currentMixerData,
+ wrap_json_pack(&currentMixerDataJ,
"{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "cardId", currentMixerDataT->data[idx].streamCardId);
+ "name", currentMixerData->verb,
+ "cardId", currentMixerData->streamCardId);
break;
case MIXER_DATA_PLAYBACKS:
case MIXER_DATA_CAPTURES :
- wrap_json_pack(&currentMixerData,
+ wrap_json_pack(&currentMixerDataJ,
"{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "mixer-name", currentMixerDataT->data[idx].verbToCall,
- "uid", currentMixerDataT->data[idx].streamCardId ? currentMixerDataT->data[idx].streamCardId : "none");
+ "name", currentMixerData->verb,
+ "mixer-name", currentMixerData->verbToCall,
+ "uid", currentMixerData->streamCardId ? currentMixerData->streamCardId : "none");
break;
default:
- json_object_put(mixerDataArray);
+ json_object_put(mixerDataArrayJ);
return NULL;
}
- json_object_array_add(mixerDataArray, currentMixerData);
+ json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
+
+ currentMixerData = currentMixerData->next;
}
- return mixerDataArray;
+ return mixerDataArrayJ;
}
json_object *HalCtlsGetJsonArrayForControls(AFB_ApiT apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT)
@@ -794,7 +787,7 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
- struct CtlHalMixerDataT *halStreamsData;
+ struct CtlHalMixerData *currentStreamData;
struct CtlHalAlsaMapT *halAlsaMapT;
json_object *requestJson, *requestedSubscriptionsJ, *requestedSubscriptionJ = NULL;
@@ -823,7 +816,6 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
return;
}
- halStreamsData = &currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData;
halAlsaMapT = currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT;
requestJson = AFB_ReqJson(request);
@@ -864,26 +856,26 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
subscriptionFound = 0;
currentSubscriptionString = (char *) json_object_get_string(requestedSubscriptionJ);
- searchIdx = 0;
- while((searchIdx < halStreamsData->count) &&
+ currentStreamData = currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData;
+ while(currentStreamData &&
(! subscriptionFound)) {
- if(! strcasecmp(currentSubscriptionString, halStreamsData->data[searchIdx].verb)) {
- if(halStreamsData->data[searchIdx].event &&
+ if(! strcasecmp(currentSubscriptionString, currentStreamData->verb)) {
+ if(currentStreamData->event &&
subscribeUnsubscribeType == SUBSCRIPTION &&
- afb_req_subscribe(request, halStreamsData->data[searchIdx].event)) {
+ afb_req_subscribe(request, currentStreamData->event)) {
AFB_ReqFailF(request,
"request_stream_event",
"Error while trying to subscribe to %s stream events",
- halStreamsData->data[searchIdx].verb);
+ currentStreamData->verb);
return;
}
- else if(halStreamsData->data[searchIdx].event &&
+ else if(currentStreamData->event &&
subscribeUnsubscribeType == UNSUBSCRIPTION &&
- afb_req_unsubscribe(request, halStreamsData->data[searchIdx].event)) {
+ afb_req_unsubscribe(request, currentStreamData->event)) {
AFB_ReqFailF(request,
"request_stream_event",
"Error while trying to unsubscribe to %s stream events",
- halStreamsData->data[searchIdx].verb);
+ currentStreamData->verb);
return;
}
@@ -893,7 +885,7 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
break;
}
- searchIdx++;
+ currentStreamData = currentStreamData->next;
}
searchIdx = 0;
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 fd42899..72f62dd 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
@@ -37,9 +37,9 @@
* HAL controllers handle mixer calls functions *
******************************************************************************/
-int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentMixerDataT, json_object *currentDataJ, enum MixerDataType dataType)
+int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMixerData, json_object *currentDataJ, enum MixerDataType dataType)
{
- int idx, verbStart, size;
+ int idx, mixerDataNb, verbStart, size;
int err = (int) MIXER_NO_ERROR;
char *currentDataVerbName, *currentStreamCardId;
@@ -47,23 +47,23 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentM
json_type currentDataType;
json_object *currentJ;
+ struct CtlHalMixerData *currentMixerData;
+
currentDataType = json_object_get_type(currentDataJ);
switch(currentDataType) {
case json_type_object:
- currentMixerDataT->count = 1;
+ mixerDataNb = 1;
break;
case json_type_array:
- currentMixerDataT->count = (unsigned int) json_object_array_length(currentDataJ);
+ mixerDataNb = (unsigned int) json_object_array_length(currentDataJ);
break;
default:
- currentMixerDataT->count = 0;
+ mixerDataNb = 0;
AFB_ApiError(apiHandle, "No data returned");
return (int) MIXER_ERROR_DATA_EMPTY;
}
- currentMixerDataT->data = (struct CtlHalMixerData *) calloc(currentMixerDataT->count, sizeof(struct CtlHalMixerData));
-
- for(idx = 0; idx < currentMixerDataT->count; idx++) {
+ for(idx = 0; idx < mixerDataNb; idx++) {
if(currentDataType == json_type_array)
currentJ = json_object_array_get_idx(currentDataJ, (int) idx);
else
@@ -78,51 +78,80 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentM
err += (int) MIXER_ERROR_DATA_CARDID_UNAVAILABLE;
}
else {
- currentMixerDataT->data[idx].verbToCall = strdup(currentDataVerbName);
+ switch(dataType) {
+ case MIXER_DATA_STREAMS:
+ size = (int) strlen(currentDataVerbName);
+ for(verbStart = 0; verbStart < size; verbStart++) {
+ if(currentDataVerbName[verbStart] == '#') {
+ verbStart++;
+ break;
+ }
+ }
- if(dataType == MIXER_DATA_STREAMS) {
- currentMixerDataT->data[idx].streamCardId = strdup(currentStreamCardId);
+ if(verbStart == size)
+ verbStart = 0;
- size = (int) strlen(currentDataVerbName);
- for(verbStart = 0; verbStart < size; verbStart++) {
- if(currentDataVerbName[verbStart] == '#') {
- verbStart++;
+ if(! (currentMixerData = HalUtlAddMixerDataToMixerDataList(firstMixerData))) {
+ AFB_ApiError(apiHandle, "Error while adding a stream to stream list");
+ err += (int) MIXER_ERROR_STREAM_NOT_ADDED_TO_STREAM_LIST;
break;
}
- }
-
- if(verbStart == size)
- verbStart = 0;
-
- currentMixerDataT->data[idx].verb = strdup(&currentDataVerbName[verbStart]);
-
- if(AFB_ApiAddVerb(apiHandle,
- currentMixerDataT->data[idx].verb,
- "Stream action transferred to mixer",
- HalCtlsActionOnStream,
- (void *) &currentMixerDataT->data[idx],
- NULL,
- 0,
- 0)) {
- AFB_ApiError(apiHandle,
- "Error while creating verbs for stream : '%s'",
- currentMixerDataT->data[idx].verb);
- err += (int) MIXER_ERROR_STREAM_VERB_NOT_CREATED;
- }
-
- currentMixerDataT->data[idx].event = AFB_EventMake(apiHandle, currentMixerDataT->data[idx].verb);
- if(! AFB_EventIsValid(currentMixerDataT->data[idx].event)) {
- AFB_ApiError(apiHandle,
- "Error while creating event for stream : '%s'",
- currentMixerDataT->data[idx].verb);
- err += (int) MIXER_ERROR_STREAM_EVENT_NOT_CREATED;
- }
- }
- else if(dataType == MIXER_DATA_PLAYBACKS) {
- currentMixerDataT->data[idx].verb = strdup(HAL_PLAYBACK_ID);
- }
- else if(dataType == MIXER_DATA_CAPTURES) {
- currentMixerDataT->data[idx].verb = strdup(HAL_CAPTURE_ID);
+
+ currentMixerData->verb = strdup(&currentDataVerbName[verbStart]);
+ currentMixerData->verbToCall = strdup(currentDataVerbName);
+ currentMixerData->streamCardId = strdup(currentStreamCardId);
+
+ if((! currentMixerData->verb) ||
+ (! currentMixerData->verbToCall) ||
+ (! currentMixerData->streamCardId)) {
+ HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
+ err += (int) MIXER_ERROR_STREAM_ALLOCATION_FAILED;
+ break;
+ }
+
+ if(AFB_ApiAddVerb(apiHandle,
+ currentMixerData->verb,
+ "Stream action transferred to mixer",
+ HalCtlsActionOnStream,
+ (void *) currentMixerData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_ApiError(apiHandle,
+ "Error while creating verbs for stream : '%s'",
+ currentMixerData->verb);
+ HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
+ err += (int) MIXER_ERROR_STREAM_VERB_NOT_CREATED;
+ break;
+ }
+
+ currentMixerData->event = AFB_EventMake(apiHandle, currentMixerData->verb);
+ if(! AFB_EventIsValid(currentMixerData->event)) {
+ AFB_ApiError(apiHandle,
+ "Error while creating event for stream %s",
+ currentMixerData->verb);
+ HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
+ err += (int) MIXER_ERROR_STREAM_EVENT_NOT_CREATED;
+ }
+
+ break;
+
+ case MIXER_DATA_PLAYBACKS:
+ case MIXER_DATA_CAPTURES:
+ currentMixerData = HalUtlAddMixerDataToMixerDataList(firstMixerData);
+
+ currentMixerData->verb = strdup((dataType == MIXER_DATA_PLAYBACKS) ? HAL_PLAYBACK_ID : HAL_CAPTURE_ID);
+ currentMixerData->verbToCall = strdup(currentDataVerbName);
+
+ if((! currentMixerData->verb) ||
+ (! currentMixerData->verbToCall)) {
+ HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
+ err += (int) MIXER_ERROR_STREAM_ALLOCATION_FAILED;
+ }
+ break;
+
+ default:
+ break;
}
}
}
@@ -132,7 +161,7 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentM
HAL_PLAYBACK_ID,
"Playback action transferred to mixer",
HalCtlsActionOnPlayback,
- (void *) currentMixerDataT,
+ (void *) *firstMixerData,
NULL,
0,
0)) {
@@ -146,7 +175,7 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentM
HAL_CAPTURE_ID,
"Capture action transferred to mixer",
HalCtlsActionOnCapture,
- (void *) currentMixerDataT,
+ (void *) *firstMixerData,
NULL,
0,
0)) {
@@ -183,14 +212,14 @@ int HalCtlsHandleMixerAttachResponse(AFB_ApiT apiHandle, struct CtlHalSpecificDa
if(mixerCapturesJ && (err += HalCtlsHandleMixerData(apiHandle, &currentHalSpecificData->ctlHalCapturesData, mixerCapturesJ, MIXER_DATA_CAPTURES)))
AFB_ApiError(apiHandle, "Error during handling response mixer captures data '%s'", json_object_get_string(mixerCapturesJ));
- if(! currentHalSpecificData->ctlHalStreamsData.count) {
+ if(! currentHalSpecificData->ctlHalStreamsData) {
AFB_ApiWarning(apiHandle, "No stream detected in mixer response, %s verb won't be created", HAL_ALL_STREAMS_VERB);
}
else if(AFB_ApiAddVerb(apiHandle,
HAL_ALL_STREAMS_VERB,
"Send a stream action on all streams",
HalCtlsActionOnAllStream,
- (void *) &currentHalSpecificData->ctlHalStreamsData,
+ (void *) currentHalSpecificData->ctlHalStreamsData,
NULL,
0,
0)) {
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
index 9189664..7856bb7 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
@@ -51,9 +51,11 @@ enum MixerStatus {
MIXER_ERROR_CAPTURE_VERB_NOT_CREATED =-5,
MIXER_ERROR_ALL_STREAMS_VERB_NOT_CREATED =-6,
MIXER_ERROR_DATA_NAME_UNAVAILABLE=-10,
- MIXER_ERROR_DATA_CARDID_UNAVAILABLE=-1000,
- MIXER_ERROR_STREAM_VERB_NOT_CREATED =-100000,
- MIXER_ERROR_STREAM_EVENT_NOT_CREATED =-10000000
+ MIXER_ERROR_DATA_CARDID_UNAVAILABLE=-100,
+ MIXER_ERROR_STREAM_NOT_ADDED_TO_STREAM_LIST =-1000,
+ MIXER_ERROR_STREAM_ALLOCATION_FAILED =-10000,
+ MIXER_ERROR_STREAM_EVENT_NOT_CREATED =-100000,
+ MIXER_ERROR_STREAM_VERB_NOT_CREATED =-1000000
};
// HAL controllers handle mixer calls functions