aboutsummaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c214
1 files changed, 108 insertions, 106 deletions
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 da05498..1574f83 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
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-utilities-data.h"
@@ -39,7 +39,7 @@
* HAL controllers handle mixer calls functions *
******************************************************************************/
-int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMixerData, json_object *currentDataJ, enum MixerDataType dataType)
+int HalCtlsHandleMixerData(afb_api_t apiHandle, struct CtlHalMixerData **firstMixerData, json_object *currentDataJ, enum MixerDataType dataType)
{
int idx, mixerDataNb, verbStart, size;
int err = (int) MIXER_NO_ERROR;
@@ -61,7 +61,7 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
break;
default:
mixerDataNb = 0;
- AFB_ApiError(apiHandle, "No data returned");
+ AFB_API_ERROR(apiHandle, "No data returned");
return (int) MIXER_ERROR_DATA_EMPTY;
}
@@ -72,11 +72,11 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
currentJ = currentDataJ;
if(wrap_json_unpack(currentJ, "{s:s}", "verb", &currentDataVerbName)) {
- AFB_ApiError(apiHandle, "Can't find verb in current data object");
+ AFB_API_ERROR(apiHandle, "Can't find verb in current data object");
err += (int) MIXER_ERROR_DATA_NAME_UNAVAILABLE;
}
else if(dataType == MIXER_DATA_STREAMS && wrap_json_unpack(currentJ, "{s:s}", "alsa", &currentStreamCardId)) {
- AFB_ApiError(apiHandle, "Can't find card id in current data object");
+ AFB_API_ERROR(apiHandle, "Can't find card id in current data object");
err += (int) MIXER_ERROR_DATA_CARDID_UNAVAILABLE;
}
else {
@@ -97,9 +97,9 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
&currentDataVerbName[verbStart],
currentDataVerbName,
currentStreamCardId)) {
- AFB_ApiError(apiHandle,
- "Error while adding stream '%s'",
- currentDataVerbName);
+ AFB_API_ERROR(apiHandle,
+ "Error while adding stream '%s'",
+ currentDataVerbName);
err += (int) MIXER_ERROR_STREAM_NOT_ADDED;
}
@@ -126,29 +126,29 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
}
if(dataType == MIXER_DATA_PLAYBACKS) {
- if(AFB_ApiAddVerb(apiHandle,
- HAL_PLAYBACK_ID,
- "Playback action transferred to mixer",
- HalUtlActionOnPlayback,
- (void *) *firstMixerData,
- NULL,
- 0,
- 0)) {
- AFB_ApiError(apiHandle, "Error while creating verb for playbacks : '%s'", HAL_PLAYBACK_ID);
+ if(afb_api_add_verb(apiHandle,
+ HAL_PLAYBACK_ID,
+ "Playback action transferred to mixer",
+ HalUtlActionOnPlayback,
+ (void *) *firstMixerData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_API_ERROR(apiHandle, "Error while creating verb for playbacks : '%s'", HAL_PLAYBACK_ID);
err += (int) MIXER_ERROR_PLAYBACK_VERB_NOT_CREATED;
}
}
if(dataType == MIXER_DATA_CAPTURES) {
- if(AFB_ApiAddVerb(apiHandle,
- HAL_CAPTURE_ID,
- "Capture action transferred to mixer",
- HalUtlActionOnCapture,
- (void *) *firstMixerData,
- NULL,
- 0,
- 0)) {
- AFB_ApiError(apiHandle, "Error while creating verb for captures : '%s'", HAL_CAPTURE_ID);
+ if(afb_api_add_verb(apiHandle,
+ HAL_CAPTURE_ID,
+ "Capture action transferred to mixer",
+ HalUtlActionOnCapture,
+ (void *) *firstMixerData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_API_ERROR(apiHandle, "Error while creating verb for captures : '%s'", HAL_CAPTURE_ID);
err += (int) MIXER_ERROR_CAPTURE_VERB_NOT_CREATED;
}
}
@@ -156,50 +156,50 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
return err;
}
-int HalCtlsHandleMixerAttachResponse(AFB_ApiT apiHandle, struct CtlHalSpecificData *currentHalSpecificData, json_object *mixerResponseJ)
+int HalCtlsHandleMixerAttachResponse(afb_api_t apiHandle, struct CtlHalSpecificData *currentHalSpecificData, json_object *mixerResponseJ)
{
int err = (int) MIXER_NO_ERROR;
json_object *mixerStreamsJ = NULL, *mixerPlaybacksJ = NULL, *mixerCapturesJ = NULL;
if(! apiHandle) {
- AFB_ApiError(apiHandle, "Can't get current hal api handle");
+ AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
return (int) MIXER_ERROR_API_UNAVAILABLE;
}
if(wrap_json_unpack(mixerResponseJ, "{s?:o s?:o s?:o}", "streams", &mixerStreamsJ, "playbacks", &mixerPlaybacksJ, "captures", &mixerCapturesJ)) {
- AFB_ApiError(apiHandle, "Can't get streams|playbacks|captures object in '%s'", json_object_get_string(mixerResponseJ));
+ AFB_API_ERROR(apiHandle, "Can't get streams|playbacks|captures object in '%s'", json_object_get_string(mixerResponseJ));
return (int) MIXER_ERROR_DATA_UNAVAILABLE;
}
if(mixerStreamsJ && (err += HalCtlsHandleMixerData(apiHandle, &currentHalSpecificData->ctlHalStreamsData, mixerStreamsJ, MIXER_DATA_STREAMS)))
- AFB_ApiError(apiHandle, "Error during handling response mixer streams data '%s'", json_object_get_string(mixerStreamsJ));
+ AFB_API_ERROR(apiHandle, "Error during handling response mixer streams data '%s'", json_object_get_string(mixerStreamsJ));
if(mixerPlaybacksJ && (err += HalCtlsHandleMixerData(apiHandle, &currentHalSpecificData->ctlHalPlaybacksData, mixerPlaybacksJ, MIXER_DATA_PLAYBACKS)))
- AFB_ApiError(apiHandle, "Error during handling response mixer playbacks data '%s'", json_object_get_string(mixerPlaybacksJ));
+ AFB_API_ERROR(apiHandle, "Error during handling response mixer playbacks data '%s'", json_object_get_string(mixerPlaybacksJ));
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));
+ AFB_API_ERROR(apiHandle, "Error during handling response mixer captures data '%s'", json_object_get_string(mixerCapturesJ));
if(! currentHalSpecificData->ctlHalStreamsData) {
- AFB_ApiWarning(apiHandle, "No stream detected in mixer response, %s verb won't be created", HAL_ALL_STREAMS_VERB);
+ AFB_API_WARNING(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",
- HalUtlActionOnAllStream,
- (void *) currentHalSpecificData->ctlHalStreamsData,
- NULL,
- 0,
- 0)) {
- AFB_ApiError(apiHandle, "Error while creating verb for all streams : '%s'", HAL_ALL_STREAMS_VERB);
+ else if(afb_api_add_verb(apiHandle,
+ HAL_ALL_STREAMS_VERB,
+ "Send a stream action on all streams",
+ HalUtlActionOnAllStream,
+ (void *) currentHalSpecificData->ctlHalStreamsData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_API_ERROR(apiHandle, "Error while creating verb for all streams : '%s'", HAL_ALL_STREAMS_VERB);
return (int) MIXER_ERROR_ALL_STREAMS_VERB_NOT_CREATED;
}
return err;
}
-int HalCtlsAttachToMixer(AFB_ApiT apiHandle)
+int HalCtlsAttachToMixer(afb_api_t apiHandle)
{
int err = 0, mixerError;
@@ -215,29 +215,27 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle)
json_object *returnJ = NULL, *toReturnJ;
if(! apiHandle) {
- AFB_ApiError(apiHandle, "Can't get current hal api handle");
+ AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
return -1;
}
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig) {
- AFB_ApiError(apiHandle, "Can't get current hal controller config");
+ if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) {
+ AFB_API_ERROR(apiHandle, "Can't get current hal controller config");
return -2;
}
- currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
- if(! currentCtlHalData) {
- AFB_ApiError(apiHandle, "Can't get current hal controller data");
+ if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) {
+ AFB_API_ERROR(apiHandle, "Can't get current hal controller data");
return -3;
}
switch(currentCtlHalData->status) {
case HAL_STATUS_UNAVAILABLE:
- AFB_ApiError(apiHandle, "Seems that the hal corresponding card was not found by alsacore at startup");
+ AFB_API_ERROR(apiHandle, "Seems that the hal corresponding card was not found by alsacore at startup");
return -4;
case HAL_STATUS_READY:
- AFB_ApiNotice(apiHandle, "Seems that the hal mixer is already initialized");
+ AFB_API_NOTICE(apiHandle, "Seems that the hal mixer is already initialized");
return 1;
case HAL_STATUS_AVAILABLE:
@@ -246,54 +244,53 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle)
firstHalData = HalMngGetFirstHalData();
if((concurentHalData = HalUtlSearchReadyHalDataByCarId(firstHalData, currentCtlHalData->sndCardId))) {
- AFB_ApiError(apiHandle,
- "Trying to attach mixer for hal '%s' but the alsa device %i is already in use with mixer by hal '%s'",
- currentCtlHalData->apiName,
- currentCtlHalData->sndCardId,
- concurentHalData->apiName);
+ AFB_API_ERROR(apiHandle,
+ "Trying to attach mixer for hal '%s' but the alsa device %i is already in use with mixer by hal '%s'",
+ currentCtlHalData->apiName,
+ currentCtlHalData->sndCardId,
+ concurentHalData->apiName);
return -5;
}
- apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName;
- if(! apiToCall) {
- AFB_ApiError(apiHandle, "Can't get mixer api");
+ if(! (apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName)) {
+ AFB_API_ERROR(apiHandle, "Can't get mixer api");
return -6;
}
- if(AFB_ServiceSync(apiHandle, apiToCall, MIXER_ATTACH_VERB, json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), &returnJ)) {
+ if(afb_api_call_sync_legacy(apiHandle, apiToCall, MIXER_ATTACH_VERB, json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), &returnJ)) {
returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_ATTACH_VERB, returnJ, &returnedStatus, &returnedInfo);
- AFB_ApiError(apiHandle,
- "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
- (int) returnedError,
- MIXER_ATTACH_VERB,
- apiToCall,
- returnedStatus ? returnedStatus : "not returned",
- returnedInfo ? returnedInfo : "not returned");
+ AFB_API_ERROR(apiHandle,
+ "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
+ (int) returnedError,
+ MIXER_ATTACH_VERB,
+ apiToCall,
+ returnedStatus ? returnedStatus : "not returned",
+ returnedInfo ? returnedInfo : "not returned");
err = -7;
}
else if(! json_object_object_get_ex(returnJ, "response", &toReturnJ)) {
- AFB_ApiError(apiHandle,
- "Seems that %s call to api %s succeed, but response is not valid : '%s'",
- MIXER_ATTACH_VERB,
- apiToCall,
- json_object_get_string(returnJ));
+ AFB_API_ERROR(apiHandle,
+ "Seems that %s call to api %s succeed, but response is not valid : '%s'",
+ MIXER_ATTACH_VERB,
+ apiToCall,
+ json_object_get_string(returnJ));
err = -8;
}
else if((mixerError = HalCtlsHandleMixerAttachResponse(apiHandle, currentCtlHalData->ctlHalSpecificData, toReturnJ)) != (int) MIXER_NO_ERROR) {
- AFB_ApiError(apiHandle,
- "Seems that %s call to api %s succeed but this warning was risen by response decoder : %i '%s'",
- MIXER_ATTACH_VERB,
- apiToCall,
- mixerError,
- json_object_get_string(toReturnJ));
- err = -9;
- }
- else {
- AFB_ApiNotice(apiHandle,
- "Seems that %s call to api %s succeed with no warning raised : '%s'",
+ AFB_API_ERROR(apiHandle,
+ "Seems that %s call to api %s succeed but this warning was risen by response decoder : %i '%s'",
MIXER_ATTACH_VERB,
apiToCall,
+ mixerError,
json_object_get_string(toReturnJ));
+ err = -9;
+ }
+ else {
+ AFB_API_NOTICE(apiHandle,
+ "Seems that %s call to api %s succeed with no warning raised : '%s'",
+ MIXER_ATTACH_VERB,
+ apiToCall,
+ json_object_get_string(toReturnJ));
currentCtlHalData->status = HAL_STATUS_READY;
}
@@ -304,7 +301,12 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle)
return err;
}
-int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ, char **returnedStatus, char **returnedInfo)
+int HalCtlsGetInfoFromMixer(afb_api_t apiHandle,
+ char *apiToCall,
+ json_object *requestJson,
+ json_object **toReturnJ,
+ char **returnedStatus,
+ char **returnedInfo)
{
int err = 0;
@@ -313,45 +315,45 @@ int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *re
json_object *returnJ, *responseJ;
if(! apiHandle) {
- AFB_ApiError(apiHandle, "Can't get current hal api handle");
+ AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
return -1;
}
if(! apiToCall) {
- AFB_ApiError(apiHandle, "Can't get mixer api");
+ AFB_API_ERROR(apiHandle, "Can't get mixer api");
return -2;
}
if(! requestJson) {
- AFB_ApiError(apiHandle, "Can't get request json");
+ AFB_API_ERROR(apiHandle, "Can't get request json");
return -3;
}
- if(AFB_ServiceSync(apiHandle, apiToCall, MIXER_INFO_VERB, json_object_get(requestJson), &returnJ)) {
+ if(afb_api_call_sync_legacy(apiHandle, apiToCall, MIXER_INFO_VERB, json_object_get(requestJson), &returnJ)) {
returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_INFO_VERB, returnJ, returnedStatus, returnedInfo);
- AFB_ApiError(apiHandle,
- "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
- (int) returnedError,
- apiToCall,
- MIXER_INFO_VERB,
- *returnedStatus ? *returnedStatus : "not returned",
- *returnedInfo ? *returnedInfo : "not returned");
+ AFB_API_ERROR(apiHandle,
+ "Error %i during call to verb %s of %s api with status '%s' and info '%s'",
+ (int) returnedError,
+ apiToCall,
+ MIXER_INFO_VERB,
+ *returnedStatus ? *returnedStatus : "not returned",
+ *returnedInfo ? *returnedInfo : "not returned");
err = -4;
}
else if(! json_object_object_get_ex(returnJ, "response", &responseJ)) {
- AFB_ApiError(apiHandle,
- "Seems that %s call to api %s succeed, but response is not valid : '%s'",
- MIXER_INFO_VERB,
- apiToCall,
- json_object_get_string(returnJ));
+ AFB_API_ERROR(apiHandle,
+ "Seems that %s call to api %s succeed, but response is not valid : '%s'",
+ MIXER_INFO_VERB,
+ apiToCall,
+ json_object_get_string(returnJ));
err = -5;
}
else {
- AFB_ApiNotice(apiHandle,
- "Seems that %s call to api %s succeed with no warning raised : '%s'",
- MIXER_INFO_VERB,
- apiToCall,
- json_object_get_string(responseJ));
+ AFB_API_NOTICE(apiHandle,
+ "Seems that %s call to api %s succeed with no warning raised : '%s'",
+ MIXER_INFO_VERB,
+ apiToCall,
+ json_object_get_string(responseJ));
*toReturnJ = json_object_get(responseJ);
}