aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-21 17:07:36 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:58 +0100
commit756f8d02b445631df44243d528165fb1fe414487 (patch)
tree1ef835068d6cf24f33eeb0a0a136865a23a1884e /plugins
parent524ad81cd52d52555d0e6cbaf865f6bb6cfecb25 (diff)
Move from controller functions to afb functions
Move from controller 'afb-definitions.h' functions to application framework 'afb/afb-binding.h' functions. Change-Id: I4cd62af881ef8ac949b082ede9dfcc4736d1e12c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'plugins')
-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
3 files changed, 37 insertions, 37 deletions
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;