summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-21 17:07:36 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:58 +0100
commit756f8d02b445631df44243d528165fb1fe414487 (patch)
tree1ef835068d6cf24f33eeb0a0a136865a23a1884e /4a-hal/4a-hal-controllers
parent524ad81cd52d52555d0e6cbaf865f6bb6cfecb25 (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')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c307
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h14
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c42
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h6
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c342
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h14
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c214
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h11
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c138
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h6
10 files changed, 543 insertions, 551 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", &currentAlsaCtl->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", &currentAlsaCtl->alsaCtlProperties.minval,
"max", &currentAlsaCtl->alsaCtlProperties.maxval,
"step", &currentAlsaCtl->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, &currentAlsaCtl->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, &currentAlsaCtl->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
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
index 351ad59..5081b49 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
@@ -24,6 +24,8 @@
#include <alsa/asoundlib.h>
+#include <afb/afb-binding.h>
+
#include <ctl-config.h>
#include "4a-hal-utilities-alsa-data.h"
@@ -39,13 +41,13 @@
snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label);
// HAL controllers alsacore calls funtions
-int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath);
-int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId);
-int HalCtlsUpdateAlsaCtlProperties(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl);
-int HalCtlsSetAlsaCtlValue(AFB_ApiT apiHandle, char *cardId, int ctlId, json_object *valuesJ);
-int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate);
+int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath);
+int HalCtlsSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId);
+int HalCtlsUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *currentAlsaCtl);
+int HalCtlsSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ);
+int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl *alsaCtlToCreate);
// HAL controllers alsacore controls request callback
-void HalCtlsActionOnAlsaCtl(AFB_ReqT request);
+void HalCtlsActionOnAlsaCtl(afb_req_t request);
#endif /* _HAL_CTLS_ALSACORE_LINK_INCLUDE_ */ \ No newline at end of file
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 0691cb5..4a1ca8f 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
@@ -23,7 +23,7 @@
#include <filescan-utils.h>
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -35,7 +35,7 @@
#include "4a-hal-controllers-mixer-link.h"
// Default api to print log when apihandle not available
-AFB_ApiT AFB_default;
+afb_api_t AFB_default;
/*******************************************************************************
* Json parsing functions using app controller *
@@ -58,7 +58,7 @@ static CtlSectionT ctrlSectionsDefault[] =
******************************************************************************/
// Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT
-static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
+static afb_verb_t CtlHalApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures/controls for this api" },
@@ -71,7 +71,7 @@ static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
* Dynamic API functions for app controller *
******************************************************************************/
-static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
+static int HalCtlsInitOneApi(afb_api_t apiHandle)
{
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -83,8 +83,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
AFB_default = apiHandle;
// Retrieve section config from api handle
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig)
+ if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle)))
return -2;
currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
@@ -106,8 +105,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath);
- currentCtlHalData->ctlHalSpecificData->streamUpdates = AFB_EventMake(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME);
- if(! AFB_EventIsValid(currentCtlHalData->ctlHalSpecificData->streamUpdates))
+ if(! (currentCtlHalData->ctlHalSpecificData->streamUpdates = afb_api_make_event(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME)))
return -4;
if(currentCtlHalData->sndCardId < 0)
@@ -120,7 +118,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
return CtlConfigExec(apiHandle, ctrlConfig);
}
-static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
+static int HalCtlsLoadOneApi(void *cbdata, afb_api_t apiHandle)
{
int err;
CtlConfigT *ctrlConfig;
@@ -132,11 +130,11 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
ctrlConfig = (CtlConfigT*) cbdata;
// Save closure as api's data context
- AFB_ApiSetUserData(apiHandle, ctrlConfig);
+ afb_api_set_userdata(apiHandle, ctrlConfig);
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, CtlHalApiStaticVerbs)) {
- AFB_ApiError(apiHandle, "Load Section : fail to register static V2 verbs");
+ AFB_API_ERROR(apiHandle, "Load Section : fail to register static V2 verbs");
return 1;
}
@@ -148,15 +146,15 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
return err;
// Declare an event manager for this Api
- AFB_ApiOnEvent(apiHandle, HalCtlsDispatchApiEvent);
+ afb_api_on_event(apiHandle, HalCtlsDispatchApiEvent);
// Init Api function (does not receive user closure ???)
- AFB_ApiOnInit(apiHandle, HalCtlsInitOneApi);
+ afb_api_on_init(apiHandle, HalCtlsInitOneApi);
return 0;
}
-int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData)
+int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrGlobalData)
{
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -167,12 +165,12 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
// Create one Api per file
ctrlConfig = CtlLoadMetaData(apiHandle, path);
if(! ctrlConfig) {
- AFB_ApiError(apiHandle, "No valid control config file in:\n-- %s", path);
+ AFB_API_ERROR(apiHandle, "No valid control config file in:\n-- %s", path);
return -2;
}
if(! ctrlConfig->api) {
- AFB_ApiError(apiHandle, "API Missing from metadata in:\n-- %s", path);
+ AFB_API_ERROR(apiHandle, "API Missing from metadata in:\n-- %s", path);
return -3;
}
@@ -189,14 +187,14 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
// Allocation of the structure that will be used to store specific hal controller data
currentCtlHalData->ctlHalSpecificData = calloc(1, sizeof(struct CtlHalSpecificData));
- // Create one API (Pre-V3 return code ToBeChanged)
- if(! AFB_NewApi(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig))
+ // Create one API
+ if(! afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig))
return -5;
return 0;
}
-int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData)
{
int index, status = 0;
char *dirList, *fileName, *fullPath;
@@ -212,7 +210,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
// Hugely hack to make all V2 AFB_DEBUG to work in fileutils
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Begining to create all APIs");
+ AFB_API_NOTICE(apiHandle, "Begining to create all APIs");
dirList = getenv("CONTROL_CONFIG_PATH");
if(! dirList)
@@ -220,7 +218,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
configJ = CtlConfigScan(dirList, "hal");
if(! configJ) {
- AFB_ApiWarning(apiHandle, "No hal-(binder-middle-name)*.json config file(s) found in %s, 4a-hal-manager will only works with external hal", dirList);
+ AFB_API_WARNING(apiHandle, "No hal-(binder-middle-name)*.json config file(s) found in %s, 4a-hal-manager will only works with external hal", dirList);
return 0;
}
@@ -229,7 +227,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
entryJ = json_object_array_get_idx(configJ, index);
if(wrap_json_unpack(entryJ, "{s:s, s:s !}", "fullpath", &fullPath, "filename", &fileName)) {
- AFB_ApiError(apiHandle, "HOOPs invalid JSON entry = %s", json_object_get_string(entryJ));
+ AFB_API_ERROR(apiHandle, "HOOPs invalid JSON entry = %s", json_object_get_string(entryJ));
return -2;
}
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
index f1d3bfd..dd33108 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
@@ -20,12 +20,12 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-data.h"
// Verbs that can be use to create api
-int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData);
-int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData);
+int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrGlobalData);
+int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData);
#endif /* _HAL_CTLS_API_LOADER_INCLUDE_ */ \ No newline at end of file
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 cfe921d..d648103 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-appfw-responses-handler.h"
@@ -36,7 +36,7 @@
* HAL controller event handler function *
******************************************************************************/
-void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ)
+void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ)
{
int numid, idx = 0, cardidx;
@@ -48,17 +48,15 @@ void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_obje
json_object *valuesJ, *normalizedValuesJ;
- AFB_ApiDebug(apiHandle, "Evtname=%s [msg=%s]", evtLabel, json_object_get_string(eventJ));
+ AFB_API_DEBUG(apiHandle, "Evtname=%s [msg=%s]", evtLabel, json_object_get_string(eventJ));
- 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;
}
- currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
- if(! currentHalData) {
- AFB_ApiWarning(apiHandle, "Can't get current hal controller data");
+ if(! (currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) {
+ AFB_API_WARNING(apiHandle, "Can't get current hal controller data");
return;
}
@@ -70,7 +68,7 @@ void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_obje
sscanf(&evtLabel[idx + 1], "%d", &cardidx) == 1 &&
currentHalData->sndCardId == cardidx) {
if(wrap_json_unpack(eventJ, "{s:i s:o !}", "id", &numid, "val", &valuesJ)) {
- AFB_ApiError(apiHandle, "Invalid Alsa Event label=%s value=%s", evtLabel, json_object_get_string(eventJ));
+ AFB_API_ERROR(apiHandle, "Invalid Alsa Event label=%s value=%s", evtLabel, json_object_get_string(eventJ));
return;
}
@@ -87,9 +85,9 @@ void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_obje
(void) ActionExecOne(&source, currentHalAlsaCtlsT->ctls[idx].action, valuesJ);
}
else {
- AFB_ApiNotice(apiHandle,
- "The alsa control id '%i' is corresponding to a known control but without any action registered",
- numid);
+ AFB_API_NOTICE(apiHandle,
+ "The alsa control id '%i' is corresponding to a known control but without any action registered",
+ numid);
}
if((! currentHalAlsaCtlsT->ctls[idx].alsaControlEvent) ||
@@ -98,29 +96,30 @@ void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_obje
valuesJ,
&normalizedValuesJ,
CONVERSION_ALSACORE_TO_NORMALIZED) ||
- (AFB_EventPush(currentHalAlsaCtlsT->ctls[idx].alsaControlEvent, normalizedValuesJ) < 0)) {
- AFB_ApiError(apiHandle,
- "Couldn't generate an event for known halmap %s (alsa control id %i)",
- currentHalAlsaCtlsT->ctls[idx].uid,
- currentHalAlsaCtlsT->ctls[idx].ctl.numid);
+ (afb_event_push(currentHalAlsaCtlsT->ctls[idx].alsaControlEvent, normalizedValuesJ) < 0)) {
+ AFB_API_ERROR(apiHandle,
+ "Couldn't generate an event for known halmap %s (alsa control id %i)",
+ currentHalAlsaCtlsT->ctls[idx].uid,
+ currentHalAlsaCtlsT->ctls[idx].ctl.numid);
}
return;
}
}
- AFB_ApiWarning(apiHandle, "Alsacore event with an unrecognized numid: %i, evtname=%s [msg=%s]",
- numid,
- evtLabel,
- json_object_get_string(eventJ));
+ AFB_API_WARNING(apiHandle,
+ "Alsacore event with an unrecognized numid: %i, evtname=%s [msg=%s]",
+ numid,
+ evtLabel,
+ json_object_get_string(eventJ));
return;
}
- AFB_ApiInfo(apiHandle,
- "Not an alsacore event '%s' [msg=%s]",
- evtLabel,
- json_object_get_string(eventJ));
+ AFB_API_INFO(apiHandle,
+ "Not an alsacore event '%s' [msg=%s]",
+ evtLabel,
+ json_object_get_string(eventJ));
CtrlDispatchApiEvent(apiHandle, evtLabel, eventJ);
}
@@ -129,7 +128,7 @@ void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_obje
* HAL controllers sections parsing functions *
******************************************************************************/
-int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *MixerJ)
+int HalCtlsHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ)
{
int err = 0;
@@ -139,12 +138,10 @@ int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object
if(! apiHandle || ! section)
return -1;
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig)
+ if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle)))
return -2;
- currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
- if(! currentHalData)
+ if(! (currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig)))
return -3;
if(MixerJ) {
@@ -160,27 +157,27 @@ int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object
}
else if(currentHalData->status == HAL_STATUS_AVAILABLE &&
(err = HalCtlsAttachToMixer(apiHandle))) {
- AFB_ApiError(apiHandle, "%s: Error %i while attaching to mixer", __func__, err);
+ AFB_API_ERROR(apiHandle, "%s: Error %i while attaching to mixer", __func__, err);
return -6;
}
return 0;
}
-int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsaMap, json_object *AlsaMapJ)
+int HalCtlsProcessOneHalMapObject(afb_api_t apiHandle, struct CtlHalAlsaMap *alsaMap, json_object *AlsaMapJ)
{
char *action = NULL, *typename = NULL;
json_object *alsaJ = NULL, *createAlsaCtlJ = NULL;
- AFB_ApiDebug(apiHandle, "AlsaMapJ=%s", json_object_get_string(AlsaMapJ));
+ AFB_API_DEBUG(apiHandle, "AlsaMapJ=%s", json_object_get_string(AlsaMapJ));
if(wrap_json_unpack(AlsaMapJ, "{s:s s?:s s:o s?:s !}",
"uid", &alsaMap->uid,
"info", &alsaMap->info,
"alsa", &alsaJ,
"action", &action)) {
- AFB_ApiError(apiHandle, "Parsing error, map should only contains [label]|[uid]|[tag]|[info]|[alsa]|[action] in:\n-- %s", json_object_get_string(AlsaMapJ));
+ AFB_API_ERROR(apiHandle, "Parsing error, map should only contains [label]|[uid]|[tag]|[info]|[alsa]|[action] in:\n-- %s", json_object_get_string(AlsaMapJ));
return -1;
}
@@ -189,7 +186,7 @@ int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsa
"numid", &alsaMap->ctl.numid,
"value", &alsaMap->ctl.value,
"create", &createAlsaCtlJ)) {
- AFB_ApiError(apiHandle, "Parsing error, alsa json should only contains [name]|[numid]||[value]|[create] in:\n-- %s", json_object_get_string(alsaJ));
+ AFB_API_ERROR(apiHandle, "Parsing error, alsa json should only contains [name]|[numid]||[value]|[create] in:\n-- %s", json_object_get_string(alsaJ));
return -2;
}
@@ -203,12 +200,12 @@ int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsa
"minval", &alsaMap->ctl.alsaCtlCreation->minval,
"maxval", &alsaMap->ctl.alsaCtlCreation->maxval,
"step", &alsaMap->ctl.alsaCtlCreation->step)) {
- AFB_ApiError(apiHandle, "Parsing error, alsa creation json should only contains [type]|[count]|[minval]|[maxval]|[step] in:\n-- %s", json_object_get_string(alsaJ));
+ AFB_API_ERROR(apiHandle, "Parsing error, alsa creation json should only contains [type]|[count]|[minval]|[maxval]|[step] in:\n-- %s", json_object_get_string(alsaJ));
return -3;
}
if(typename && (alsaMap->ctl.alsaCtlCreation->type = HalCtlsMapsAlsaTypeToEnum(typename)) == SND_CTL_ELEM_TYPE_NONE) {
- AFB_ApiError(apiHandle, "Couldn't get alsa type from string %s in:\n-- %s", typename, json_object_get_string(alsaJ));
+ AFB_API_ERROR(apiHandle, "Couldn't get alsa type from string %s in:\n-- %s", typename, json_object_get_string(alsaJ));
return -4;
}
@@ -216,17 +213,17 @@ int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsa
alsaMap->ctl.name = (char *) alsaMap->uid;
}
else if(alsaMap->ctl.name && alsaMap->ctl.numid > 0) {
- AFB_ApiError(apiHandle,
- "Can't have both a control name (%s) and a control uid (%i) in alsa object:\n-- %s",
- alsaMap->ctl.name,
- alsaMap->ctl.numid,
- json_object_get_string(alsaJ));
+ AFB_API_ERROR(apiHandle,
+ "Can't have both a control name (%s) and a control uid (%i) in alsa object:\n-- %s",
+ alsaMap->ctl.name,
+ alsaMap->ctl.numid,
+ json_object_get_string(alsaJ));
return -5;
}
else if(! alsaMap->ctl.name && alsaMap->ctl.numid <= 0) {
- AFB_ApiError(apiHandle,
- "Need at least a control name or a control uid in alsa object:\n-- %s",
- json_object_get_string(alsaJ));
+ AFB_API_ERROR(apiHandle,
+ "Need at least a control name or a control uid in alsa object:\n-- %s",
+ json_object_get_string(alsaJ));
return -6;
}
@@ -236,28 +233,27 @@ int HalCtlsProcessOneHalMapObject(AFB_ApiT apiHandle, struct CtlHalAlsaMap *alsa
return 0;
}
-int HalCtlsHandleOneHalMapObject(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaMap *alsaMap)
+int HalCtlsHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaMap *alsaMap)
{
int err;
json_object *valueJ, *convertedValueJ = NULL;
- alsaMap->alsaControlEvent = AFB_EventMake(apiHandle, alsaMap->uid);
- if(! AFB_EventIsValid(alsaMap->alsaControlEvent)) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to create event for halmap ALSA control '%s'",
- alsaMap->uid);
+ if(! (alsaMap->alsaControlEvent = afb_api_make_event(apiHandle, alsaMap->uid))) {
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to create event for current alsa control to load action using alsa object:\n-- %s",
+ json_object_get_string(alsaMap->actionJ));
return -1;
}
if(alsaMap->ctl.alsaCtlCreation) {
if(HalCtlsCreateAlsaCtl(apiHandle, cardId, &alsaMap->ctl)) {
- AFB_ApiError(apiHandle, "An error happened when trying to create a new alsa control");
+ AFB_API_ERROR(apiHandle, "An error happened when trying to create a new alsa control");
return -2;
}
}
else if(HalCtlsUpdateAlsaCtlProperties(apiHandle, cardId, &alsaMap->ctl)) {
- AFB_ApiError(apiHandle, "An error happened when trying to get existing alsa control info");
+ AFB_API_ERROR(apiHandle, "An error happened when trying to get existing alsa control info");
return -3;
}
@@ -267,15 +263,15 @@ int HalCtlsHandleOneHalMapObject(AFB_ApiT apiHandle, char *cardId, struct CtlHal
err = 0;
if(HalCtlsConvertJsonValues(apiHandle, &alsaMap->ctl.alsaCtlProperties, valueJ, &convertedValueJ, CONVERSION_NORMALIZED_TO_ALSACORE)) {
- AFB_ApiError(apiHandle, "Error when trying to convert initiate value json '%s'", json_object_get_string(valueJ));
+ AFB_API_ERROR(apiHandle, "Error when trying to convert initiate value json '%s'", json_object_get_string(valueJ));
err = -4;
}
else if(HalCtlsSetAlsaCtlValue(apiHandle, cardId, alsaMap->ctl.numid, convertedValueJ)) {
- AFB_ApiError(apiHandle,
- "Error while trying to set initial value on alsa control %i, device '%s', value '%s'",
- alsaMap->ctl.numid,
- cardId,
- json_object_get_string(valueJ));
+ AFB_API_ERROR(apiHandle,
+ "Error while trying to set initial value on alsa control %i, device '%s', value '%s'",
+ alsaMap->ctl.numid,
+ cardId,
+ json_object_get_string(valueJ));
err = -5;
}
@@ -291,24 +287,24 @@ int HalCtlsHandleOneHalMapObject(AFB_ApiT apiHandle, char *cardId, struct CtlHal
if(alsaMap->actionJ) {
alsaMap->action = calloc(1, sizeof(CtlActionT));
if(ActionLoadOne(apiHandle, alsaMap->action, alsaMap->actionJ, 0)) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to load action using alsa object:\n-- %s",
- json_object_get_string(alsaMap->actionJ));
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to load action using alsa object:\n-- %s",
+ json_object_get_string(alsaMap->actionJ));
return -6;
}
}
- if(AFB_ApiAddVerb(apiHandle, alsaMap->uid, alsaMap->info, HalCtlsActionOnAlsaCtl, (void *) alsaMap, NULL, 0, 0)) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to create verb for current alsa control to load action using alsa object:\n-- %s",
- json_object_get_string(alsaMap->actionJ));
+ if(afb_api_add_verb(apiHandle, alsaMap->uid, alsaMap->info, HalCtlsActionOnAlsaCtl, (void *) alsaMap, NULL, 0, 0)) {
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to create verb for current alsa control to load action using alsa object:\n-- %s",
+ json_object_get_string(alsaMap->actionJ));
return -7;
}
return 0;
}
-int HalCtlsProcessAllHalMap(AFB_ApiT apiHandle, json_object *AlsaMapJ, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT)
+int HalCtlsProcessAllHalMap(afb_api_t apiHandle, json_object *AlsaMapJ, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT)
{
int idx, err = 0;
@@ -329,7 +325,7 @@ int HalCtlsProcessAllHalMap(AFB_ApiT apiHandle, json_object *AlsaMapJ, struct Ct
default:
currentCtlHalAlsaMapT->ctlsCount = 0;
currentCtlHalAlsaMapT->ctls = NULL;
- AFB_ApiWarning(apiHandle, "Couldn't get content of 'halmap' section in:\n-- %s", json_object_get_string(AlsaMapJ));
+ AFB_API_WARNING(apiHandle, "Couldn't get content of 'halmap' section in:\n-- %s", json_object_get_string(AlsaMapJ));
return -1;
}
@@ -343,7 +339,7 @@ int HalCtlsProcessAllHalMap(AFB_ApiT apiHandle, json_object *AlsaMapJ, struct Ct
return err;
}
-int HalCtlsHandleAllHalMap(AFB_ApiT apiHandle, int sndCardId, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT)
+int HalCtlsHandleAllHalMap(afb_api_t apiHandle, int sndCardId, struct CtlHalAlsaMapT *currentCtlHalAlsaMapT)
{
int idx, err = 0;
@@ -359,13 +355,12 @@ int HalCtlsHandleAllHalMap(AFB_ApiT apiHandle, int sndCardId, struct CtlHalAlsaM
return err;
}
-int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *AlsaMapJ)
+int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *AlsaMapJ)
{
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentHalData;
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig)
+ if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle)))
return -1;
currentHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
@@ -376,28 +371,28 @@ int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *A
currentHalData->ctlHalSpecificData->ctlHalAlsaMapT = calloc(1, sizeof(struct CtlHalAlsaMapT));
if(HalCtlsProcessAllHalMap(apiHandle, AlsaMapJ, currentHalData->ctlHalSpecificData->ctlHalAlsaMapT)) {
- AFB_ApiError(apiHandle, "Failed to process 'halmap' section");
+ AFB_API_ERROR(apiHandle, "Failed to process 'halmap' section");
return -3;
}
}
else if(currentHalData->status == HAL_STATUS_UNAVAILABLE) {
- AFB_ApiWarning(apiHandle, "Hal is unavailable, 'halmap' section data can't be handle");
+ AFB_API_WARNING(apiHandle, "Hal is unavailable, 'halmap' section data can't be handle");
return 1;
}
else if(currentHalData->sndCardId < 0) {
- AFB_ApiError(apiHandle, "Hal alsa card id is not valid, 'halmap' section data can't be handle");
+ AFB_API_ERROR(apiHandle, "Hal alsa card id is not valid, 'halmap' section data can't be handle");
return -6;
}
else if(! currentHalData->ctlHalSpecificData->ctlHalAlsaMapT) {
- AFB_ApiWarning(apiHandle, "'halmap' section data is empty");
+ AFB_API_WARNING(apiHandle, "'halmap' section data is empty");
return 2;
}
else if(! (currentHalData->ctlHalSpecificData->ctlHalAlsaMapT->ctlsCount > 0)) {
- AFB_ApiWarning(apiHandle, "No alsa controls defined in 'halmap' section");
+ AFB_API_WARNING(apiHandle, "No alsa controls defined in 'halmap' section");
return 3;
}
else if(HalCtlsHandleAllHalMap(apiHandle, currentHalData->sndCardId, currentHalData->ctlHalSpecificData->ctlHalAlsaMapT)) {
- AFB_ApiError(apiHandle, "Failed to handle 'halmap' section");
+ AFB_API_ERROR(apiHandle, "Failed to handle 'halmap' section");
return -9;
}
@@ -408,20 +403,20 @@ int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *A
* HAL controllers verbs functions *
******************************************************************************/
-json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMixerData, enum MixerDataType dataType)
+json_object *HalCtlsGetJsonArrayForMixerDataTable(afb_api_t apiHandle, struct CtlHalMixerData **firstMixerData, enum MixerDataType dataType)
{
json_object *mixerDataArrayJ, *currentMixerDataJ;
struct CtlHalMixerData *currentMixerData;
if(! apiHandle) {
- AFB_ApiError(apiHandle, "Can't get current hal controller api handle");
+ AFB_API_ERROR(apiHandle, "Can't get current hal controller api handle");
return NULL;
}
mixerDataArrayJ = json_object_new_array();
if(! mixerDataArrayJ) {
- AFB_ApiError(apiHandle, "Can't generate json mixer data array");
+ AFB_API_ERROR(apiHandle, "Can't generate json mixer data array");
return NULL;
}
@@ -457,25 +452,24 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl
return mixerDataArrayJ;
}
-json_object *HalCtlsGetJsonArrayForControls(AFB_ApiT apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT)
+json_object *HalCtlsGetJsonArrayForControls(afb_api_t apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT)
{
unsigned int idx;
json_object *alsaMapDataArray, *currentAlsaMapData;
if(! apiHandle) {
- AFB_ApiError(apiHandle, "Can't get current hal controller api handle");
+ AFB_API_ERROR(apiHandle, "Can't get current hal controller api handle");
return NULL;
}
if(! currentAlsaMapDataT) {
- AFB_ApiError(apiHandle, "Can't get Alsa map data table to handle");
+ AFB_API_ERROR(apiHandle, "Can't get Alsa map data table to handle");
return NULL;
}
- alsaMapDataArray = json_object_new_array();
- if(! alsaMapDataArray) {
- AFB_ApiError(apiHandle, "Can't generate json mixer data array");
+ if(! (alsaMapDataArray = json_object_new_array())) {
+ AFB_API_ERROR(apiHandle, "Can't generate json mixer data array");
return NULL;
}
@@ -491,88 +485,84 @@ json_object *HalCtlsGetJsonArrayForControls(AFB_ApiT apiHandle, struct CtlHalAls
return alsaMapDataArray;
}
-void HalCtlsInfo(AFB_ReqT request)
+void HalCtlsInfo(afb_req_t request)
{
char *apiToCall, *returnedStatus = NULL, *returnedInfo = NULL;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray, *controlsArray;
- 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;
}
- requestJson = AFB_ReqJson(request);
- if(! requestJson) {
- AFB_ReqNotice(request, "Can't get request json");
+ if(! (requestJson = afb_req_json(request))) {
+ AFB_REQ_NOTICE(request, "Can't get request json");
}
else if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) {
apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName;
if(! apiToCall) {
- AFB_ReqFail(request, "mixer_api", "Can't get mixer api");
+ afb_req_fail(request, "mixer_api", "Can't get mixer api");
return;
}
if(HalCtlsGetInfoFromMixer(apiHandle, apiToCall, requestJson, &toReturnJ, &returnedStatus, &returnedInfo)) {
if(returnedStatus && returnedInfo) {
- AFB_ReqFailF(request,
- "mixer_info",
- "Call to mixer info verb didn't succeed with status '%s' and info '%s'",
- returnedStatus,
- returnedInfo);
+ afb_req_fail_f(request,
+ "mixer_info",
+ "Call to mixer info verb didn't succeed with status '%s' and info '%s'",
+ returnedStatus,
+ returnedInfo);
}
else {
- AFB_ReqFail(request, "mixer_info", "Call to mixer info verb didn't succeed");
+ afb_req_fail(request, "mixer_info", "Call to mixer info verb didn't succeed");
}
return;
}
- AFB_ReqSuccess(request, toReturnJ, "Mixer requested data");
+ afb_req_success(request, toReturnJ, "Mixer requested data");
return;
}
if(! (streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
&currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData,
MIXER_DATA_STREAMS))) {
- AFB_ReqFail(request, "streams_data", "Didn't succeed to generate streams data array");
+ afb_req_fail(request, "streams_data", "Didn't succeed to generate streams data array");
return;
}
if(! (playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
&currentCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData,
MIXER_DATA_PLAYBACKS))) {
- AFB_ReqFail(request, "playbacks_data", "Didn't succeed to generate playbacks data array");
+ afb_req_fail(request, "playbacks_data", "Didn't succeed to generate playbacks data array");
return;
}
if(! (capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
&currentCtlHalData->ctlHalSpecificData->ctlHalCapturesData,
MIXER_DATA_CAPTURES))) {
- AFB_ReqFail(request, "captures_data", "Didn't succeed to generate captures data array");
+ afb_req_fail(request, "captures_data", "Didn't succeed to generate captures data array");
return;
}
if(! (controlsArray = HalCtlsGetJsonArrayForControls(apiHandle,
currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT))) {
- AFB_ReqFail(request, "controls_data", "Didn't succeed to generate controls data array");
+ afb_req_fail(request, "controls_data", "Didn't succeed to generate controls data array");
return;
}
@@ -583,16 +573,16 @@ void HalCtlsInfo(AFB_ReqT request)
"captures", capturesArray,
"controls", controlsArray);
- AFB_ReqSuccess(request, requestAnswer, "Requested data");
+ afb_req_success(request, requestAnswer, "Requested data");
}
-void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType subscribeUnsubscribeType)
+void HalCtlsSubscribeUnsubscribe(afb_req_t request, enum SubscribeUnsubscribeType subscribeUnsubscribeType)
{
int arrayIdx, searchIdx, count, subscriptionFound, subscriptionDoneNb = 0;
char *currentSubscriptionString;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -602,39 +592,35 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
json_object *requestJson, *requestedSubscriptionsJ, *requestedSubscriptionJ = NULL;
json_type requestJsonType;
- 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->ctlHalSpecificData) {
- AFB_ReqFail(request, "hal_controller_data", "Can't get current hal specific data");
+ afb_req_fail(request, "hal_controller_data", "Can't get current hal specific data");
return;
}
halAlsaMapT = currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT;
- requestJson = AFB_ReqJson(request);
- if(! requestJson) {
- AFB_ReqFail(request, "request_json", "Can't get request json");
+ if(! (requestJson = afb_req_json(request))) {
+ afb_req_fail(request, "request_json", "Can't get request json");
return;
}
if(wrap_json_unpack(requestJson, "{s:o}", "events", &requestedSubscriptionsJ)) {
- AFB_ReqFail(request, "request_json", "Request json invalid");
+ afb_req_fail(request, "request_json", "Request json invalid");
return;
}
@@ -650,7 +636,7 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
break;
default:
- AFB_ReqFail(request, "request_json", "Request json invalid");
+ afb_req_fail(request, "request_json", "Request json invalid");
return;
}
@@ -658,7 +644,7 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
if(requestJsonType == json_type_array) {
requestedSubscriptionJ = json_object_array_get_idx(requestedSubscriptionsJ, arrayIdx);
if(! json_object_is_type(requestedSubscriptionJ, json_type_string)) {
- AFB_ReqFailF(request, "request_json", "Request json number %i in array invalid", arrayIdx);
+ afb_req_fail_f(request, "request_json", "Request json number %i in array invalid", arrayIdx);
return;
}
}
@@ -670,17 +656,17 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
if(currentCtlHalData->ctlHalSpecificData->streamUpdates &&
subscribeUnsubscribeType == SUBSCRIPTION &&
afb_req_subscribe(request, currentCtlHalData->ctlHalSpecificData->streamUpdates)) {
- AFB_ReqFailF(request,
- "request_stream_list_updates_event",
- "Error while trying to subscribe to stream list updates event");
+ afb_req_fail_f(request,
+ "request_stream_list_updates_event",
+ "Error while trying to subscribe to stream list updates event");
return;
}
else if(currentCtlHalData->ctlHalSpecificData->streamUpdates &&
subscribeUnsubscribeType == UNSUBSCRIPTION &&
afb_req_unsubscribe(request, currentCtlHalData->ctlHalSpecificData->streamUpdates)) {
- AFB_ReqFailF(request,
- "request_stream_list_updates_event",
- "Error while trying to unsubscribe to stream list updates event");
+ afb_req_fail_f(request,
+ "request_stream_list_updates_event",
+ "Error while trying to unsubscribe to stream list updates event");
return;
}
@@ -695,19 +681,19 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
if(currentStreamData->event &&
subscribeUnsubscribeType == SUBSCRIPTION &&
afb_req_subscribe(request, currentStreamData->event)) {
- AFB_ReqFailF(request,
- "request_stream_event",
- "Error while trying to subscribe to %s stream events",
- currentStreamData->verb);
+ afb_req_fail_f(request,
+ "request_stream_event",
+ "Error while trying to subscribe to %s stream events",
+ currentStreamData->verb);
return;
}
else if(currentStreamData->event &&
subscribeUnsubscribeType == UNSUBSCRIPTION &&
afb_req_unsubscribe(request, currentStreamData->event)) {
- AFB_ReqFailF(request,
- "request_stream_event",
- "Error while trying to unsubscribe to %s stream events",
- currentStreamData->verb);
+ afb_req_fail_f(request,
+ "request_stream_event",
+ "Error while trying to unsubscribe to %s stream events",
+ currentStreamData->verb);
return;
}
@@ -727,19 +713,19 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
if(halAlsaMapT->ctls[searchIdx].alsaControlEvent &&
subscribeUnsubscribeType == SUBSCRIPTION &&
afb_req_subscribe(request, halAlsaMapT->ctls[searchIdx].alsaControlEvent)) {
- AFB_ReqFailF(request,
- "request_control_event",
- "Error while trying to subscribe to %s halmap controls events",
- halAlsaMapT->ctls[searchIdx].uid);
+ afb_req_fail_f(request,
+ "request_control_event",
+ "Error while trying to subscribe to %s halmap controls events",
+ halAlsaMapT->ctls[searchIdx].uid);
return;
}
else if(halAlsaMapT->ctls[searchIdx].alsaControlEvent &&
subscribeUnsubscribeType == UNSUBSCRIPTION &&
afb_req_unsubscribe(request, halAlsaMapT->ctls[searchIdx].alsaControlEvent)) {
- AFB_ReqFailF(request,
- "request_stream_event",
- "Error while trying to unsubscribe to %s halmap controls events",
- halAlsaMapT->ctls[searchIdx].uid);
+ afb_req_fail_f(request,
+ "request_stream_event",
+ "Error while trying to unsubscribe to %s halmap controls events",
+ halAlsaMapT->ctls[searchIdx].uid);
return;
}
@@ -754,38 +740,38 @@ void HalCtlsSubscribeUnsubscribe(AFB_ReqT request, enum SubscribeUnsubscribeType
}
if(subscriptionDoneNb == 0)
- AFB_ReqFailF(request,
- "events_not_found",
- "%s failed, event(s) were not found",
- subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription");
+ afb_req_fail_f(request,
+ "events_not_found",
+ "%s failed, event(s) were not found",
+ subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription");
if(subscriptionDoneNb == count)
- AFB_ReqSuccessF(request,
- json_object_new_int(subscriptionDoneNb),
- "%s succeed for all the %i events requested",
- subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
- subscriptionDoneNb);
+ afb_req_success_f(request,
+ json_object_new_int(subscriptionDoneNb),
+ "%s succeed for all the %i events requested",
+ subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
+ subscriptionDoneNb);
else if(subscriptionDoneNb < count)
- AFB_ReqSuccessF(request,
- json_object_new_int(subscriptionDoneNb),
- "%s succeed but only to %i events requested out of %i",
- subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
- subscriptionDoneNb,
- count);
+ afb_req_success_f(request,
+ json_object_new_int(subscriptionDoneNb),
+ "%s succeed but only to %i events requested out of %i",
+ subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
+ subscriptionDoneNb,
+ count);
else
- AFB_ReqSuccessF(request,
- json_object_new_int(subscriptionDoneNb),
- "%s succeed but to more events than requested (%i out of %i)",
- subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
- subscriptionDoneNb,
- count);
+ afb_req_success_f(request,
+ json_object_new_int(subscriptionDoneNb),
+ "%s succeed but to more events than requested (%i out of %i)",
+ subscribeUnsubscribeType == SUBSCRIPTION ? "Subscription" : "Unsubscription",
+ subscriptionDoneNb,
+ count);
}
-void HalCtlsSubscribe(AFB_ReqT request)
+void HalCtlsSubscribe(afb_req_t request)
{
HalCtlsSubscribeUnsubscribe(request, SUBSCRIPTION);
}
-void HalCtlsUnsubscribe(AFB_ReqT request)
+void HalCtlsUnsubscribe(afb_req_t request)
{
HalCtlsSubscribeUnsubscribe(request, UNSUBSCRIPTION);
} \ No newline at end of file
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
index a90c19a..d43176d 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
@@ -20,7 +20,7 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -31,15 +31,15 @@ enum SubscribeUnsubscribeType {
};
// HAL controller event handler function
-void HalCtlsDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ);
+void HalCtlsDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ);
// HAL controllers sections parsing functions
-int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *MixerJ);
-int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *StreamControlsJ);
+int HalCtlsHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *MixerJ);
+int HalCtlsHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *StreamControlsJ);
// HAL controllers verbs functions
-void HalCtlsInfo(AFB_ReqT request);
-void HalCtlsSubscribe(AFB_ReqT request);
-void HalCtlsUnsubscribe(AFB_ReqT request);
+void HalCtlsInfo(afb_req_t request);
+void HalCtlsSubscribe(afb_req_t request);
+void HalCtlsUnsubscribe(afb_req_t request);
#endif /* _HALMGR_CB_INCLUDE_ */ \ No newline at end of file
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);
}
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 db42001..f7d8f83 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
@@ -22,6 +22,8 @@
#include <wrap-json.h>
+#include <afb/afb-binding.h>
+
#include <afb-helpers-utils.h>
#include "4a-hal-utilities-data.h"
@@ -57,7 +59,12 @@ enum MixerStatus {
};
// HAL controllers handle mixer calls functions
-int HalCtlsAttachToMixer(AFB_ApiT apiHandle);
-int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ, char **returnedStatus, char **returnedInfo);
+int HalCtlsAttachToMixer(afb_api_t apiHandle);
+int HalCtlsGetInfoFromMixer(afb_api_t apiHandle,
+ char *apiToCall,
+ json_object *requestJson,
+ json_object **toReturnJ,
+ char **returnedStatus,
+ char **returnedInfo);
#endif /* _HAL_CTLS_SOFTMIXER_LINK_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
index 4273def..74d0fdd 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
@@ -25,7 +25,7 @@
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-controllers-value-handler.h"
#include "4a-hal-controllers-alsacore-link.h"
@@ -62,7 +62,7 @@ int HalCtlsConvertPercentageToValue(int percentage, int min, int max)
* Convert json object from percentage to value *
******************************************************************************/
-int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
+int HalCtlsConvertJsonValueForIntegerControl(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *toConvertJ,
json_object **ConvertedJ,
@@ -71,9 +71,9 @@ int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
int initialValue, convertedValue;
if(! json_object_is_type(toConvertJ, json_type_int)) {
- AFB_ApiError(apiHandle,
- "Can't convert json value, unrecognized json format (must be an integer) : '%s'",
- json_object_get_string(toConvertJ));
+ AFB_API_ERROR(apiHandle,
+ "Can't convert json value, unrecognized json format (must be an integer) : '%s'",
+ json_object_get_string(toConvertJ));
return -1;
}
@@ -82,10 +82,10 @@ int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
switch(requestedConversion) {
case CONVERSION_NORMALIZED_TO_ALSACORE:
if(initialValue < 0 || initialValue > 100) {
- AFB_ApiError(apiHandle,
- "Cannot convert '%i' value, value should be between 0 and 100 ('%s')",
- initialValue,
- json_object_get_string(toConvertJ));
+ AFB_API_ERROR(apiHandle,
+ "Cannot convert '%i' value, value should be between 0 and 100 ('%s')",
+ initialValue,
+ json_object_get_string(toConvertJ));
return -2;
}
@@ -94,11 +94,11 @@ int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
alsaCtlProperties->maxval);
if(convertedValue == -INT_MAX) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to convert %i (using min %i et max %i)",
- initialValue,
- alsaCtlProperties->minval,
- alsaCtlProperties->maxval);
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to convert %i (using min %i et max %i)",
+ initialValue,
+ alsaCtlProperties->minval,
+ alsaCtlProperties->maxval);
return -3;
}
@@ -115,21 +115,21 @@ int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
alsaCtlProperties->maxval);
if(convertedValue == -INT_MAX) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to convert %i (using min %i et max %i)",
- initialValue,
- alsaCtlProperties->minval,
- alsaCtlProperties->maxval);
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to convert %i (using min %i et max %i)",
+ initialValue,
+ alsaCtlProperties->minval,
+ alsaCtlProperties->maxval);
return -4;
}
break;
default:
- AFB_ApiError(apiHandle,
- "Can't convert '%i' value, unrecognized conversion type : '%i'",
- initialValue,
- (int) requestedConversion);
+ AFB_API_ERROR(apiHandle,
+ "Can't convert '%i' value, unrecognized conversion type : '%i'",
+ initialValue,
+ (int) requestedConversion);
*ConvertedJ = NULL;
return -5;
}
@@ -139,7 +139,7 @@ int HalCtlsConvertJsonValueForIntegerControl(AFB_ApiT apiHandle,
return 0;
}
-int HalCtlsConvertJsonValueForBooleanControl(AFB_ApiT apiHandle,
+int HalCtlsConvertJsonValueForBooleanControl(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *toConvertJ,
json_object **ConvertedJ,
@@ -157,17 +157,17 @@ int HalCtlsConvertJsonValueForBooleanControl(AFB_ApiT apiHandle,
break;
default:
- AFB_ApiError(apiHandle,
- "Can't convert json value, unrecognized format (must be an integer or a boolean) : '%s'",
- json_object_get_string(toConvertJ));
+ AFB_API_ERROR(apiHandle,
+ "Can't convert json value, unrecognized format (must be an integer or a boolean) : '%s'",
+ json_object_get_string(toConvertJ));
return -1;
}
if(initialValue < 0 || initialValue > 1) {
- AFB_ApiError(apiHandle,
- "Cannot convert '%i' value, value should be 0 or 1 ('%s')",
- initialValue,
- json_object_get_string(toConvertJ));
+ AFB_API_ERROR(apiHandle,
+ "Cannot convert '%i' value, value should be 0 or 1 ('%s')",
+ initialValue,
+ json_object_get_string(toConvertJ));
return -2;
}
@@ -181,10 +181,10 @@ int HalCtlsConvertJsonValueForBooleanControl(AFB_ApiT apiHandle,
break;
default:
- AFB_ApiError(apiHandle,
- "Can't convert '%i' value, unrecognized conversion type : '%i'",
- initialValue,
- (int) requestedConversion);
+ AFB_API_ERROR(apiHandle,
+ "Can't convert '%i' value, unrecognized conversion type : '%i'",
+ initialValue,
+ (int) requestedConversion);
*ConvertedJ = NULL;
return -3;
}
@@ -192,7 +192,7 @@ int HalCtlsConvertJsonValueForBooleanControl(AFB_ApiT apiHandle,
return 0;
}
-int HalCtlsConvertJsonValues(AFB_ApiT apiHandle,
+int HalCtlsConvertJsonValues(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *toConvertJ,
json_object **ConvertedJ,
@@ -224,11 +224,11 @@ int HalCtlsConvertJsonValues(AFB_ApiT apiHandle,
toConvertObjectJ,
&convertedValueJ,
requestedConversion))) {
- AFB_ApiError(apiHandle,
- "Error %i happened in when trying to convert index %i for integer control ('%s')",
- conversionError,
- idx,
- json_object_get_string(toConvertObjectJ));
+ AFB_API_ERROR(apiHandle,
+ "Error %i happened in when trying to convert index %i for integer control ('%s')",
+ conversionError,
+ idx,
+ json_object_get_string(toConvertObjectJ));
json_object_put(convertedArrayJ);
return -(idx + 1);
}
@@ -240,20 +240,20 @@ int HalCtlsConvertJsonValues(AFB_ApiT apiHandle,
toConvertObjectJ,
&convertedValueJ,
requestedConversion))) {
- AFB_ApiError(apiHandle,
- "Error %i happened in when trying to convert index %i for boolean control ('%s')",
- conversionError,
- idx,
- json_object_get_string(toConvertObjectJ));
+ AFB_API_ERROR(apiHandle,
+ "Error %i happened in when trying to convert index %i for boolean control ('%s')",
+ conversionError,
+ idx,
+ json_object_get_string(toConvertObjectJ));
json_object_put(convertedArrayJ);
return -(idx + 1);
}
break;
default:
- AFB_ApiError(apiHandle,
- "Conversion not handle for the alsa control type %i",
- (int) alsaCtlProperties->type);
+ AFB_API_ERROR(apiHandle,
+ "Conversion not handle for the alsa control type %i",
+ (int) alsaCtlProperties->type);
json_object_put(convertedArrayJ);
return -(idx + 1);
}
@@ -266,7 +266,7 @@ int HalCtlsConvertJsonValues(AFB_ApiT apiHandle,
return 0;
}
-int HalCtlsChangePreviousValuesUsingJson(AFB_ApiT apiHandle,
+int HalCtlsChangePreviousValuesUsingJson(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *requestedPercentageVariationJ,
json_object *previousControlValuesJ,
@@ -284,26 +284,26 @@ int HalCtlsChangePreviousValuesUsingJson(AFB_ApiT apiHandle,
requestedPercentageVariation = (int) strtol(requestedPercentageVariationString, &conversionEnd, 10);
if(conversionEnd == requestedPercentageVariationString) {
- AFB_ApiError(apiHandle,
- "Tried to increase/decrease an integer control \
- but string sent in json is not a increase/decrease string : '%s'",
- json_object_get_string(requestedPercentageVariationJ));
+ AFB_API_ERROR(apiHandle,
+ "Tried to increase/decrease an integer control \
+ but string sent in json is not a increase/decrease string : '%s'",
+ json_object_get_string(requestedPercentageVariationJ));
return -1;
}
if(alsaCtlProperties->type != SND_CTL_ELEM_TYPE_INTEGER &&
alsaCtlProperties->type != SND_CTL_ELEM_TYPE_INTEGER64) {
- AFB_ApiError(apiHandle,
- "Tried to increase/decrease values on a incompatible \
- control type (%i), control type must be an integer",
- alsaCtlProperties->type);
+ AFB_API_ERROR(apiHandle,
+ "Tried to increase/decrease values on a incompatible \
+ control type (%i), control type must be an integer",
+ alsaCtlProperties->type);
return -2;
}
if(requestedPercentageVariation < -100 || requestedPercentageVariation > 100) {
- AFB_ApiError(apiHandle,
- "Tried to increase/decrease values but specified change is \
- not a valid percentage, it should be between -100 and 100");
+ AFB_API_ERROR(apiHandle,
+ "Tried to increase/decrease values but specified change is \
+ not a valid percentage, it should be between -100 and 100");
return -3;
}
@@ -312,11 +312,11 @@ int HalCtlsChangePreviousValuesUsingJson(AFB_ApiT apiHandle,
alsaCtlProperties->maxval);
if(requestedeVariation == -INT_MAX) {
- AFB_ApiError(apiHandle,
- "Didn't succeed to convert %i (using min %i et max %i)",
- requestedPercentageVariation,
- alsaCtlProperties->minval,
- alsaCtlProperties->maxval);
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to convert %i (using min %i et max %i)",
+ requestedPercentageVariation,
+ alsaCtlProperties->minval,
+ alsaCtlProperties->maxval);
return -4;
}
@@ -331,9 +331,9 @@ int HalCtlsChangePreviousValuesUsingJson(AFB_ApiT apiHandle,
toChangeObjectJ = json_object_array_get_idx(previousControlValuesJ, idx);
if(! json_object_is_type(toChangeObjectJ, json_type_int)) {
- AFB_ApiError(apiHandle,
- "Current json object %s is not an integer",
- json_object_get_string(toChangeObjectJ));
+ AFB_API_ERROR(apiHandle,
+ "Current json object %s is not an integer",
+ json_object_get_string(toChangeObjectJ));
return -(10 + idx);
}
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h
index 4844952..03b47e7 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.h
@@ -22,6 +22,8 @@
#include <wrap-json.h>
+#include <afb/afb-binding.h>
+
#include "4a-hal-controllers-alsacore-link.h"
// Enum for the type of conversion requested
@@ -35,14 +37,14 @@ int HalCtlsConvertValueToPercentage(double val, double min, double max);
int HalCtlsConvertPercentageToValue(int percentage, int min, int max);
// Convert json object from percentage to value
-int HalCtlsConvertJsonValues(AFB_ApiT apiHandle,
+int HalCtlsConvertJsonValues(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *toConvertJ,
json_object **ConvertedJ,
enum ConversionType requestedConversion);
// Increase/Decrease previous values using percentage passed in Json
-int HalCtlsChangePreviousValuesUsingJson(AFB_ApiT apiHandle,
+int HalCtlsChangePreviousValuesUsingJson(afb_api_t apiHandle,
struct CtlHalAlsaCtlProperties *alsaCtlProperties,
json_object *requestedPercentageVariationJ,
json_object *previousControlValuesJ,