diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-01-21 17:07:36 +0100 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-01-28 15:38:58 +0100 |
commit | 756f8d02b445631df44243d528165fb1fe414487 (patch) | |
tree | 1ef835068d6cf24f33eeb0a0a136865a23a1884e /4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c | |
parent | 524ad81cd52d52555d0e6cbaf865f6bb6cfecb25 (diff) |
Move from controller functions to afb functions
Move from controller 'afb-definitions.h' functions to
application framework 'afb/afb-binding.h' functions.
Change-Id: I4cd62af881ef8ac949b082ede9dfcc4736d1e12c
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c')
-rw-r--r-- | 4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c | 307 |
1 files changed, 151 insertions, 156 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c index f1f99a6..5fadd36 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c @@ -24,7 +24,7 @@ #include <alsa/asoundlib.h> -#include <afb-definitions.h> +#include <afb/afb-binding.h> #include <ctl-config.h> @@ -70,7 +70,7 @@ snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label) * HAL controllers alsacore calls funtions * ******************************************************************************/ -int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath) +int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath) { int cardId = -1; @@ -81,37 +81,37 @@ int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath) json_object *toSendJ, *returnJ = NULL, *responsJ, *devidJ; if(! apiHandle) { - AFB_ApiError(apiHandle, "Api handle not available"); + AFB_API_ERROR(apiHandle, "Api handle not available"); return -1; } if(! devPath) { - AFB_ApiError(apiHandle, "Dev path is not available"); + AFB_API_ERROR(apiHandle, "Dev path is not available"); return -2; } wrap_json_pack(&toSendJ, "{s:s}", "devpath", devPath); - if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_GETINFO_VERB, toSendJ, &returnJ)) { + if(afb_api_call_sync_legacy(apiHandle, ALSACORE_API, ALSACORE_GETINFO_VERB, toSendJ, &returnJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_GETINFO_VERB, returnJ, &returnedStatus, &returnedInfo); - AFB_ApiWarning(apiHandle, - "Error %i during call to verb %s of %s api with status '%s' and info '%s'", - (int) returnedError, - ALSACORE_GETINFO_VERB, - ALSACORE_API, - returnedStatus ? returnedStatus : "not returned", - returnedInfo ? returnedInfo : "not returned"); + AFB_API_WARNING(apiHandle, + "Error %i during call to verb %s of %s api with status '%s' and info '%s'", + (int) returnedError, + ALSACORE_GETINFO_VERB, + ALSACORE_API, + returnedStatus ? returnedStatus : "not returned", + returnedInfo ? returnedInfo : "not returned"); } else if(json_object_object_get_ex(returnJ, "response", &responsJ)) { if(json_object_object_get_ex(responsJ, "devid", &devidJ) && json_object_is_type(devidJ, json_type_string)) { cardIdString = (char *) json_object_get_string(devidJ); if(sscanf(cardIdString, "hw:%i", &cardId) <= 0) { - AFB_ApiWarning(apiHandle, "Couldn't get valid devid from string: '%s'", cardIdString); + AFB_API_WARNING(apiHandle, "Couldn't get valid devid from string: '%s'", cardIdString); cardId = -2; } } else { - AFB_ApiWarning(apiHandle, "Response devid is not present/valid"); + AFB_API_WARNING(apiHandle, "Response devid is not present/valid"); } } @@ -121,7 +121,7 @@ int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath) return cardId; } -int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId) +int HalCtlsSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId) { int err = 0; @@ -132,23 +132,23 @@ int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId) json_object *subscribeQueryJ, *returnedJ = NULL, *returnedWarningJ; wrap_json_pack(&subscribeQueryJ, "{s:s}", "devid", cardId); - if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_SUBSCRIBE_VERB, subscribeQueryJ, &returnedJ)) { + if(afb_api_call_sync_legacy(apiHandle, ALSACORE_API, ALSACORE_SUBSCRIBE_VERB, subscribeQueryJ, &returnedJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_SUBSCRIBE_VERB, returnedJ, &returnedStatus, &returnedInfo); - AFB_ApiError(apiHandle, - "Error %i during call to verb %s of %s api with status '%s' and info '%s'", - (int) returnedError, - ALSACORE_SUBSCRIBE_VERB, - ALSACORE_API, - 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, + ALSACORE_SUBSCRIBE_VERB, + ALSACORE_API, + returnedStatus ? returnedStatus : "not returned", + returnedInfo ? returnedInfo : "not returned"); err = -1; } else if(! wrap_json_unpack(returnedJ, "{s:{s:o}}", "request", "info", &returnedWarningJ)) { - AFB_ApiError(apiHandle, - "Warning raised during call to verb %s of %s api : '%s'", - ALSACORE_SUBSCRIBE_VERB, - ALSACORE_API, - json_object_get_string(returnedWarningJ)); + AFB_API_ERROR(apiHandle, + "Warning raised during call to verb %s of %s api : '%s'", + ALSACORE_SUBSCRIBE_VERB, + ALSACORE_API, + json_object_get_string(returnedWarningJ)); err = -2; } @@ -158,7 +158,7 @@ int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId) return err; } -int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedDataJ) +int HalCtlsGetAlsaCtlInfo(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedDataJ) { int err = 0; @@ -171,22 +171,22 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *returnedDataJ = NULL; if(! apiHandle) { - AFB_ApiError(apiHandle, "Api handle not available"); + AFB_API_ERROR(apiHandle, "Api handle not available"); return -1; } if(! cardId) { - AFB_ApiError(apiHandle, "Card id is not available"); + AFB_API_ERROR(apiHandle, "Card id is not available"); return -2; } if(! currentAlsaCtl) { - AFB_ApiError(apiHandle, "Alsa control data structure is not available"); + AFB_API_ERROR(apiHandle, "Alsa control data structure is not available"); return -3; } if(currentAlsaCtl->name && currentAlsaCtl->numid > 0) { - AFB_ApiDebug(apiHandle, + AFB_API_DEBUG(apiHandle, "Both a control name (%s) and a control uid (%i) are specified, control uid will be used", currentAlsaCtl->name, currentAlsaCtl->numid); @@ -199,27 +199,27 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl wrap_json_pack(&queryJ, "{s:s s:s s:i}", "devid", cardId, "ctl", currentAlsaCtl->name, "mode", 3); } else { - AFB_ApiError(apiHandle, "Need at least a control name or a control uid"); + AFB_API_ERROR(apiHandle, "Need at least a control name or a control id"); return -4; } - if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_CTLGET_VERB, queryJ, &returnedJ)) { + if(afb_api_call_sync_legacy(apiHandle, ALSACORE_API, ALSACORE_CTLGET_VERB, queryJ, &returnedJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_CTLGET_VERB, returnedJ, &returnedStatus, &returnedInfo); - AFB_ApiError(apiHandle, - "Error %i during call to verb %s of %s api with status '%s' and info '%s'", - (int) returnedError, - ALSACORE_CTLGET_VERB, - ALSACORE_API, - 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, + ALSACORE_CTLGET_VERB, + ALSACORE_API, + returnedStatus ? returnedStatus : "not returned", + returnedInfo ? returnedInfo : "not returned"); return -5; } else if(currentAlsaCtl->name && wrap_json_unpack(returnedJ, "{s:{s:i}}", "response", "id", ¤tAlsaCtl->numid)) { - AFB_ApiError(apiHandle, "Can't find alsa control 'id' from control 'name': '%s' on device '%s'", currentAlsaCtl->name, cardId); + AFB_API_ERROR(apiHandle, "Can't find alsa control 'id' from control 'name': '%s' on device '%s'", currentAlsaCtl->name, cardId); err = -6; } else if(! json_object_object_get_ex(returnedJ, "response", NULL)) { - AFB_ApiError(apiHandle, "Can't find alsa control 'id': %i on device '%s'", currentAlsaCtl->numid, cardId); + AFB_API_ERROR(apiHandle, "Can't find alsa control 'id': %i on device '%s'", currentAlsaCtl->numid, cardId); err = -7; } @@ -231,7 +231,7 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl return err; } -int HalCtlsUpdateAlsaCtlProperties(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl) +int HalCtlsUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl) { int err = 0; @@ -250,11 +250,11 @@ int HalCtlsUpdateAlsaCtlProperties(AFB_ApiT apiHandle, char *cardId, struct CtlH "min", ¤tAlsaCtl->alsaCtlProperties.minval, "max", ¤tAlsaCtl->alsaCtlProperties.maxval, "step", ¤tAlsaCtl->alsaCtlProperties.step)) { - AFB_ApiError(apiHandle, - "Didn't succeed to get control %i properties on device '%s' : '%s'", - currentAlsaCtl->numid, - cardId, - json_object_get_string(returnedDataJ)); + AFB_API_ERROR(apiHandle, + "Didn't succeed to get control %i properties on device '%s' : '%s'", + currentAlsaCtl->numid, + cardId, + json_object_get_string(returnedDataJ)); err = -8; } @@ -265,7 +265,7 @@ int HalCtlsUpdateAlsaCtlProperties(AFB_ApiT apiHandle, char *cardId, struct CtlH return err; } -int HalCtlsGetAlsaCtlValues(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedValuesJ) +int HalCtlsGetAlsaCtlValues(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl, json_object **returnedValuesJ) { int err = 0; @@ -277,20 +277,20 @@ int HalCtlsGetAlsaCtlValues(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaC return err; } else if(wrap_json_unpack(returnedDataJ, "{s:{s:o}}", "response", "val", &returnedValuesArrayJ)) { - AFB_ApiError(apiHandle, - "Didn't succeed to get control %i values on device '%s' : '%s'", - currentAlsaCtl->numid, - cardId, - json_object_get_string(returnedValuesArrayJ)); + AFB_API_ERROR(apiHandle, + "Didn't succeed to get control %i values on device '%s' : '%s'", + currentAlsaCtl->numid, + cardId, + json_object_get_string(returnedValuesArrayJ)); err = -8; } else if(! json_object_is_type(returnedValuesArrayJ, json_type_array)) { - AFB_ApiError(apiHandle, - "Json returned by control %i values on device '%s' are not an array ('%s')", - currentAlsaCtl->numid, - cardId, - json_object_get_string(returnedValuesArrayJ)); + AFB_API_ERROR(apiHandle, + "Json returned by control %i values on device '%s' are not an array ('%s')", + currentAlsaCtl->numid, + cardId, + json_object_get_string(returnedValuesArrayJ)); err = -9; } @@ -304,7 +304,7 @@ int HalCtlsGetAlsaCtlValues(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaC return err; } -int HalCtlsSetAlsaCtlValue(AFB_ApiT apiHandle, char *cardId, int ctlId, json_object *valuesJ) +int HalCtlsSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ) { int err = 0; @@ -315,44 +315,44 @@ int HalCtlsSetAlsaCtlValue(AFB_ApiT apiHandle, char *cardId, int ctlId, json_obj json_object *queryJ, *returnedJ = NULL, *returnedWarningJ; if(! apiHandle) { - AFB_ApiError(apiHandle, "Api handle not available"); + AFB_API_ERROR(apiHandle, "Api handle not available"); return -1; } if(! cardId) { - AFB_ApiError(apiHandle, "Card id is not available"); + AFB_API_ERROR(apiHandle, "Card id is not available"); return -2; } if(ctlId <= 0) { - AFB_ApiError(apiHandle, "Alsa control id is not valid"); + AFB_API_ERROR(apiHandle, "Alsa control id is not valid"); return -3; } if(! valuesJ) { - AFB_ApiError(apiHandle, "Values to set json is not available"); + AFB_API_ERROR(apiHandle, "Values to set json is not available"); return -4; } wrap_json_pack(&queryJ, "{s:s s:{s:i s:o}}", "devid", cardId, "ctl", "id", ctlId, "val", json_object_get(valuesJ)); - if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_CTLSET_VERB, queryJ, &returnedJ)) { + if(afb_api_call_sync_legacy(apiHandle, ALSACORE_API, ALSACORE_CTLSET_VERB, queryJ, &returnedJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_CTLSET_VERB, returnedJ, &returnedStatus, &returnedInfo); - AFB_ApiError(apiHandle, - "Error %i during call to verb %s of %s api with status '%s' and info '%s'", - (int) returnedError, - ALSACORE_CTLSET_VERB, - ALSACORE_API, - 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, + ALSACORE_CTLSET_VERB, + ALSACORE_API, + returnedStatus ? returnedStatus : "not returned", + returnedInfo ? returnedInfo : "not returned"); err = 1; } else if(! wrap_json_unpack(returnedJ, "{s:{s:o}}", "request", "info", &returnedWarningJ)) { - AFB_ApiError(apiHandle, - "Warning raised during call to verb %s of %s api : '%s'", - ALSACORE_CTLSET_VERB, - ALSACORE_API, - json_object_get_string(returnedWarningJ)); + AFB_API_ERROR(apiHandle, + "Warning raised during call to verb %s of %s api : '%s'", + ALSACORE_CTLSET_VERB, + ALSACORE_API, + json_object_get_string(returnedWarningJ)); err = 2; } @@ -362,7 +362,7 @@ int HalCtlsSetAlsaCtlValue(AFB_ApiT apiHandle, char *cardId, int ctlId, json_obj return err; } -int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate) +int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate) { int err = 0; @@ -373,22 +373,22 @@ int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl json_object *queryJ, *returnedJ = NULL, *returnedWarningJ, *responseJ; if(! apiHandle) { - AFB_ApiError(apiHandle, "Api handle not available"); + AFB_API_ERROR(apiHandle, "Api handle not available"); return -1; } if(! cardId) { - AFB_ApiError(apiHandle, "Card id is not available"); + AFB_API_ERROR(apiHandle, "Card id is not available"); return -2; } if(! alsaCtlToCreate) { - AFB_ApiError(apiHandle, "Alsa control data structure is not available"); + AFB_API_ERROR(apiHandle, "Alsa control data structure is not available"); return -3; } if(! alsaCtlToCreate->alsaCtlCreation) { - AFB_ApiError(apiHandle, "Alsa control data for creation structure is not available"); + AFB_API_ERROR(apiHandle, "Alsa control data for creation structure is not available"); return -4; } @@ -403,42 +403,42 @@ int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl "type", (int) alsaCtlToCreate->alsaCtlCreation->type, "count", alsaCtlToCreate->alsaCtlCreation->count); - if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, queryJ, &returnedJ)) { + if(afb_api_call_sync_legacy(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, queryJ, &returnedJ)) { returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, returnedJ, &returnedStatus, &returnedInfo); - AFB_ApiError(apiHandle, - "Error %i during call to verb %s of %s api with status '%s' and info '%s'", - (int) returnedError, - ALSACORE_GETINFO_VERB, - ALSACORE_API, - 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, + ALSACORE_GETINFO_VERB, + ALSACORE_API, + returnedStatus ? returnedStatus : "not returned", + returnedInfo ? returnedInfo : "not returned"); err = -5; } else if(! wrap_json_unpack(returnedJ, "{s:{s:o}}", "request", "info", &returnedWarningJ)) { - AFB_ApiError(apiHandle, - "Warning raised during call to verb %s of %s api : '%s'", - ALSACORE_GETINFO_VERB, - ALSACORE_API, - json_object_get_string(returnedWarningJ)); + AFB_API_ERROR(apiHandle, + "Warning raised during call to verb %s of %s api : '%s'", + ALSACORE_GETINFO_VERB, + ALSACORE_API, + json_object_get_string(returnedWarningJ)); err = -6; } else if(wrap_json_unpack(returnedJ, "{s:o}", "response", &responseJ)) { - AFB_ApiError(apiHandle, - "Can't get response of call to verb %s of %s api : %s", - ALSACORE_GETINFO_VERB, - ALSACORE_API, - json_object_get_string(returnedJ)); + AFB_API_ERROR(apiHandle, + "Can't get response of call to verb %s of %s api : %s", + ALSACORE_GETINFO_VERB, + ALSACORE_API, + json_object_get_string(returnedJ)); err = -7; } else if(wrap_json_unpack(responseJ, "{s:i}", "id", &alsaCtlToCreate->numid)) { - AFB_ApiError(apiHandle, - "Can't get create id from %s of %s api", - ALSACORE_GETINFO_VERB, - ALSACORE_API); + AFB_API_ERROR(apiHandle, + "Can't get create id from %s of %s api", + ALSACORE_GETINFO_VERB, + ALSACORE_API); err = -8; } else if(wrap_json_unpack(responseJ, "{s:o}", "ctl", NULL)) { - AFB_ApiWarning(apiHandle, "Control %s was already present but has been updated", alsaCtlToCreate->name); + AFB_API_WARNING(apiHandle, "Control %s was already present but has been updated", alsaCtlToCreate->name); } if(returnedJ) @@ -451,11 +451,11 @@ int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl * HAL controllers alsacore controls request callback * ******************************************************************************/ -void HalCtlsActionOnAlsaCtl(AFB_ReqT request) +void HalCtlsActionOnAlsaCtl(afb_req_t request) { char cardIdString[6]; - AFB_ApiT apiHandle; + afb_api_t apiHandle; CtlConfigT *ctrlConfig; @@ -471,44 +471,40 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) *appliedControlValuesJ, *normalizedAppliedControlValuesJ; - apiHandle = (AFB_ApiT) AFB_ReqGetApi(request); - if(! apiHandle) { - AFB_ReqFail(request, "api_handle", "Can't get current hal controller api handle"); + if(! (apiHandle = afb_req_get_api(request))) { + afb_req_fail(request, "api_handle", "Can't get current hal controller api handle"); return; } - ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle); - if(! ctrlConfig) { - AFB_ReqFail(request, "hal_controller_config", "Can't get current hal controller config"); + if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) { + afb_req_fail(request, "hal_controller_config", "Can't get current hal controller config"); return; } - currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig); - if(! currentCtlHalData) { - AFB_ReqFail(request, "hal_controller_data", "Can't get current hal controller data"); + if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { + afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); return; } if(currentCtlHalData->status == HAL_STATUS_UNAVAILABLE) { - AFB_ReqFail(request, "hal_unavailable", "Seems that hal is not available"); + afb_req_fail(request, "hal_unavailable", "Seems that hal is not available"); return; } - currentAlsaCtl = (struct CtlHalAlsaMap *) AFB_ReqVCBData(request); - if(! currentAlsaCtl) { - AFB_ReqFail(request, "alsa_control_data", "Can't get current alsa control data"); + if(! (currentAlsaCtl = (struct CtlHalAlsaMap *) afb_req_get_vcbdata(request))) { + afb_req_fail(request, "alsa_control_data", "Can't get current alsa control data"); return; } if(currentAlsaCtl->ctl.numid <= 0) { - AFB_ReqFail(request, "alsa_control_id", "Alsa control id is not valid"); + afb_req_fail(request, "alsa_control_id", "Alsa control id is not valid"); return; } snprintf(cardIdString, 6, "hw:%i", currentCtlHalData->sndCardId); if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &previousControlValuesJ)) { - AFB_ReqFailF(request, "previous_values", "Error when trying to get unchanged alsa control values"); + afb_req_fail_f(request, "previous_values", "Error when trying to get unchanged alsa control values"); return; } else if(HalCtlsConvertJsonValues(apiHandle, @@ -516,35 +512,34 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) previousControlValuesJ, &normalizedPreviousControlValuesJ, CONVERSION_ALSACORE_TO_NORMALIZED)) { - AFB_ReqFailF(request, - "request_json", - "Error when trying to normalize unchanged alsa control values json '%s'", - json_object_get_string(previousControlValuesJ)); + afb_req_fail_f(request, + "request_json", + "Error when trying to normalize unchanged alsa control values json '%s'", + json_object_get_string(previousControlValuesJ)); json_object_put(previousControlValuesJ); return; } - requestJson = AFB_ReqJson(request); - if(! requestJson) { + if(! (requestJson = afb_req_json(request))) { wrap_json_pack(&answerJ, "{s:o}", "current", normalizedPreviousControlValuesJ); - AFB_ReqSuccess(request, answerJ, "Current controls values"); + afb_req_success(request, answerJ, "Current controls values"); json_object_put(previousControlValuesJ); return; } if(! json_object_is_type(requestJson, json_type_object)) { - AFB_ReqFailF(request, "request_json", "Request json is not valid '%s'", json_object_get_string(requestJson)); + afb_req_fail_f(request, "request_json", "Request json is not valid '%s'", json_object_get_string(requestJson)); json_object_put(previousControlValuesJ); json_object_put(normalizedPreviousControlValuesJ); return; } if(wrap_json_unpack(requestJson, "{s:o}", "value", &valueJ)) { - AFB_ReqFailF(request, - "request_json", "Error when trying to get request value object inside request '%s'", - json_object_get_string(requestJson)); + afb_req_fail_f(request, + "request_json", "Error when trying to get request value object inside request '%s'", + json_object_get_string(requestJson)); json_object_put(previousControlValuesJ); json_object_put(normalizedPreviousControlValuesJ); return; @@ -556,10 +551,10 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) valueJ, &convertedJ, CONVERSION_NORMALIZED_TO_ALSACORE)) { - AFB_ReqFailF(request, - "request_json", - "Error when trying to convert request values '%s'", - json_object_get_string(valueJ)); + afb_req_fail_f(request, + "request_json", + "Error when trying to convert request values '%s'", + json_object_get_string(valueJ)); json_object_put(previousControlValuesJ); json_object_put(normalizedPreviousControlValuesJ); return; @@ -570,11 +565,11 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) valueJ, previousControlValuesJ, &convertedJ)) { - AFB_ReqFailF(request, - "previous_values", - "Error when trying to generate changed alsa control values (values : '%s', previous :'%s')", - json_object_get_string(valueJ), - json_object_get_string(previousControlValuesJ)); + afb_req_fail_f(request, + "previous_values", + "Error when trying to generate changed alsa control values (values : '%s', previous :'%s')", + json_object_get_string(valueJ), + json_object_get_string(previousControlValuesJ)); json_object_put(previousControlValuesJ); json_object_put(normalizedPreviousControlValuesJ); return; @@ -583,12 +578,12 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) json_object_put(previousControlValuesJ); if(HalCtlsSetAlsaCtlValue(apiHandle, cardIdString, currentAlsaCtl->ctl.numid, convertedJ)) { - AFB_ReqFailF(request, - "alsa_control_call_error", - "Error while trying to set value on alsa control %i, device '%s', converted message '%s'", - currentAlsaCtl->ctl.numid, - cardIdString, - json_object_get_string(convertedJ)); + afb_req_fail_f(request, + "alsa_control_call_error", + "Error while trying to set value on alsa control %i, device '%s', converted message '%s'", + currentAlsaCtl->ctl.numid, + cardIdString, + json_object_get_string(convertedJ)); json_object_put(convertedJ); json_object_put(normalizedPreviousControlValuesJ); return; @@ -597,7 +592,7 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) json_object_put(convertedJ); if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, ¤tAlsaCtl->ctl, &appliedControlValuesJ)) { - AFB_ReqFailF(request, "applied_values", "Error when trying to get applied alsa control values"); + afb_req_fail_f(request, "applied_values", "Error when trying to get applied alsa control values"); json_object_put(normalizedPreviousControlValuesJ); return; } @@ -606,10 +601,10 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) appliedControlValuesJ, &normalizedAppliedControlValuesJ, CONVERSION_ALSACORE_TO_NORMALIZED)) { - AFB_ReqFailF(request, - "request_json", - "Error when trying to normalize applied values json '%s'", - json_object_get_string(appliedControlValuesJ)); + afb_req_fail_f(request, + "request_json", + "Error when trying to normalize applied values json '%s'", + json_object_get_string(appliedControlValuesJ)); json_object_put(normalizedPreviousControlValuesJ); json_object_put(appliedControlValuesJ); return; @@ -622,5 +617,5 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request) "previous", normalizedPreviousControlValuesJ, "current", normalizedAppliedControlValuesJ); - AFB_ReqSuccess(request, answerJ, "Values correctly applied on alsa control"); + afb_req_success(request, answerJ, "Values correctly applied on alsa control"); }
\ No newline at end of file |