summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c104
1 files changed, 48 insertions, 56 deletions
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;