From f2cc370504024af22db297dac0ef919fe232e3d8 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 28 May 2025 10:17:26 -0400 Subject: [PATCH] audio/player: Fix not being able to register players of different types When registering players both AVRCP and MCP were using the same object path making them clash, so this fix it by adding a type to the object path so each profile can register their player in their own domain. Fixes: https://github.com/bluez/bluez/issues/1290 --- profiles/audio/avrcp.c | 2 +- profiles/audio/mcp.c | 3 ++- profiles/audio/player.c | 5 +++-- profiles/audio/player.h | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 2d7b4e1e7..831f1dc8b 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3577,7 +3577,7 @@ static struct avrcp_player *create_ct_player(struct avrcp *session, path = device_get_path(session->dev); - mp = media_player_controller_create(path, id); + mp = media_player_controller_create(path, "avrcp", id); if (mp == NULL) { g_free(player); return NULL; diff --git a/profiles/audio/mcp.c b/profiles/audio/mcp.c index 0a2991f20..2808674cf 100644 --- a/profiles/audio/mcp.c +++ b/profiles/audio/mcp.c @@ -342,7 +342,8 @@ static int mcp_accept(struct btd_service *service) bt_mcp_attach(data->mcp, client); - data->mp = media_player_controller_create(device_get_path(device), 0); + data->mp = media_player_controller_create(device_get_path(device), + "mcp", 0); if (data->mp == NULL) { DBG("Unable to create Media Player"); return -EINVAL; diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 52844c9c0..86e59bc8e 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -1277,13 +1277,14 @@ void media_player_destroy(struct media_player *mp) } struct media_player *media_player_controller_create(const char *path, - uint16_t id) + const char *type, + uint16_t id) { struct media_player *mp; mp = g_new0(struct media_player, 1); mp->device = g_strdup(path); - mp->path = g_strdup_printf("%s/player%u", path, id); + mp->path = g_strdup_printf("%s/%s/player%u", path, type, id); mp->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); mp->track = g_hash_table_new_full(g_str_hash, g_str_equal, diff --git a/profiles/audio/player.h b/profiles/audio/player.h index 5e181591c..dcd7df286 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -61,7 +61,8 @@ struct media_player_callback { }; struct media_player *media_player_controller_create(const char *path, - uint16_t id); + const char *type, + uint16_t id); const char *media_player_get_path(struct media_player *mp); void media_player_destroy(struct media_player *mp); void media_player_set_duration(struct media_player *mp, uint32_t duration); -- 2.47.3