aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-07-19 17:22:00 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-07-20 11:39:37 +0000
commit7b20b115c4ec4b9c157d19d5154453f5c751a5d6 (patch)
tree3a56e02b4aaff0cc0bf205f27134d40a617dda59
parent2209293bec9ce0cff772dedbec326704f5a2ca42 (diff)
Use some app-fwk macros to support v2 and v3
Use some application framework macros to support both v2 and v3 compilation. Change-Id: I3051bbeff8788ea2c71545e5d253619d4749ff41 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--alsa-binding/Alsa-AddCtl.c4
-rw-r--r--alsa-binding/Alsa-ApiHat.c6
-rw-r--r--alsa-binding/Alsa-ApiHat.h30
-rw-r--r--alsa-binding/Alsa-RegEvt.c16
-rw-r--r--alsa-binding/Alsa-SetGet.c12
-rw-r--r--alsa-binding/Alsa-Ucm.c12
6 files changed, 42 insertions, 38 deletions
diff --git a/alsa-binding/Alsa-AddCtl.c b/alsa-binding/Alsa-AddCtl.c
index 02bc268..60be790 100644
--- a/alsa-binding/Alsa-AddCtl.c
+++ b/alsa-binding/Alsa-AddCtl.c
@@ -83,7 +83,7 @@ static const unsigned int *allocate_int_linear_tlv(int max, int min) {
return tlv;
}
-STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_object *ctlJ, queryModeE queryMode) {
+STATIC json_object * addOneSndCtl(afb_req_t request, snd_ctl_t *ctlDev, json_object *ctlJ, queryModeE queryMode) {
int err, done, ctlNumid, ctlValue=0, shouldCreate;
json_object *tmpJ;
const char *ctlName;
@@ -345,7 +345,7 @@ OnErrorExit:
return NULL;
}
-PUBLIC void alsaAddCustomCtls(afb_req request) {
+PUBLIC void alsaAddCustomCtls(afb_req_t request) {
int err;
json_object *ctlsJ, *ctlsValues, *ctlValues;
enum json_type;
diff --git a/alsa-binding/Alsa-ApiHat.c b/alsa-binding/Alsa-ApiHat.c
index 7c5f29e..f43e421 100644
--- a/alsa-binding/Alsa-ApiHat.c
+++ b/alsa-binding/Alsa-ApiHat.c
@@ -30,7 +30,7 @@
#include "Alsa-ApiHat.h"
-STATIC void pingtest(struct afb_req request) {
+STATIC void pingtest(afb_req_t request) {
json_object *query = afb_req_json(request);
afb_req_success(request, json_object_get(query), NULL);
}
@@ -38,7 +38,7 @@ STATIC void pingtest(struct afb_req request) {
/*
* array of the verbs exported to afb-daemon
*/
-static const struct afb_verb_v2 api_verbs[] = {
+static const afb_verb_t api_verbs[] = {
/* VERB'S NAME FUNCTION TO CALL */
{ .verb = "ping", .callback = pingtest, .info="Ping Presence Check on API"},
{ .verb = "infoget", .callback = alsaGetInfo, .info="Return sound cards list"},
@@ -61,7 +61,7 @@ static const struct afb_verb_v2 api_verbs[] = {
/*
* description of the binding for afb-daemon
*/
-const afb_binding_v2 afbBindingV2 = {
+const afb_binding_t afbBindingExport = {
.api = "alsacore",
.verbs = api_verbs,
};
diff --git a/alsa-binding/Alsa-ApiHat.h b/alsa-binding/Alsa-ApiHat.h
index 7e7c349..eaef9c7 100644
--- a/alsa-binding/Alsa-ApiHat.h
+++ b/alsa-binding/Alsa-ApiHat.h
@@ -74,29 +74,29 @@ typedef struct {
// import from AlsaAfbBinding
extern const struct afb_binding_interface *afbIface;
-PUBLIC json_object *alsaCheckQuery (struct afb_req request, queryValuesT *queryValues);
+PUBLIC json_object *alsaCheckQuery (afb_req_t request, queryValuesT *queryValues);
// AlseCoreSetGet exports
PUBLIC int alsaGetSingleCtl (snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlRequestT *ctlRequest, queryModeE queryMode);
-PUBLIC void alsaGetInfo (struct afb_req request);
-PUBLIC void alsaGetCtls(struct afb_req request);
-PUBLIC void alsaSetCtls(struct afb_req request);
+PUBLIC void alsaGetInfo (afb_req_t request);
+PUBLIC void alsaGetCtls(afb_req_t request);
+PUBLIC void alsaSetCtls(afb_req_t request);
// AlsaUseCase exports
-PUBLIC void alsaUseCaseQuery(struct afb_req request);
-PUBLIC void alsaUseCaseSet(struct afb_req request);
-PUBLIC void alsaUseCaseGet(struct afb_req request);
-PUBLIC void alsaUseCaseClose(struct afb_req request);
-PUBLIC void alsaUseCaseReset(struct afb_req request);
-PUBLIC void alsaAddCustomCtls(struct afb_req request);
+PUBLIC void alsaUseCaseQuery(afb_req_t request);
+PUBLIC void alsaUseCaseSet(afb_req_t request);
+PUBLIC void alsaUseCaseGet(afb_req_t request);
+PUBLIC void alsaUseCaseClose(afb_req_t request);
+PUBLIC void alsaUseCaseReset(afb_req_t request);
+PUBLIC void alsaAddCustomCtls(afb_req_t request);
// AlsaRegEvt
-PUBLIC void alsaEvtSubcribe (struct afb_req request);
-PUBLIC void alsaGetCardId (struct afb_req request);
-PUBLIC void alsaRegisterHal (struct afb_req request);
-PUBLIC void alsaActiveHal (struct afb_req request);
-PUBLIC void alsaPcmInfo (struct afb_req request);
+PUBLIC void alsaEvtSubcribe (afb_req_t request);
+PUBLIC void alsaGetCardId (afb_req_t request);
+PUBLIC void alsaRegisterHal (afb_req_t request);
+PUBLIC void alsaActiveHal (afb_req_t request);
+PUBLIC void alsaPcmInfo (afb_req_t request);
#endif /* ALSALIBMAPPING_H */
diff --git a/alsa-binding/Alsa-RegEvt.c b/alsa-binding/Alsa-RegEvt.c
index a4f552f..974431e 100644
--- a/alsa-binding/Alsa-RegEvt.c
+++ b/alsa-binding/Alsa-RegEvt.c
@@ -31,7 +31,7 @@ typedef struct {
sd_event_source *src;
snd_ctl_t *ctlDev;
int mode;
- struct afb_event afbevt;
+ afb_event_t afbevt;
} evtHandleT;
typedef struct {
@@ -61,7 +61,7 @@ STATIC int getHalIdxFromCardid (int cardid) {
return -1;
}
-PUBLIC json_object *alsaCheckQuery(afb_req request, queryValuesT *queryValues) {
+PUBLIC json_object *alsaCheckQuery(afb_req_t request, queryValuesT *queryValues) {
json_object *tmpJ;
int done;
@@ -164,7 +164,7 @@ OnErrorExit:
// Subscribe to every Alsa CtlEvent send by a given board
-PUBLIC void alsaEvtSubcribe(afb_req request) {
+PUBLIC void alsaEvtSubcribe(afb_req_t request) {
static sndHandleT sndHandles[MAX_SND_CARD];
evtHandleT *evtHandle = NULL;
snd_ctl_t *ctlDev = NULL;
@@ -261,7 +261,7 @@ OnErrorExit:
// Subscribe to every Alsa CtlEvent send by a given board
-STATIC json_object *alsaProbeCardId(afb_req request) {
+STATIC json_object *alsaProbeCardId(afb_req_t request) {
char devid [32];
const char *ctlName, *shortname, *longname, *mixername, *drivername;
int done, mode, card, err, index, idx;
@@ -375,7 +375,7 @@ OnErrorExit:
// Make alsaProbeCardId compatible with AFB request
-PUBLIC void alsaGetCardId(afb_req request) {
+PUBLIC void alsaGetCardId(afb_req_t request) {
json_object *responseJ = alsaProbeCardId(request);
if (responseJ) afb_req_success(request, responseJ, NULL);
@@ -403,7 +403,7 @@ OnErrorExit:
// Return list of active resgistrated HAL with corresponding sndcard
-PUBLIC void alsaActiveHal(afb_req request) {
+PUBLIC void alsaActiveHal(afb_req_t request) {
json_object *responseJ = json_object_new_array();
for (int idx = 0; idx < MAX_SND_HAL; idx++) {
@@ -424,7 +424,7 @@ PUBLIC void alsaActiveHal(afb_req request) {
// Register loaded HAL with board Name and API prefix
-PUBLIC void alsaRegisterHal(afb_req request) {
+PUBLIC void alsaRegisterHal(afb_req_t request) {
static int index = 0;
json_object *responseJ;
const char *shortname, *apiPrefix;
@@ -485,7 +485,7 @@ OnErrorExit:
return;
}
-PUBLIC void alsaPcmInfo (struct afb_req request) {
+PUBLIC void alsaPcmInfo (afb_req_t request) {
int done, mode, err;
json_object *tmpJ, *responseJ = NULL;
snd_pcm_t *pcmHandle = NULL;
diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c
index 6983817..b0b8949 100644
--- a/alsa-binding/Alsa-SetGet.c
+++ b/alsa-binding/Alsa-SetGet.c
@@ -409,7 +409,11 @@ STATIC json_object* alsaCardProbe(const char *rqt, InfoGetT infoType) {
name = snd_ctl_card_info_get_name(cardinfo);
json_object_object_add(ctlDev, "name", json_object_new_string(name));
+#if(AFB_BINDING_VERSION == 3)
+ if (afb_api_wants_log_level(afbBindingV3root, AFB_SYSLOG_LEVEL_NOTICE)) {
+#else
if (afb_get_verbosity() >= AFB_VERBOSITY_LEVEL_NOTICE) {
+#endif
driver = snd_ctl_card_info_get_driver(cardinfo);
json_object_object_add(ctlDev, "driver", json_object_new_string(driver));
info = strdup(snd_ctl_card_info_get_longname(cardinfo));
@@ -426,7 +430,7 @@ STATIC json_object* alsaCardProbe(const char *rqt, InfoGetT infoType) {
// Loop on every potential Sound card and register active one
-PUBLIC void alsaGetInfo(afb_req request) {
+PUBLIC void alsaGetInfo(afb_req_t request) {
int card;
json_object *ctlDev, *ctlDevs;
char devid[32];
@@ -708,7 +712,7 @@ OnErrorExit:
// assign multiple control to the same value
-STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req request) {
+STATIC void alsaSetGetCtls(ActionSetGetT action, afb_req_t request) {
ctlRequestT *ctlRequest;
const char *warmsg = NULL;
int err = 0, status = 0, done;
@@ -873,11 +877,11 @@ OnErrorExit:
return;
}
-PUBLIC void alsaGetCtls(afb_req request) {
+PUBLIC void alsaGetCtls(afb_req_t request) {
alsaSetGetCtls(ACTION_GET, request);
}
-PUBLIC void alsaSetCtls(afb_req request) {
+PUBLIC void alsaSetCtls(afb_req_t request) {
alsaSetGetCtls(ACTION_SET, request);
}
diff --git a/alsa-binding/Alsa-Ucm.c b/alsa-binding/Alsa-Ucm.c
index 0c65f2c..3e0687c 100644
--- a/alsa-binding/Alsa-Ucm.c
+++ b/alsa-binding/Alsa-Ucm.c
@@ -51,7 +51,7 @@ static ucmHandleT ucmHandles[MAX_SND_CARD];
// Cache opened UCM handles
-STATIC int alsaUseCaseOpen(struct afb_req request, queryValuesT *queryValues, int allowNewMgr) {
+STATIC int alsaUseCaseOpen(afb_req_t request, queryValuesT *queryValues, int allowNewMgr) {
snd_ctl_t *ctlDev=NULL;
snd_ctl_card_info_t *cardinfo;
snd_use_case_mgr_t *ucmHandle;
@@ -110,7 +110,7 @@ OnErrorExit:
return -1;
}
-PUBLIC void alsaUseCaseQuery(struct afb_req request) {
+PUBLIC void alsaUseCaseQuery(afb_req_t request) {
int verbCount, ucmIdx;
const char **verbList;
snd_use_case_mgr_t *ucmHandle;
@@ -233,7 +233,7 @@ OnErrorExit:
return (NULL);
}
-PUBLIC void alsaUseCaseGet(struct afb_req request) {
+PUBLIC void alsaUseCaseGet(afb_req_t request) {
int ucmIdx, labelCount;
queryValuesT queryValues;
json_object *jResponse = json_object_new_object();
@@ -318,7 +318,7 @@ OnErrorExit:
return;
}
-PUBLIC void alsaUseCaseSet(struct afb_req request) {
+PUBLIC void alsaUseCaseSet(afb_req_t request) {
int err, ucmIdx;
queryValuesT queryValues;
json_object *jResponse = json_object_new_object();
@@ -383,7 +383,7 @@ OnErrorExit:
return;
}
-PUBLIC void alsaUseCaseReset(struct afb_req request) {
+PUBLIC void alsaUseCaseReset(afb_req_t request) {
int err, ucmIdx;
queryValuesT queryValues;
@@ -405,7 +405,7 @@ OnErrorExit:
return;
}
-PUBLIC void alsaUseCaseClose(struct afb_req request) {
+PUBLIC void alsaUseCaseClose(afb_req_t request) {
int err, ucmIdx;
queryValuesT queryValues;