summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.c2
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.h4
-rw-r--r--4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c75
-rw-r--r--4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h6
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c4
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.h12
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c133
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h14
-rw-r--r--4a-hal-utilities/4a-hal-utilities-verbs-loader.c20
-rw-r--r--4a-hal-utilities/4a-hal-utilities-verbs-loader.h4
-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
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c106
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.h16
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-events.h2
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.c33
-rw-r--r--plugins/lib/bluealsa/hal-bluealsa-transports.c2
-rw-r--r--plugins/lib/bluealsa/hal-bluealsa-transports.h2
-rw-r--r--plugins/lib/bluealsa/hal-bluealsa.c70
27 files changed, 791 insertions, 808 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
index ef2967a..79cc8eb 100644
--- a/4a-hal-utilities/4a-hal-utilities-alsa-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
@@ -19,7 +19,7 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-alsa-data.h"
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
index 5a998ae..ef0aba1 100644
--- a/4a-hal-utilities/4a-hal-utilities-alsa-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
@@ -24,6 +24,8 @@
#include <alsa/asoundlib.h>
+#include <afb/afb-binding.h>
+
#include <ctl-config.h>
struct CtlHalAlsaDBScale {
@@ -55,7 +57,7 @@ struct CtlHalAlsaCtl {
struct CtlHalAlsaMap {
const char *uid;
char *info;
- AFB_EventT alsaControlEvent;
+ afb_event_t alsaControlEvent;
struct CtlHalAlsaCtl ctl;
json_object *actionJ;
CtlActionT *action;
diff --git a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
index 40581ef..bf88571 100644
--- a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
+++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
@@ -20,13 +20,15 @@
#include <stdio.h>
#include <string.h>
+#include <afb/afb-binding.h>
+
#include "4a-hal-utilities-appfw-responses-handler.h"
/*******************************************************************************
* Handle application framework response function *
******************************************************************************/
-enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
+enum CallError HalUtlHandleAppFwCallError(afb_api_t apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
{
json_object *returnedRequestJ, *returnedStatusJ, *returnedInfoJ;
@@ -34,73 +36,72 @@ enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, c
return CALL_ERROR_INVALID_ARGS;
if(! json_object_object_get_ex(callReturnJ, "request", &returnedRequestJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response request object");
+ AFB_API_WARNING(apiHandle, "Couldn't get response request object");
return CALL_ERROR_REQUEST_UNAVAILABLE;
}
if(! json_object_is_type(returnedRequestJ, json_type_object)) {
- AFB_ApiWarning(apiHandle, "Response request object is not valid");
+ AFB_API_WARNING(apiHandle, "Response request object is not valid");
return CALL_ERROR_REQUEST_NOT_VALID;
}
if(! json_object_object_get_ex(returnedRequestJ, "status", &returnedStatusJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response status object");
+ AFB_API_WARNING(apiHandle, "Couldn't get response status object");
return CALL_ERROR_REQUEST_STATUS_UNAVAILABLE;
}
if(! json_object_is_type(returnedStatusJ, json_type_string)) {
- AFB_ApiWarning(apiHandle, "Response status object is not valid");
+ AFB_API_WARNING(apiHandle, "Response status object is not valid");
return CALL_ERROR_REQUEST_STATUS_NOT_VALID;
}
*returnedStatus = (char *) json_object_get_string(returnedStatusJ);
if(! strcmp(*returnedStatus, "unknown-api")) {
- AFB_ApiWarning(apiHandle, "Api %s not found", apiCalled);
+ AFB_API_WARNING(apiHandle, "Api %s not found", apiCalled);
return CALL_ERROR_API_UNAVAILABLE;
}
if(! strcmp(*returnedStatus, "unknown-verb")) {
- AFB_ApiWarning(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
+ AFB_API_WARNING(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
return CALL_ERROR_VERB_UNAVAILABLE;
}
if(! json_object_object_get_ex(returnedRequestJ, "info", &returnedInfoJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response info object");
+ AFB_API_WARNING(apiHandle, "Couldn't get response info object");
return CALL_ERROR_REQUEST_INFO_UNAVAILABLE;
}
if(! json_object_is_type(returnedInfoJ, json_type_string)) {
- AFB_ApiWarning(apiHandle, "Response info object is not valid");
+ AFB_API_WARNING(apiHandle, "Response info object is not valid");
return CALL_ERROR_REQUEST_INFO_NOT_VALID;
}
*returnedInfo = (char *) json_object_get_string(returnedInfoJ);
- AFB_ApiWarning(apiHandle,
- "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
- apiCalled,
- verbCalled,
- *returnedStatus,
- *returnedInfo);
+ AFB_API_WARNING(apiHandle,
+ "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
+ apiCalled,
+ verbCalled,
+ *returnedStatus,
+ *returnedInfo);
return CALL_ERROR_RETURNED;
}
-void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
+void HalUtlHandleAppFwCallErrorInRequest(afb_req_t request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
{
char *returnedStatus = NULL, *returnedInfo = NULL;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
if(! request || ! apiCalled || ! verbCalled || ! callReturnJ) {
- AFB_ReqFailF(request, "invalid_args", "Invalid arguments");
+ afb_req_fail_f(request, "invalid_args", "Invalid arguments");
return;
}
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFailF(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail_f(request, "api_handle", "Can't get hal manager api handle");
return;
}
@@ -111,37 +112,37 @@ void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char
case CALL_ERROR_REQUEST_STATUS_NOT_VALID:
case CALL_ERROR_REQUEST_INFO_UNAVAILABLE:
case CALL_ERROR_REQUEST_INFO_NOT_VALID:
- AFB_ReqFail(request, errorStatusToSend, "Error with response object");
+ afb_req_fail(request, errorStatusToSend, "Error with response object");
return;
case CALL_ERROR_API_UNAVAILABLE:
- AFB_ReqFailF(request, errorStatusToSend, "Api %s not found", apiCalled);
+ afb_req_fail_f(request, errorStatusToSend, "Api %s not found", apiCalled);
return;
case CALL_ERROR_VERB_UNAVAILABLE:
- AFB_ReqFailF(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
+ afb_req_fail_f(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
return;
case CALL_ERROR_RETURNED:
- AFB_ReqFailF(request,
- errorStatusToSend,
- "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
- apiCalled,
- verbCalled,
- returnedStatus ? returnedStatus : "not returned",
- returnedInfo ? returnedInfo : "not returned");
+ afb_req_fail_f(request,
+ errorStatusToSend,
+ "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
+ apiCalled,
+ verbCalled,
+ returnedStatus ? returnedStatus : "not returned",
+ returnedInfo ? returnedInfo : "not returned");
return;
case CALL_ERROR_INVALID_ARGS:
- AFB_ReqFailF(request,
- errorStatusToSend,
- "Api %s and verb %s found, but the arguments are invalid",
- apiCalled,
- verbCalled);
+ afb_req_fail_f(request,
+ errorStatusToSend,
+ "Api %s and verb %s found, but the arguments are invalid",
+ apiCalled,
+ verbCalled);
return;
default:
- AFB_ReqFailF(request, errorStatusToSend, "Unknown error happened during call to verb %s of api %s", verbCalled, apiCalled);
+ afb_req_fail_f(request, errorStatusToSend, "Unknown error happened during call to verb %s of api %s", verbCalled, apiCalled);
return;
}
} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
index 923ca6b..2bdbaab 100644
--- a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
+++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
// Enum for the type of error detected
enum CallError {
@@ -39,7 +39,7 @@ enum CallError {
};
// Handle application framework response function
-extern enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
-void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
+extern enum CallError HalUtlHandleAppFwCallError(afb_api_t apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
+void HalUtlHandleAppFwCallErrorInRequest(afb_req_t request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
#endif /* _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
index b5d0293..420354e 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -22,6 +22,8 @@
#include <wrap-json.h>
+#include <afb/afb-binding.h>
+
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-alsa-data.h"
@@ -307,7 +309,7 @@ struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData *
* Hal Manager data handling functions *
******************************************************************************/
-uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
+uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
{
if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info)
return -1;
diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h
index 62beac8..dda88ba 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-data.h
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -42,7 +42,7 @@ struct CtlHalMixerData {
char *verb;
char *verbToCall;
char *streamCardId;
- AFB_EventT event;
+ afb_event_t event;
struct CtlHalMixerData *next;
};
@@ -54,14 +54,14 @@ struct CtlHalSpecificData {
json_object *halMixerJ;
struct CtlHalMixerData *ctlHalStreamsData;
- AFB_EventT streamUpdates;
+ afb_event_t streamUpdates;
struct CtlHalMixerData *ctlHalPlaybacksData;
struct CtlHalMixerData *ctlHalCapturesData;
struct CtlHalAlsaMapT *ctlHalAlsaMapT;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
};
@@ -89,7 +89,7 @@ struct HalMgrData {
char *apiName;
char *info;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct SpecificHalData *first;
};
@@ -110,7 +110,7 @@ struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **fi
struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData **firstHalData, int cardId);
// Exported verbs for 'struct HalMgrData' handling
-uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
+uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData);
#endif /* _HAL_UTILITIES_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
index 4d42b01..9f23787 100644
--- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <json-c/json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -32,13 +32,13 @@
* Actions to be call when a stream verb is called *
******************************************************************************/
-void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
+void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
{
int idx, count;
char *apiToCall;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -46,27 +46,23 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
json_object *requestJson, *returnJ = NULL, *responseJ, *toReturnJ = NULL;
- 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_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;
}
@@ -75,17 +71,17 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
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(currentCtlHalData->status != HAL_STATUS_READY) {
- AFB_ReqFail(request, "hal_not_ready", "Seems that hal is not ready");
+ afb_req_fail(request, "hal_not_ready", "Seems that hal is not ready");
return;
}
- if(! (currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request))) {
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ if(! (currentMixerData = (struct CtlHalMixerData *) afb_req_get_vcbdata(request))) {
+ afb_req_fail(request, "hal_call_data", "Can't get current call data");
return;
}
@@ -102,16 +98,16 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
break;
default:
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ afb_req_fail(request, "hal_call_data", "Can't get current call data");
return;
}
for(idx = 0; idx < count; idx++) {
- if(AFB_ServiceSync(apiHandle,
- apiToCall,
- currentMixerData->verbToCall,
- json_object_get(requestJson),
- &returnJ)) {
+ if(afb_api_call_sync_legacy(apiHandle,
+ apiToCall,
+ currentMixerData->verbToCall,
+ json_object_get(requestJson),
+ &returnJ)) {
HalUtlHandleAppFwCallErrorInRequest(request, apiToCall, currentMixerData->verbToCall, returnJ, "call_action");
json_object_put(returnJ);
if(toReturnJ)
@@ -120,11 +116,11 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
}
if(wrap_json_unpack(returnJ, "{s:o}", "response", &responseJ)) {
- AFB_ReqFailF(request,
- "Seems that %s call to api %s succeed, but no response was found in : '%s'",
- currentMixerData->verbToCall,
- apiToCall,
- json_object_get_string(returnJ));
+ afb_req_fail_f(request,
+ "Seems that %s call to api %s succeed, but no response was found in : '%s'",
+ currentMixerData->verbToCall,
+ apiToCall,
+ json_object_get_string(returnJ));
json_object_put(returnJ);
if(toReturnJ)
json_object_put(toReturnJ);
@@ -135,8 +131,8 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
if((actionType == ACTION_ON_MIXER_STREAM ||
actionType == ACTION_ON_MIXER_ALL_STREAM) &&
((! currentMixerData->event) ||
- (AFB_EventPush(currentMixerData->event, json_object_get(responseJ)) < 0))) {
- AFB_ApiError(apiHandle, "Couldn't generate an event for stream %s", currentMixerData->verb);
+ (afb_event_push(currentMixerData->event, json_object_get(responseJ)) < 0))) {
+ AFB_API_ERROR(apiHandle, "Could not generate an event for stream %s", currentMixerData->verb);
}
switch(actionType) {
@@ -173,29 +169,29 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
switch(actionType) {
case ACTION_ON_MIXER_STREAM:
- AFB_ReqSuccessF(request,
- toReturnJ,
- "Action %s correctly transferred to %s without any error raised",
- currentMixerData->verbToCall,
- apiToCall);
+ afb_req_success_f(request,
+ toReturnJ,
+ "Action %s correctly transferred to %s without any error raised",
+ currentMixerData->verbToCall,
+ apiToCall);
break;
case ACTION_ON_MIXER_PLAYBACK:
- AFB_ReqSuccess(request,
- toReturnJ,
- "Actions correctly transferred to all playbacks without any error raised");
+ afb_req_success(request,
+ toReturnJ,
+ "Actions correctly transferred to all playbacks without any error raised");
break;
case ACTION_ON_MIXER_CAPTURE:
- AFB_ReqSuccess(request,
- toReturnJ,
- "Actions correctly transferred to all captures without any error raised");
+ afb_req_success(request,
+ toReturnJ,
+ "Actions correctly transferred to all captures without any error raised");
break;
case ACTION_ON_MIXER_ALL_STREAM:
- AFB_ReqSuccess(request,
- toReturnJ,
- "Actions correctly transferred to all streams without any error raised");
+ afb_req_success(request,
+ toReturnJ,
+ "Actions correctly transferred to all streams without any error raised");
break;
default:
@@ -203,22 +199,22 @@ void HalUtlActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
}
}
-void HalUtlActionOnStream(AFB_ReqT request)
+void HalUtlActionOnStream(afb_req_t request)
{
HalUtlActionOnMixer(request, ACTION_ON_MIXER_STREAM);
}
-void HalUtlActionOnPlayback(AFB_ReqT request)
+void HalUtlActionOnPlayback(afb_req_t request)
{
HalUtlActionOnMixer(request, ACTION_ON_MIXER_PLAYBACK);
}
-void HalUtlActionOnCapture(AFB_ReqT request)
+void HalUtlActionOnCapture(afb_req_t request)
{
HalUtlActionOnMixer(request, ACTION_ON_MIXER_CAPTURE);
}
-void HalUtlActionOnAllStream(AFB_ReqT request)
+void HalUtlActionOnAllStream(afb_req_t request)
{
HalUtlActionOnMixer(request, ACTION_ON_MIXER_ALL_STREAM);
}
@@ -227,7 +223,7 @@ void HalUtlActionOnAllStream(AFB_ReqT request)
* Add stream data and verb function *
******************************************************************************/
-struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandle,
+struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId)
@@ -242,7 +238,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandl
if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
return NULL;
- if((! (ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle))) ||
+ if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) ||
(! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
(! currentSpecificHalData->ctlHalSpecificData))
return NULL;
@@ -261,21 +257,20 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandl
return NULL;
}
- createdStreamData->event = AFB_EventMake(apiHandle, createdStreamData->verb);
- if(! AFB_EventIsValid(createdStreamData->event)) {
+ if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) {
HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
return NULL;
}
- if(AFB_ApiAddVerb(apiHandle,
- createdStreamData->verb,
- "Stream action transferred to mixer",
- HalUtlActionOnStream,
- (void *) createdStreamData,
- NULL,
- 0,
- 0)) {
- AFB_ApiError(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb);
+ if(afb_api_add_verb(apiHandle,
+ createdStreamData->verb,
+ "Stream action transferred to mixer",
+ HalUtlActionOnStream,
+ (void *) createdStreamData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_API_ERROR(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb);
HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
return NULL;
}
@@ -286,12 +281,12 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandl
"name", createdStreamData->verb,
"cardId", createdStreamData->streamCardId);
- AFB_EventPush(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamAddedEventJ);
+ afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamAddedEventJ);
return createdStreamData;
}
-int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
+int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId)
@@ -308,7 +303,7 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
return -1;
- if((! (ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle))) ||
+ if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) ||
(! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
(! currentSpecificHalData->ctlHalSpecificData))
return -2;
@@ -326,18 +321,18 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
"cardId", toRemoveStreamData->streamCardId);
if(afb_api_del_verb(apiHandle, verb, NULL)) {
- AFB_ApiError(apiHandle,"Error while deleting verb for stream : '%s'", verb);
+ AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb);
json_object_put(streamRemovedEventJ);
return -4;
}
if((returnedErr = HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) {
- AFB_ApiError(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb);
+ AFB_API_ERROR(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb);
json_object_put(streamRemovedEventJ);
return -5;
}
- AFB_EventPush(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamRemovedEventJ);
+ afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamRemovedEventJ);
return 0;
} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
index b77006d..ca065e7 100644
--- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -20,7 +20,7 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -33,17 +33,17 @@ enum ActionOnMixerType {
};
// Actions to be call when a stream verb is called
-void HalUtlActionOnStream(AFB_ReqT request);
-void HalUtlActionOnPlayback(AFB_ReqT request);
-void HalUtlActionOnCapture(AFB_ReqT request);
-void HalUtlActionOnAllStream(AFB_ReqT request);
+void HalUtlActionOnStream(afb_req_t request);
+void HalUtlActionOnPlayback(afb_req_t request);
+void HalUtlActionOnCapture(afb_req_t request);
+void HalUtlActionOnAllStream(afb_req_t request);
// Add/Remove stream data and verb functions
-struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandle,
+struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId);
-int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
+int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId);
diff --git a/4a-hal-utilities/4a-hal-utilities-verbs-loader.c b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
index f557f4c..16c28c4 100644
--- a/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
+++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-verbs-loader.h"
@@ -28,7 +28,7 @@
* Dynamic API common functions *
******************************************************************************/
-int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs)
+int HalUtlLoadVerbs(afb_api_t apiHandle, afb_verb_t *verbs)
{
int idx, errCount = 0;
@@ -36,14 +36,14 @@ int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs)
return -1;
for (idx = 0; verbs[idx].verb; idx++) {
- errCount+= AFB_ApiAddVerb(apiHandle,
- verbs[idx].verb,
- NULL,
- verbs[idx].callback,
- (void *) &verbs[idx],
- verbs[idx].auth,
- 0,
- 0);
+ errCount+= afb_api_add_verb(apiHandle,
+ verbs[idx].verb,
+ NULL,
+ verbs[idx].callback,
+ (void *) &verbs[idx],
+ verbs[idx].auth,
+ 0,
+ 0);
}
return errCount;
diff --git a/4a-hal-utilities/4a-hal-utilities-verbs-loader.h b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
index 2bfa1cd..9084595 100644
--- a/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
+++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
@@ -20,9 +20,9 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
// Verb that allows to add verb to a dynamic api
-int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs);
+int HalUtlLoadVerbs(afb_api_t apiHandle, afb_verb_t *verbs);
#endif /* _HAL_UTILITIES_VERBS_LOADER_INCLUDE_ */ \ No newline at end of file
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,
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index ba01394..81f2c10 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -22,6 +22,8 @@
#include <wrap-json.h>
+#include <afb/afb-binding.h>
+
#include "4a-hal-utilities-data.h"
#include "4a-hal-manager-cb.h"
@@ -32,9 +34,9 @@
******************************************************************************/
// TBD JAI : to implement
-void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ)
+void HalMgrDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ)
{
- AFB_ApiWarning(apiHandle, "Not implemented yet");
+ AFB_API_WARNING(apiHandle, "Not implemented yet");
// Use "4a-hal-manager-events.h" to handle events
}
@@ -42,58 +44,55 @@ void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_objec
* HAL Manager verbs functions *
******************************************************************************/
-void HalMgrPing(AFB_ReqT request)
+void HalMgrPing(afb_req_t request)
{
static int count = 0;
count++;
- AFB_ReqNotice(request, "ping count = %d", count);
- AFB_ReqSuccess(request, json_object_new_int(count), NULL);
+ AFB_REQ_NOTICE(request, "ping count = %d", count);
+ afb_req_success(request, json_object_new_int(count), NULL);
return;
}
-void HalMgrLoaded(AFB_ReqT request)
+void HalMgrLoaded(afb_req_t request)
{
int requestJsonErr = 0, allHal = 0, verbose = 0;
char cardIdString[32];
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *currentHalData;
json_object *requestJson, *requestAnswer, *apiObject;
- apiHandle = (AFB_ApiT ) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
currentHalData = HalMgrGlobalData->first;
if(! currentHalData) {
- AFB_ReqSuccess(request, NULL, "No Hal Api loaded");
+ afb_req_success(request, NULL, "No Hal Api loaded");
return;
}
requestAnswer = json_object_new_array();
if(! requestAnswer) {
- AFB_ReqFail(request, "json_answer", "Can't generate json answer");
+ afb_req_fail(request, "json_answer", "Can't generate json answer");
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
requestJsonErr = wrap_json_unpack(requestJson, "{s?:b s?:b}", "all", &allHal, "verbose", &verbose);
@@ -128,41 +127,38 @@ void HalMgrLoaded(AFB_ReqT request)
currentHalData = currentHalData->next;
}
- AFB_ReqSuccess(request, requestAnswer, "Requested data");
+ afb_req_success(request, requestAnswer, "Requested data");
}
-void HalMgrLoad(AFB_ReqT request)
+void HalMgrLoad(afb_req_t request)
{
int cardId = -1;
char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *addedHal;
json_object *requestJson, *apiReceviedMetadata;
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- 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(! json_object_object_get_ex(requestJson, "metadata", &apiReceviedMetadata)) {
- AFB_ReqFail(request, "api_metadata", "Can't get json metadata section to register external hal");
+ afb_req_fail(request, "api_metadata", "Can't get json metadata section to register external hal");
return;
}
@@ -175,7 +171,7 @@ void HalMgrLoad(AFB_ReqT request)
"version", &version,
"date", &date,
"snd-dev-id", &cardId)) {
- AFB_ReqFail(request, "api_metadata", "Can't metadata of api to register");
+ afb_req_fail(request, "api_metadata", "Can't metadata of api to register");
return;
}
@@ -204,75 +200,71 @@ void HalMgrLoad(AFB_ReqT request)
// TBD JAI: add subscription to this api status events, if subscription fails, remove hal from list
- AFB_ReqSuccess(request, NULL, "Api successfully registered");
+ afb_req_success(request, NULL, "Api successfully registered");
}
-void HalMgrUnload(AFB_ReqT request)
+void HalMgrUnload(afb_req_t request)
{
char *apiName;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *HalToRemove;
json_object *requestJson;
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- 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:s}", "api", &apiName)) {
- AFB_ReqFail(request, "requested_api", "Can't get api to remove");
+ afb_req_fail(request, "requested_api", "Can't get api to remove");
return;
}
- HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName);
- if(! HalToRemove) {
- AFB_ReqFail(request, "requested_api", "Can't find api to remove");
+ if(! (HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName))) {
+ afb_req_fail(request, "requested_api", "Can't find api to remove");
return;
}
if(HalToRemove->internal) {
- AFB_ReqFail(request, "requested_api", "Can't remove an internal controller api");
+ afb_req_fail(request, "requested_api", "Can't remove an internal controller api");
return;
}
if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->first, HalToRemove)) {
- AFB_ReqFail(request, "unregister_error", "Didn't succeed to remove specified api");
+ afb_req_fail(request, "unregister_error", "Didn't succeed to remove specified api");
return;
}
// TBD JAI: remove subscription to this api status events
- AFB_ReqSuccess(request, NULL, "Api successfully unregistered");
+ afb_req_success(request, NULL, "Api successfully unregistered");
}
// TBD JAI : to implement
-void HalMgrSubscribeEvent(AFB_ReqT request)
+void HalMgrSubscribeEvent(afb_req_t request)
{
- AFB_ReqWarning(request, "Not implemented yet");
+ AFB_REQ_WARNING(request, "Not implemented yet");
- AFB_ReqSuccess(request, json_object_new_boolean(0), NULL);
+ afb_req_success(request, json_object_new_boolean(0), NULL);
}
// TBD JAI : to implement
-void HalMgrUnsubscribeEvent(AFB_ReqT request)
+void HalMgrUnsubscribeEvent(afb_req_t request)
{
- AFB_ReqWarning(request, "Not implemented yet");
+ AFB_REQ_WARNING(request, "Not implemented yet");
- AFB_ReqSuccess(request, json_object_new_boolean(0), NULL);
+ afb_req_success(request, json_object_new_boolean(0), NULL);
}
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.h b/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
index dbed634..e0e144f 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
@@ -20,17 +20,17 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
// Event handler
-void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ);
+void HalMgrDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ);
// Exported verbs callbacks
-void HalMgrPing(AFB_ReqT request);
-void HalMgrLoaded(AFB_ReqT request);
-void HalMgrLoad(AFB_ReqT request);
-void HalMgrUnload(AFB_ReqT request);
-void HalMgrSubscribeEvent(AFB_ReqT request);
-void HalMgrUnsubscribeEvent(AFB_ReqT request);
+void HalMgrPing(afb_req_t request);
+void HalMgrLoaded(afb_req_t request);
+void HalMgrLoad(afb_req_t request);
+void HalMgrUnload(afb_req_t request);
+void HalMgrSubscribeEvent(afb_req_t request);
+void HalMgrUnsubscribeEvent(afb_req_t request);
#endif /* _HALMGR_CB_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-events.h b/4a-hal/4a-hal-manager/4a-hal-manager-events.h
index 30034cf..bf0d9ff 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-events.h
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-events.h
@@ -20,7 +20,7 @@
#include <stdio.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
// TBD JAI: declare events handlers functions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c
index c510d17..75177e7 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.c
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-verbs-loader.h"
@@ -31,7 +31,7 @@
#include "4a-hal-manager-cb.h"
// Default api to print log when apihandle not available
-AFB_ApiT AFB_default;
+afb_api_t AFB_default;
// Local (static) Hal manager data structure
static struct HalMgrData localHalMgrGlobalData;
@@ -41,7 +41,7 @@ static struct HalMgrData localHalMgrGlobalData;
******************************************************************************/
// Hal manager exported verbs
-AFB_ApiVerbs HalManagerApiStaticVerbs[] =
+afb_verb_t HalManagerApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "ping", .callback = HalMgrPing, .info = "Ping test"},
@@ -67,7 +67,7 @@ struct SpecificHalData **HalMngGetFirstHalData(void)
* Dynamic API functions for hal manager *
******************************************************************************/
-static int HalMgrInitApi(AFB_ApiT apiHandle)
+static int HalMgrInitApi(afb_api_t apiHandle)
{
struct SpecificHalData *currentCtlHalData;
struct HalMgrData *HalMgrGlobalData;
@@ -79,8 +79,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
AFB_default = apiHandle;
// Retrieve section config from api handle
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData)
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle)))
return -2;
if(HalUtlInitializeHalMgrData(apiHandle, HalMgrGlobalData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO))
@@ -91,7 +90,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
while(currentCtlHalData) {
if(! currentCtlHalData->apiName)
return -4;
- else if(AFB_RequireApi(apiHandle, currentCtlHalData->apiName, 1))
+ else if(afb_api_require_api(apiHandle, currentCtlHalData->apiName, 1))
return -5;
currentCtlHalData = currentCtlHalData->next;
@@ -100,7 +99,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
return 0;
}
-static int HalMgrLoadApi(void *cbdata, AFB_ApiT apiHandle)
+static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle)
{
struct HalMgrData *HalMgrGlobalData;
@@ -110,39 +109,39 @@ static int HalMgrLoadApi(void *cbdata, AFB_ApiT apiHandle)
HalMgrGlobalData = (struct HalMgrData *) cbdata;
// Save closure as api's data context
- AFB_ApiSetUserData(apiHandle, HalMgrGlobalData);
+ afb_api_set_userdata(apiHandle, HalMgrGlobalData);
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, HalManagerApiStaticVerbs)) {
- AFB_ApiError(apiHandle, "Load section : fail to register static verbs");
+ AFB_API_ERROR(apiHandle, "Load section : fail to register static verbs");
return 1;
}
// Declare an event manager for Hal Manager
- AFB_ApiOnEvent(apiHandle, HalMgrDispatchApiEvent);
+ afb_api_on_event(apiHandle, HalMgrDispatchApiEvent);
// Init Api function (does not receive user closure ???)
- AFB_ApiOnInit(apiHandle, HalMgrInitApi);
+ afb_api_on_init(apiHandle, HalMgrInitApi);
- AFB_ApiSeal(apiHandle);
+ afb_api_seal(apiHandle);
return 0;
}
-int HalMgrCreateApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData)
{
if(! apiHandle || ! HalMgrGlobalData)
return -1;
// Create one API
- return AFB_NewApi(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, HalMgrGlobalData) ? 0 : -1;
+ return afb_api_new_api(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, HalMgrGlobalData) ? 0 : -1;
}
/*******************************************************************************
* Startup function *
******************************************************************************/
-int afbBindingEntry(AFB_ApiT apiHandle)
+int afbBindingEntry(afb_api_t apiHandle)
{
int status = 0, rc;
@@ -152,7 +151,7 @@ int afbBindingEntry(AFB_ApiT apiHandle)
// Hugely hack to make all V2 AFB_DEBUG to work in fileutils
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Binding start");
+ AFB_API_NOTICE(apiHandle, "Binding start");
// Load Hal-Manager using Api v3
rc = HalMgrCreateApi(apiHandle, &localHalMgrGlobalData);
diff --git a/plugins/lib/bluealsa/hal-bluealsa-transports.c b/plugins/lib/bluealsa/hal-bluealsa-transports.c
index 2c58023..56e1a29 100644
--- a/plugins/lib/bluealsa/hal-bluealsa-transports.c
+++ b/plugins/lib/bluealsa/hal-bluealsa-transports.c
@@ -105,7 +105,7 @@ int halBlueAlsaTransportUpdate(
char transportS[HAL_BLUEALSA_TRANSPORT_LEN_MAX];
- AFB_ApiInfo(watch->plugin->api,
+ AFB_API_INFO(watch->plugin->api,
"Unregister transport %s",
halBlueAlsaTransportAsString(transportS, HAL_BLUEALSA_TRANSPORT_LEN_MAX, &transport->transport));
diff --git a/plugins/lib/bluealsa/hal-bluealsa-transports.h b/plugins/lib/bluealsa/hal-bluealsa-transports.h
index 0c5d6a4..d5b277f 100644
--- a/plugins/lib/bluealsa/hal-bluealsa-transports.h
+++ b/plugins/lib/bluealsa/hal-bluealsa-transports.h
@@ -22,7 +22,7 @@
#include <stdbool.h>
#include <urcu/list.h>
-#include "afb-definitions.h"
+#include <afb/afb-binding.h>
#include "hal-bluealsa-watch.h"
typedef struct {
diff --git a/plugins/lib/bluealsa/hal-bluealsa.c b/plugins/lib/bluealsa/hal-bluealsa.c
index c8cfe98..502bfc6 100644
--- a/plugins/lib/bluealsa/hal-bluealsa.c
+++ b/plugins/lib/bluealsa/hal-bluealsa.c
@@ -48,7 +48,7 @@ CTLP_CAPI_REGISTER(HAL_BLUEALSA_PLUGIN_NAME)
// Call at initialization time ('requires' are forbidden at this stage)
CTLP_ONLOAD(plugin, callbacks)
{
- AFB_ApiNotice(plugin->api, "%s Plugin Registered correctly: uid='%s' 'info='%s'", HAL_BLUEALSA_PLUGIN_NAME, plugin->uid, plugin->info);
+ AFB_API_NOTICE(plugin->api, "%s Plugin Registered correctly: uid='%s' 'info='%s'", HAL_BLUEALSA_PLUGIN_NAME, plugin->uid, plugin->info);
return 0;
}
@@ -63,8 +63,8 @@ CTLP_INIT(plugin, callbacks)
"info", "Init Bluez-Alsa hal plugin",
"action", "plugin://hal-bluealsa#init");
- if (!(ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(plugin->api))) {
- AFB_ApiError(plugin->api, "Can't get current hal controller config");
+ if (!(ctrlConfig = (CtlConfigT *) afb_api_get_userdata(plugin->api))) {
+ AFB_API_ERROR(plugin->api, "Can't get current hal controller config");
goto fail;
}
@@ -73,16 +73,16 @@ CTLP_INIT(plugin, callbacks)
idx++;
if (!ctrlConfig->sections[idx].key) {
- AFB_ApiError(plugin->api, "Wasn't able to add '%s' as a new onload, 'onload' section not found", json_object_get_string(actionsToAdd));
+ AFB_API_ERROR(plugin->api, "Wasn't able to add '%s' as a new onload, 'onload' section not found", json_object_get_string(actionsToAdd));
goto fail;
}
if(AddActionsToSection(plugin->api, &ctrlConfig->sections[idx], actionsToAdd, 0)) {
- AFB_ApiError(plugin->api, "Wasn't able to add '%s' as a new onload to %s", json_object_get_string(actionsToAdd), ctrlConfig->sections[idx].uid);
+ AFB_API_ERROR(plugin->api, "Wasn't able to add '%s' as a new onload to %s", json_object_get_string(actionsToAdd), ctrlConfig->sections[idx].uid);
goto fail;
}
- AFB_ApiNotice(plugin->api, "Plugin initialization of %s plugin correctly done", HAL_BLUEALSA_PLUGIN_NAME);
+ AFB_API_NOTICE(plugin->api, "Plugin initialization of %s plugin correctly done", HAL_BLUEALSA_PLUGIN_NAME);
return 0;
fail:
@@ -94,7 +94,7 @@ fail:
// Call at controller onload time
CTLP_CAPI(init, source, argsJ, queryJ)
{
- AFB_ApiNotice(source->api, "Controller onload event");
+ AFB_API_NOTICE(source->api, "Controller onload event");
CtlPluginT * plugin = source->plugin;
@@ -123,29 +123,29 @@ CTLP_CAPI(init, source, argsJ, queryJ)
"a2dp", &a2dpParamsJ);
if (error) {
- AFB_ApiError(plugin->api, "%s: wrong parameters", __func__);
+ AFB_API_ERROR(plugin->api, "%s: wrong parameters", __func__);
goto fail;
}
if (scoParamsJ) {
- AFB_ApiInfo(plugin->api, "%s: sco parameters: %s", __func__, json_object_get_string(scoParamsJ));
+ AFB_API_INFO(plugin->api, "%s: sco parameters: %s", __func__, json_object_get_string(scoParamsJ));
error = wrap_json_unpack(scoParamsJ, "{s:s,s:s,s?i !}",
"mic", &pluginData->sco.mic,
"zone", &pluginData->sco.speaker,
"delayms", &pluginData->sco.delayms);
if (error) {
- AFB_ApiError(plugin->api, "%s: wrong sco parameters: err %s", __func__, wrap_json_get_error_string(error));
+ AFB_API_ERROR(plugin->api, "%s: wrong sco parameters: err %s", __func__, wrap_json_get_error_string(error));
goto fail;
}
}
if (a2dpParamsJ) {
- AFB_ApiInfo(plugin->api, "%s: a2dp parameters: %s", __func__, json_object_get_string(a2dpParamsJ));
+ AFB_API_INFO(plugin->api, "%s: a2dp parameters: %s", __func__, json_object_get_string(a2dpParamsJ));
error = wrap_json_unpack(a2dpParamsJ, "{s:s,s?i !}",
"zone", &pluginData->a2dp.zone,
"delayms", &pluginData->a2dp.delayms);
if (error) {
- AFB_ApiError(plugin->api, "%s: wrong a2dp parameters: err=%s", __func__, wrap_json_get_error_string(error));
+ AFB_API_ERROR(plugin->api, "%s: wrong a2dp parameters: err=%s", __func__, wrap_json_get_error_string(error));
goto fail;
}
}
@@ -171,13 +171,13 @@ static int halBlueAlsaTransportEventCB(sd_event_source* src, int fd, uint32_t re
struct ba_msg_event event;
ssize_t ret;
- AFB_ApiDebug(plugin->api, "--- %s ----!", __func__);
+ AFB_API_DEBUG(plugin->api, "--- %s ----!", __func__);
if ((revents & EPOLLIN) == 0)
goto done;
if (revents & EPOLLHUP) {
- AFB_ApiInfo(plugin->api, "Lost connection with bluealsa on interface %s", watch->interface);
+ AFB_API_INFO(plugin->api, "Lost connection with bluealsa on interface %s", watch->interface);
sd_event_source_unref(src);
close(fd);
halBlueAlsaRegister(plugin, watch->interface);
@@ -188,7 +188,7 @@ static int halBlueAlsaTransportEventCB(sd_event_source* src, int fd, uint32_t re
continue;
if (ret != sizeof(event)) {
- AFB_ApiError(plugin->api, "Couldn't read event: %s", strerror(ret == -1 ? errno : EBADMSG));
+ AFB_API_ERROR(plugin->api, "Couldn't read event: %s", strerror(ret == -1 ? errno : EBADMSG));
goto done;
}
@@ -461,7 +461,7 @@ static int halBlueAlsaAttachTransportStreams(bluealsa_transport_t * transport) {
delayms = pluginData->a2dp.delayms;
playbackZoneS = pluginData->a2dp.zone;
} else {
- AFB_ApiError(plugin->api, "%s: unsupported transport type", __func__ );
+ AFB_API_ERROR(plugin->api, "%s: unsupported transport type", __func__ );
goto fail;
}
@@ -556,8 +556,8 @@ static int halBlueAlsaAttachTransportStreams(bluealsa_transport_t * transport) {
/* In softmixer, this will create a transaction verb (whose name is transactionUidS),
* will be used later to destroy all the created objects upon transport removal */
- if (AFB_ServiceSync(plugin->api, SMIXER_API_NAME, "attach", requestJ, &returnJ)) {
- AFB_ApiError(plugin->api, "Error calling attach verb of mixer" );
+ if (afb_api_call_sync_legacy(plugin->api, SMIXER_API_NAME, "attach", requestJ, &returnJ)) {
+ AFB_API_ERROR(plugin->api, "Error calling attach verb of mixer" );
goto done;
}
@@ -572,7 +572,7 @@ static int halBlueAlsaAttachTransportStreams(bluealsa_transport_t * transport) {
fail:
return -1;
done:
- AFB_ApiDebug(plugin->api, "DONE.");
+ AFB_API_DEBUG(plugin->api, "DONE.");
return ret;
}
@@ -583,7 +583,7 @@ static int halBluezAlsaRemoveTransportStream(bluealsa_transport_t * transport) {
json_object* requestJ = NULL;
json_object* returnJ = NULL;
- AFB_ApiInfo(plugin->api, "Call transaction detach verb %s", transport->transactionUidS);
+ AFB_API_INFO(plugin->api, "Call transaction detach verb %s", transport->transactionUidS);
if (transport->transactionUidS == NULL)
goto fail;
@@ -593,8 +593,8 @@ static int halBluezAlsaRemoveTransportStream(bluealsa_transport_t * transport) {
json_object_object_add(requestJ, "action", json_object_new_string("remove"));
- if (AFB_ServiceSync(plugin->api, SMIXER_API_NAME, transport->transactionUidS, requestJ, &returnJ)) {
- AFB_ApiError(plugin->api, "Error calling attach verb of mixer" );
+ if (afb_api_call_sync_legacy(plugin->api, SMIXER_API_NAME, transport->transactionUidS, requestJ, &returnJ)) {
+ AFB_API_ERROR(plugin->api, "Error calling attach verb of mixer" );
goto fail;
}
@@ -616,14 +616,14 @@ static int halBlueAlsaFetchTransports(bluealsa_watch * watch) {
bluealsa_transport_t * transport_list = &pluginData->transport_list;
bluealsa_transport_t * transport = NULL;
- AFB_ApiDebug(plugin->api, "Fetching available transports of interface %s", watch->interface);
+ AFB_API_DEBUG(plugin->api, "Fetching available transports of interface %s", watch->interface);
if ((nbTransports = bluealsa_get_transports(watch->fd, &transports)) == -1) {
- AFB_ApiError(plugin->api, "Couldn't get transports: %s", strerror(errno));
+ AFB_API_ERROR(plugin->api, "Couldn't get transports: %s", strerror(errno));
goto done;
}
- AFB_ApiDebug(plugin->api, "Got %zu transport(s)", nbTransports);
+ AFB_API_DEBUG(plugin->api, "Got %zu transport(s)", nbTransports);
for (int ix=0; ix<nbTransports; ix++) {
char addr[18];
@@ -637,27 +637,27 @@ static int halBlueAlsaFetchTransports(bluealsa_watch * watch) {
else
typeS = "unknown";
- AFB_ApiDebug(plugin->api, "Transport %d: type %s, dev %s", ix, typeS, addr);
+ AFB_API_DEBUG(plugin->api, "Transport %d: type %s, dev %s", ix, typeS, addr);
if (halBlueAlsaTransportFind(watch, transport_list, ba_transport)) {
- AFB_ApiDebug(plugin->api, "This transport is already streamed");
+ AFB_API_DEBUG(plugin->api, "This transport is already streamed");
continue;
}
- AFB_ApiInfo(plugin->api, "Registering transport type %s, dev %s", typeS, addr);
+ AFB_API_INFO(plugin->api, "Registering transport type %s, dev %s", typeS, addr);
transport = halBlueAlsaTransportsAdd(watch, transport_list, ba_transport);
if (transport == NULL) {
- AFB_ApiError(plugin->api, "Failed to register this transport");
+ AFB_API_ERROR(plugin->api, "Failed to register this transport");
goto done;
}
// Do the softmixer stuff
if (halBlueAlsaAttachTransportStreams(transport) != 0) {
- AFB_ApiError(plugin->api, "Failed create transport streams");
+ AFB_API_ERROR(plugin->api, "Failed create transport streams");
goto done;
}
- AFB_ApiDebug(plugin->api, "%s: transaction id %s", __func__, transport->transactionUidS);
+ AFB_API_DEBUG(plugin->api, "%s: transaction id %s", __func__, transport->transactionUidS);
}
@@ -673,7 +673,7 @@ static int halBlueAlsaRegister(CtlPluginT* plugin, const char * interface) {
sd_event *sdLoop;
sd_event_source* evtsrc;
- sdLoop = AFB_GetEventLoop(plugin->api);
+ sdLoop = afb_api_get_event_loop(plugin->api);
enum ba_event transport_mask = BA_EVENT_TRANSPORT_ADDED |
// BA_EVENT_TRANSPORT_CHANGED |
@@ -687,20 +687,20 @@ static int halBlueAlsaRegister(CtlPluginT* plugin, const char * interface) {
watch->plugin = plugin;
if ((watch->fd = bluealsa_open(interface)) == -1) {
- AFB_ApiError(plugin->api, "BlueALSA connection failed: %s", strerror(errno));
+ AFB_API_ERROR(plugin->api, "BlueALSA connection failed: %s", strerror(errno));
goto fail;
}
halBlueAlsaFetchTransports(watch);
if (bluealsa_subscribe(watch->fd, transport_mask) == -1) {
- AFB_ApiError(plugin->api, "BlueALSA subscription failed: %s", strerror(errno));
+ AFB_API_ERROR(plugin->api, "BlueALSA subscription failed: %s", strerror(errno));
goto fail;
}
// Register sound event to the main loop of the binder
if ((ret = sd_event_add_io(sdLoop, &evtsrc, watch->fd, EPOLLIN, halBlueAlsaTransportEventCB, watch)) < 0) {
- AFB_ApiError(plugin->api,
+ AFB_API_ERROR(plugin->api,
"%s: Failed to register event fd to io loop",
__func__);
goto fail;