From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This fixes --disable-avrcp causing build errors. Fixes: https://github.com/bluez/bluez/issues/1061 --- Makefile.plugins | 9 +++++---- configure.ac | 3 +++ profiles/audio/media.c | 38 +++++++++++++++++++++++++++++++++++++- profiles/audio/transport.c | 10 ++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/Makefile.plugins b/Makefile.plugins index 7644041b3b6d..97335d643028 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -8,6 +8,10 @@ builtin_sources += plugins/autopair.c builtin_modules += policy builtin_sources += plugins/policy.c +builtin_sources += profiles/audio/media.h profiles/audio/media.c \ + profiles/audio/transport.h profiles/audio/transport.c \ + profiles/audio/player.h profiles/audio/player.c + if ADMIN builtin_modules += admin builtin_sources += plugins/admin.c @@ -32,8 +36,6 @@ builtin_sources += profiles/audio/source.h profiles/audio/source.c \ profiles/audio/sink.h profiles/audio/sink.c \ profiles/audio/a2dp.h profiles/audio/a2dp.c \ profiles/audio/avdtp.h profiles/audio/avdtp.c \ - profiles/audio/media.h profiles/audio/media.c \ - profiles/audio/transport.h profiles/audio/transport.c \ profiles/audio/a2dp-codecs.h endif @@ -42,8 +44,7 @@ if AVRCP builtin_modules += avrcp builtin_sources += profiles/audio/control.h profiles/audio/control.c \ profiles/audio/avctp.h profiles/audio/avctp.c \ - profiles/audio/avrcp.h profiles/audio/avrcp.c \ - profiles/audio/player.h profiles/audio/player.c + profiles/audio/avrcp.h profiles/audio/avrcp.c endif if NETWORK diff --git a/configure.ac b/configure.ac index 01f0f2ba04c0..964206bf17f0 100644 --- a/configure.ac +++ b/configure.ac @@ -180,6 +180,9 @@ AM_CONDITIONAL(A2DP, test "${enable_a2dp}" != "no") AC_ARG_ENABLE(avrcp, AS_HELP_STRING([--disable-avrcp], [disable AVRCP profile]), [enable_avrcp=${enableval}]) AM_CONDITIONAL(AVRCP, test "${enable_avrcp}" != "no") +if test "${enable_avrcp}" != "no"; then + AC_DEFINE(HAVE_AVRCP, 1, [Define to 1 if you have AVRCP support.]) +fi AC_ARG_ENABLE(network, AS_HELP_STRING([--disable-network], [disable network profiles]), [enable_network=${enableval}]) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 062475e56c49..69c6dc67135b 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -49,7 +49,10 @@ #include "media.h" #include "transport.h" #include "a2dp.h" + +#ifdef HAVE_AVRCP #include "avrcp.h" +#endif #define MEDIA_INTERFACE "org.bluez.Media1" #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" @@ -65,7 +68,9 @@ struct media_app { char *path; /* Application object path */ struct queue *proxies; /* Application proxies */ struct queue *endpoints; /* Application endpoints */ +#ifdef HAVE_AVRCP struct queue *players; /* Application players */ +#endif int err; }; @@ -73,7 +78,9 @@ struct media_adapter { struct btd_adapter *btd_adapter; struct queue *apps; /* Application list */ GSList *endpoints; /* Endpoints list */ +#ifdef HAVE_AVRCP GSList *players; /* Players list */ +#endif }; struct endpoint_request { @@ -482,6 +489,7 @@ struct a2dp_config_data { int8_t media_player_get_device_volume(struct btd_device *device) { +#ifdef HAVE_AVRCP struct avrcp_player *target_player; struct media_adapter *adapter; GSList *l; @@ -505,6 +513,7 @@ int8_t media_player_get_device_volume(struct btd_device *device) } done: +#endif /* HAVE_AVRCP */ /* If media_player doesn't exists use device_volume */ return btd_device_get_volume(device); } @@ -1760,6 +1769,7 @@ static DBusMessage *unregister_endpoint(DBusConnection *conn, DBusMessage *msg, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +#ifdef HAVE_AVRCP static struct media_player *media_adapter_find_player( struct media_adapter *adapter, const char *sender, @@ -2649,10 +2659,12 @@ static struct media_player *media_player_create(struct media_adapter *adapter, return mp; } +#endif /* HAVE_AVRCP */ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg, void *data) { +#ifdef HAVE_AVRCP struct media_adapter *adapter = data; struct media_player *mp; DBusMessageIter args; @@ -2683,11 +2695,15 @@ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg, } return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +#else + return btd_error_not_supported(msg); +#endif } static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg, void *data) { +#ifdef HAVE_AVRCP struct media_adapter *adapter = data; struct media_player *player; const char *sender, *path; @@ -2706,6 +2722,9 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg, media_player_remove(player); return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +#else + return btd_error_not_supported(msg); +#endif } static void app_free(void *data) @@ -2714,7 +2733,9 @@ static void app_free(void *data) queue_destroy(app->proxies, NULL); queue_destroy(app->endpoints, media_endpoint_remove); +#ifdef HAVE_AVRCP queue_destroy(app->players, media_player_remove); +#endif if (app->client) { g_dbus_client_set_disconnect_watch(app->client, NULL, NULL); @@ -2913,6 +2934,7 @@ fail: static void app_register_player(void *data, void *user_data) { +#ifdef HAVE_AVRCP struct media_app *app = user_data; GDBusProxy *proxy = data; const char *iface = g_dbus_proxy_get_interface(proxy); @@ -2994,6 +3016,7 @@ fail: error("Unable to register player %s:%s: %s", app->sender, path, strerror(-app->err)); media_player_destroy(player); +#endif /* HAVE_AVRCP */ } static void remove_app(void *data) @@ -3042,7 +3065,11 @@ static void client_ready_cb(GDBusClient *client, void *user_data) goto reply; } +#ifdef HAVE_AVRCP if ((queue_isempty(app->endpoints) && queue_isempty(app->players))) { +#else + if (queue_isempty(app->endpoints)) { +#endif error("No valid external Media objects found"); fail = true; reply = btd_error_failed(app->reg, @@ -3091,6 +3118,7 @@ static bool match_endpoint_by_path(const void *a, const void *b) return !strcmp(endpoint->path, path); } +#ifdef HAVE_AVRCP static bool match_player_by_path(const void *a, const void *b) { const struct media_player *player = a; @@ -3098,12 +3126,12 @@ static bool match_player_by_path(const void *a, const void *b) return !strcmp(player->path, path); } +#endif static void proxy_removed_cb(GDBusProxy *proxy, void *user_data) { struct media_app *app = user_data; struct media_endpoint *endpoint; - struct media_player *player; const char *iface, *path; iface = g_dbus_proxy_get_interface(proxy); @@ -3122,7 +3150,10 @@ static void proxy_removed_cb(GDBusProxy *proxy, void *user_data) DBG("Proxy removed - removing endpoint: %s", endpoint->path); media_endpoint_remove(endpoint); +#ifdef HAVE_AVRCP } else if (!strcmp(iface, MEDIA_PLAYER_INTERFACE)) { + struct media_player *player; + player = queue_remove_if(app->players, match_player_by_path, (void *) path); if (!player) @@ -3134,6 +3165,7 @@ static void proxy_removed_cb(GDBusProxy *proxy, void *user_data) DBG("Proxy removed - removing player: %s", player->path); media_player_remove(player); +#endif } } @@ -3162,7 +3194,9 @@ static struct media_app *create_app(DBusConnection *conn, DBusMessage *msg, app->proxies = queue_new(); app->endpoints = queue_new(); +#ifdef HAVE_AVRCP app->players = queue_new(); +#endif app->reg = dbus_message_ref(msg); g_dbus_client_set_disconnect_watch(app->client, client_disconnect_cb, @@ -3326,6 +3360,7 @@ static void path_free(void *data) release_endpoint(endpoint); } +#ifdef HAVE_AVRCP for (l = adapter->players; l;) { struct media_player *mp = l->data; @@ -3333,6 +3368,7 @@ static void path_free(void *data) media_player_destroy(mp); } +#endif adapters = g_slist_remove(adapters, adapter); diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index dbebb1ea5fa0..1b9c66e4940d 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -612,6 +612,7 @@ static int8_t transport_a2dp_get_volume(struct media_transport *transport) return a2dp->volume; } +#ifdef HAVE_AVRCP static int transport_a2dp_src_set_volume(struct media_transport *transport, int8_t level) { @@ -643,6 +644,7 @@ static int transport_a2dp_snk_set_volume(struct media_transport *transport, return avrcp_set_volume(transport->device, level, notify); } +#endif static int transport_a2dp_snk_set_delay(struct media_transport *transport, uint16_t delay) @@ -2409,11 +2411,19 @@ static void *transport_asha_init(struct media_transport *transport, void *data) static const struct media_transport_ops transport_ops[] = { A2DP_OPS(A2DP_SOURCE_UUID, transport_a2dp_src_init, +#ifdef HAVE_AVRCP transport_a2dp_src_set_volume, +#else + NULL, +#endif NULL, transport_a2dp_src_destroy), A2DP_OPS(A2DP_SINK_UUID, transport_a2dp_snk_init, +#ifdef HAVE_AVRCP transport_a2dp_snk_set_volume, +#else + NULL, +#endif transport_a2dp_snk_set_delay, transport_a2dp_snk_destroy), BAP_UC_OPS(PAC_SOURCE_UUID), -- 2.47.1