mcp: expose org.bluez.MediaPlayer information via GMCS
Subsystems (2)
cover mcp: expose org.bluez.MediaPlayer information via GMCS
Select one of the local org.bluez.MediaPlayer instances as the "active" player, and expose its playback controls via GMCS.
To do this, decouple media.c player API from AVRCP by adding a similar API for org.bluez.MediaPlayer --> remote as used for the remote --> org.bluez.MediaPlayer direction. Use it for both AVRCP and MCS.
In theory we could also expose each org.bluez.MediaPlayer in separate MCS instances. This is not implemented here; it would need to be done so that we don't consume ATT handles when players come and go.
Pauli Virtanen (3):
media: decouple local org.bluez.MediaPlayer from AVRCP
mcp: expose org.bluez.MediaPlayer information via GMCS tools/mpris-proxy: allow selecting which adapter to use
Makefile.plugins | 3 +- profiles/audio/avrcp-player.c | 291 +++++++++++++++++++ profiles/audio/avrcp.c | 4 + profiles/audio/avrcp.h | 3 + profiles/audio/mcp.c | 506 +++++++++++++++++++++++++++++----- profiles/audio/media.c | 501 ++++++++++++++++++--------------- profiles/audio/media.h | 45 +++ tools/mpris-proxy.c | 8 +- 8 files changed, 1074 insertions(+), 287 deletions(-) create mode 100644 profiles/audio/avrcp-player.c
Signature · 1 line
2.51.1
PATCH 1/3 media: decouple local org.bluez.MediaPlayer from AVRCP
The local media player API should be used also for MCP in addition to AVRCP, but it's currently calling directly into AVRCP.
Invert the API to be DBus player --> hooks, and attach AVRCP to it allowing multiple backends.
Rename media_player to local_player, to fix the naming conflict with player.h, which is the API for remote player --> DBus, ie. the inverse direction.
Don't modify the AVRCP side of the code to these new wrappers, instead keep the old AVRCP API and use an extra indirection in avrcp-player.c, which may make it easier to add new features for MCS.
--- Makefile.plugins | 3 +- profiles/audio/avrcp-player.c | 291 ++++++++++++++++++++ profiles/audio/avrcp.c | 4 + profiles/audio/avrcp.h | 3 + profiles/audio/media.c | 501 +++++++++++++++++++--------------- profiles/audio/media.h | 45 +++ 6 files changed, 626 insertions(+), 221 deletions(-) create mode 100644 profiles/audio/avrcp-player.c
Makefile.plugins +2 -1
@@ -44,7 +44,8 @@ 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/avrcp.h profiles/audio/avrcp.c \ + profiles/audio/avrcp-player.c endif if NETWORK
profiles/audio/avrcp-player.c new file +291 -0
291 lines not on this page · raw message
profiles/audio/avrcp.c +4 -0
@@ -4972,11 +4972,15 @@ static int avrcp_init(void)populate_default_features (); +avrcp_player_init (); +return 0 ; }static void avrcp_exit (void ) { +avrcp_player_exit (); +btd_profile_unregister (&avrcp_controller_profile);btd_profile_unregister (&avrcp_target_profile); }
profiles/audio/avrcp.h +3 -0
@@ -105,3 +105,6 @@ size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands);size_t avrcp_browsing_general_reject (uint8_t *operands);struct avrcp_player *avrcp_get_target_player_by_device (struct btd_device *dev); + +void avrcp_player_init (void ); +void avrcp_player_exit (void );
profiles/audio/media.c +281 -220
969 lines not on this page · raw message
profiles/audio/media.h +45 -0
54 lines not on this page · raw message
Signature · 1 line
2.51.1
PATCH 2/3 mcp: expose org.bluez.MediaPlayer information via GMCS
In reply to Pauli VirtanenSelect one of the local org.bluez.MediaPlayer instances as the "active" player, and expose its playback controls via GMCS.
--- profiles/audio/mcp.c | 506 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 441 insertions(+), 65 deletions(-)
profiles/audio/mcp.c +441 -65
@@ -56,6 +56,7 @@#include "src/error.h" #include "player.h" +#include "media.h" #define MCS_UUID_STR "00001848-0000-1000-8000-00805f9b34fb"#define GMCS_UUID_STR "00001849-0000-1000-8000-00805f9b34fb"
@@ -203,30 +204,42 @@ static const struct { .shuffle = true }, }; -static void remote_playing_order (void *data,uint8_t order) +static bool get_playing_order (uint8_t order,const char **repeat, +const char **shuffle) { -struct remote_player *remote = data; -const char *repeat ="off" ;unsigned int i; -bool shuffle; - remote->playing_order = order; + *repeat ="off" ; + *shuffle ="off" ;for (i =0 ; i <ARRAY_SIZE (playing_orders); ++i) { - shuffle = playing_orders[i].shuffle; + *shuffle = playing_orders[i].shuffle ?"alltracks" :"off" ;if (order == playing_orders[i].basic) {break ; }else if (order == playing_orders[i].repeat) { - repeat = playing_orders[i].single ?"singletrack" : + *repeat = playing_orders[i].single ?"singletrack" :"alltracks" ;break ; } }if (i ==ARRAY_SIZE (playing_orders)) +return false; + +return true; +} + +static void remote_playing_order (void *data,uint8_t order) +{ +struct remote_player *remote = data; +const char *repeat, *shuffle; + + remote->playing_order = order; + +if (!get_playing_order (order, &repeat, &shuffle))return ;media_player_set_setting (remote->mp,"Repeat" , repeat); -media_player_set_setting (remote->mp,"Shuffle" , shuffle ?"on" :"off" ); +media_player_set_setting (remote->mp,"Shuffle" , shuffle); }static void remote_media_state (void *data,uint8_t status)
@@ -297,7 +310,7 @@ static bool remote_mp_set_setting(struct media_player *mp, const char *key,unsigned int i;if (strcmp (key,"Repeat" ) ==0 ) { -bool repeat = (strcmp (value,"alltracks" ) ==0 ); +bool repeat = (strcasecmp (value,"alltracks" ) ==0 );uint8_t order = remote->playing_order;/* Some sensible mapping, 1-to-1 not possible */
@@ -313,7 +326,7 @@ static bool remote_mp_set_setting(struct media_player *mp, const char *key, } } -if (strcmp (value,"singletrack" ) ==0 ) +if (strcasecmp (value,"singletrack" ) ==0 ) order =BT_MCS_ORDER_SINGLE_REPEAT ;DBG ("Set Repeat %s -> 0x%02x" , value, order);
@@ -325,7 +338,7 @@ static bool remote_mp_set_setting(struct media_player *mp, const char *key, }if (strcmp (key,"Shuffle" ) ==0 ) { -bool shuffle = (strcmp (value,"off" ) !=0 ); +bool shuffle = (strcasecmp (value,"off" ) !=0 );uint8_t order = remote->playing_order;/* Some sensible mapping, 1-to-1 not possible */
@@ -424,22 +437,33 @@ static const struct bt_mcp_callback mcp_cb = {/* -* Local player +* Local player. +* +* TODO: maybe expose multiple MCS instances, as many as there are players. We'd +* have to keep unused instances around in inactive state, so that we don't +* consume ATT handles when players disappear/reappear. +* +* If an instance has no local player, for GMCS we forward key presses to +* uinput. Other MCS instances should do nothing when inactive. */ -struct gmcs ; +struct mcs_instance ; -struct local_player { -struct bt_mcs *mcs; -struct media_player *mp; -struct gmcs *gmcs; +struct player_link { +struct local_player *lp; +unsigned int id; +struct mcs_instance *instance; }; -struct gmcs { -struct bt_uinput *uinput; +struct mcs_instance {struct btd_adapter *adapter;struct bt_mcs *mcs; -struct queue *players; +struct queue *player_links; +bool at_start; + +/* GMCS-specific */ +struct bt_uinput *uinput; +unsigned int player_watch_id; };static const struct bt_uinput_key_map key_map[] = {
@@ -453,96 +477,418 @@ static const struct bt_uinput_key_map key_map[] = {static struct queue *servers; -static bool gmcs_command (struct gmcs *gmcs,uint8_t cmd) +static struct player_link *mcs_get_active (struct mcs_instance *mcs) +{ +return queue_peek_head (mcs->player_links); +} + +static bool player_link_is_active (struct player_link *p) +{ +return mcs_get_active (p->instance) == p; +} + +static void mcs_update_media_state (struct mcs_instance *mcs) +{ +struct player_link *p =mcs_get_active (mcs); +const char *status =NULL ; +uint8_t state; + + mcs->at_start = false; + +if (p) + status =local_player_get_status (p->lp); + +if (!status) { + state =BT_MCS_STATE_INACTIVE ; + }else if (!strcasecmp (status,"playing" )) { + state =BT_MCS_STATE_PLAYING ; + }else if (!strcasecmp (status,"stopped" )) { + mcs->at_start = true; + state =BT_MCS_STATE_PAUSED ; + }else if (!strcasecmp (status,"paused" )) { + state =BT_MCS_STATE_PAUSED ; + }else if (!strcasecmp (status,"forward-seek" ) || + !strcasecmp (status,"backward-seek" )) { + state =BT_MCS_STATE_SEEKING ; + }else { + state =BT_MCS_STATE_INACTIVE ; + } + +bt_mcs_set_media_state (mcs->mcs, state); +bt_mcs_changed (mcs->mcs,MCS_TRACK_POSITION_CHRC_UUID ); +} + +static void mcs_player_changed (struct mcs_instance *mcs) +{ +struct player_link *p =mcs_get_active (mcs); +const char *name = p ?local_player_get_player_name (p->lp) :NULL ; + +DBG ("active: %p %s" , p, name ? name :"" ); + +bt_mcs_changed (mcs->mcs,MCS_MEDIA_PLAYER_NAME_CHRC_UUID ); +mcs_update_media_state (mcs); + +bt_mcs_changed (mcs->mcs,MCS_TRACK_TITLE_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_DURATION_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_POSITION_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_PLAYBACK_SPEED_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_SEEKING_SPEED_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_PLAYING_ORDER_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_CHANGED_CHRC_UUID ); +} + +static bool player_link_make_active (struct player_link *p) +{ +struct mcs_instance *mcs = p->instance; + +if (player_link_is_active (p)) +return false; + +queue_remove (mcs->player_links, p); +queue_push_head (mcs->player_links, p); + +mcs_player_changed (mcs); +return true; +} + +static void lp_status_changed (void *user_data) +{ +struct player_link *p = user_data; +struct mcs_instance *mcs = p->instance; +const char *status =local_player_get_status (p->lp); + +/* Make the last player to start playing active */ +if (!strcasecmp (status,"playing" )) { +if (player_link_make_active (p)) +return ; + } + +if (!player_link_is_active (p)) +return ; + +mcs_update_media_state (mcs); +} + +static void lp_track_position (uint32_t old_ms,uint32_t new_ms,void *user_data) +{ +struct player_link *p = user_data; +struct mcs_instance *mcs = p->instance; + +if (!player_link_is_active (p)) +return ; + +bt_mcs_changed (mcs->mcs,MCS_TRACK_POSITION_CHRC_UUID ); +} + +static void lp_track_changed (void *user_data) +{ +struct player_link *p = user_data; +struct mcs_instance *mcs = p->instance; + + mcs->at_start = false; + +if (!player_link_is_active (p)) +return ; + +bt_mcs_changed (mcs->mcs,MCS_TRACK_TITLE_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_POSITION_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_DURATION_CHRC_UUID ); +bt_mcs_changed (mcs->mcs,MCS_TRACK_CHANGED_CHRC_UUID ); +} + +static void lp_settings_changed (const char *key,void *user_data) +{ +struct player_link *p = user_data; +struct mcs_instance *mcs = p->instance; + +if (!player_link_is_active (p)) +return ; +if (strcasecmp (key,"Shuffle" ) &&strcasecmp (key,"Repeat" )) +return ; + +bt_mcs_changed (mcs->mcs,MCS_PLAYING_ORDER_CHRC_UUID ); +} + +static void lp_player_removed (void *user_data) +{ +struct player_link *p = user_data; +struct mcs_instance *mcs = p->instance; +bool active =player_link_is_active (p); + +DBG ("%p" , p); + +queue_remove (mcs->player_links, p); +free (p); + +if (active) +mcs_player_changed (mcs); +} + +const struct local_player_callback local_player_cb = { + .status_changed = lp_status_changed, + .track_position = lp_track_position, + .track_changed = lp_track_changed, + .settings_changed = lp_settings_changed, + .player_removed = lp_player_removed, +}; + +static bool mcs_command (struct mcs_instance *mcs,uint8_t cmd) {unsigned int i;/* Emulate media key press */ -if (!gmcs->uinput) +if (!mcs->uinput)return false;for (i =0 ; i <ARRAY_SIZE (key_map); ++i) {if (key_map[i].code == cmd) { -DBG ("GMCS press %s" , key_map[i].name); -bt_uinput_send_key (gmcs->uinput, key_map[i].uinput,1 ); -bt_uinput_send_key (gmcs->uinput, key_map[i].uinput,0 ); +DBG ("MCS press %s" , key_map[i].name); +bt_uinput_send_key (mcs->uinput, key_map[i].uinput,1 ); +bt_uinput_send_key (mcs->uinput, key_map[i].uinput,0 );break ; } } -/* We are always inactive, so command does not cause state changes and +/* We are inactive, so command does not cause state changes and * does not succeed, even though we do generate the key presses. * This should be OK vs. MCP v1.0.1 p. 26 */ return false; } -static bool gmcs_play (void *data) +static bool mcs_play (void *data) { -return gmcs_command (data,BT_MCS_CMD_PLAY ); +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (p &&local_player_play (p->lp)) +return true; +return mcs_command (mcs,BT_MCS_CMD_PLAY ); } -static bool gmcs_pause (void *data) +static bool mcs_pause (void *data) { -return gmcs_command (data,BT_MCS_CMD_PAUSE ); +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (p &&local_player_pause (p->lp)) +return true; +return mcs_command (mcs,BT_MCS_CMD_PAUSE ); } -static bool gmcs_stop (void *data) +static bool mcs_stop (void *data) { -return gmcs_command (data,BT_MCS_CMD_STOP ); +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (p &&local_player_stop (p->lp)) { + mcs->at_start = true; +return true; + } +return mcs_command (mcs,BT_MCS_CMD_STOP ); } -static bool gmcs_next_track (void *data) +static bool mcs_next_track (void *data) { -return gmcs_command (data,BT_MCS_CMD_NEXT_TRACK ); +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (p &&local_player_next (p->lp)) { + mcs->at_start = true; +return true; + } +return mcs_command (data,BT_MCS_CMD_NEXT_TRACK ); } -static bool gmcs_previous_track (void *data) +static bool mcs_previous_track (void *data) { -return gmcs_command (data,BT_MCS_CMD_PREV_TRACK ); +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (p &&local_player_previous (p->lp)) { + mcs->at_start = true; +return true; + } +return mcs_command (data,BT_MCS_CMD_PREV_TRACK ); } -static void gmcs_media_player_name (void *data,struct iovec *buf,size_t size) +static void mcs_media_player_name (void *data,struct iovec *buf,size_t size) { -struct gmcs *gmcs = data; -int len; +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); +const char *name =NULL ; - len =snprintf ((void *)buf->iov_base, size,"%s" , -btd_adapter_get_name (gmcs->adapter)); -if (len <0 ) - len =0 ; -else if ((size_t )len > size) - len = size; -util_iov_push (buf, len); +if (p) + name =local_player_get_player_name (p->lp); +if (!name) + name =btd_adapter_get_name (mcs->adapter); + +snprintf ((void *)buf->iov_base, size,"%s" , name); +util_iov_push (buf,strlen (buf->iov_base)); } -static void gmcs_destroy (void *data) +static void mcs_track_title (void *data,struct iovec *buf,size_t size) { -struct gmcs *gmcs = data; +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); +const char *name =NULL ; + +if (p) + name =local_player_get_metadata (p->lp,"Title" ); +if (!name) + name ="" ; + +snprintf ((void *)buf->iov_base, size,"%s" , name); +util_iov_push (buf,strlen (buf->iov_base)); +} + +static int32_t mcs_track_duration (void *data) +{ +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); +const char *duration =NULL ; +long duration_ms; + +if (p) + duration =local_player_get_metadata (p->lp,"Duration" ); +if (!duration) +return BT_MCS_DURATION_UNAVAILABLE ; + + duration_ms =atol (duration); +return duration_ms /10 ; +} + +static int32_t mcs_track_position (void *data) +{ +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (!p) +return BT_MCS_POSITION_UNAVAILABLE ; + +if (mcs->at_start) +return 0 ; + +return local_player_get_position (p->lp) /10 ; +} + +static uint8_t mcs_playing_order (void *data) +{ +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); +bool shuffle, repeat, single; +const char *shuffle_str, *repeat_str; + +if (!p) +return BT_MCS_ORDER_IN_ORDER_ONCE ; + + shuffle_str =local_player_get_setting (p->lp,"Shuffle" ); + repeat_str =local_player_get_setting (p->lp,"Repeat" ); + + shuffle = shuffle_str &&strcasecmp (shuffle_str,"off" ); + repeat = repeat_str &&strcasecmp (repeat_str,"off" ); + single = repeat_str && !strcasecmp (repeat_str,"singletrack" ); +if (single) +return BT_MCS_ORDER_SINGLE_REPEAT ; + +if (shuffle) +return repeat ?BT_MCS_ORDER_SHUFFLE_REPEAT : +BT_MCS_ORDER_SHUFFLE_ONCE ; +return repeat ?BT_MCS_ORDER_IN_ORDER_REPEAT : +BT_MCS_ORDER_IN_ORDER_ONCE ; +} + +static uint16_t mcs_playing_order_supported (void *data) +{ +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); + +if (!p) +return BT_MCS_ORDER_SUPPORTED_IN_ORDER_ONCE ; + +return BT_MCS_ORDER_SUPPORTED_SINGLE_REPEAT | +BT_MCS_ORDER_SUPPORTED_IN_ORDER_ONCE | +BT_MCS_ORDER_SUPPORTED_IN_ORDER_REPEAT | +BT_MCS_ORDER_SUPPORTED_SHUFFLE_ONCE | +BT_MCS_ORDER_SUPPORTED_SHUFFLE_REPEAT ; +} + +static bool mcs_set_track_position (void *data,int32_t value) +{ +/* TODO: add support to setting position in org.bluez.MediaPlayer */ +return false; +} + +static bool mcs_set_playing_order (void *data,uint8_t value) +{ +struct mcs_instance *mcs = data; +struct player_link *p =mcs_get_active (mcs); +const char *repeat, *shuffle; +bool ok = true; + +if (!p) +return false; +if (!get_playing_order (value, &repeat, &shuffle)) +return false; + +if (local_player_set_setting (p->lp,"Shuffle" , shuffle) <0 ) + ok = false; +if (local_player_set_setting (p->lp,"Repeat" , repeat) <0 ) + ok = false; + +bt_mcs_changed (mcs->mcs,MCS_PLAYING_ORDER_CHRC_UUID ); +return ok; +} + +static void player_link_destroy (void *data) +{ +struct player_link *p = data; + +DBG ("%p" , p); + +local_player_unregister_callbacks (p->lp, p->id); +free (p); +} + +static void mcs_destroy (void *data) +{ +struct mcs_instance *mcs = data;DBG ("destroy %p" , data); -queue_remove (servers, gmcs); +queue_remove (servers, mcs); -bt_uinput_destroy (gmcs->uinput); +bt_uinput_destroy (mcs->uinput); -free (gmcs); +queue_destroy (mcs->player_links, player_link_destroy); + +if (mcs->player_watch_id) +local_player_unregister_watch (mcs->player_watch_id); + +free (mcs); } -static void gmcs_debug (void *data,const char *str) +static void mcs_debug (void *data,const char *str) {DBG_IDX (0xffff ,"%s" , str); }static const struct bt_mcs_callback gmcs_cb = { - .media_player_name = gmcs_media_player_name, - .play = gmcs_play, - .pause = gmcs_pause, - .stop = gmcs_stop, - .next_track = gmcs_next_track, - .previous_track = gmcs_previous_track, - .debug = gmcs_debug, - .destroy = gmcs_destroy, + .media_player_name = mcs_media_player_name, + .track_title = mcs_track_title, + .track_duration = mcs_track_duration, + .track_position = mcs_track_position, + .playing_order = mcs_playing_order, + .playing_order_supported = mcs_playing_order_supported, + .set_track_position = mcs_set_track_position, + .set_playing_order = mcs_set_playing_order, + .play = mcs_play, + .pause = mcs_pause, + .stop = mcs_stop, + .next_track = mcs_next_track, + .previous_track = mcs_previous_track, + .debug = mcs_debug, + .destroy = mcs_destroy, };static void uinput_debug (const char *str,void *data)
@@ -550,13 +896,39 @@ static void uinput_debug(const char *str, void *data)DBG_IDX (0xffff ,"%s" , str); } -static struct gmcs *gmcs_new (struct btd_adapter *adapter) +static void gmcs_player_added (struct local_player *lp,void *user_data) { -struct gmcs *gmcs; +struct mcs_instance *gmcs = user_data; +struct btd_adapter *adapter =local_player_get_adapter (lp); +struct player_link *p; + +if (adapter != gmcs->adapter) +return ; + + p = new0(struct player_link, 1); + p->lp = lp; + p->id =local_player_register_callbacks (lp, &local_player_cb, p); + p->instance = gmcs; +if (!p->id) { +free (p); +return ; + } + +DBG ("%p" , p); + +queue_push_tail (gmcs->player_links, p); + +if (queue_length (gmcs->player_links) ==1 ) +mcs_player_changed (gmcs); +} + +static struct mcs_instance *gmcs_new (struct btd_adapter *adapter) +{ +struct mcs_instance *gmcs;const char *name =btd_adapter_get_name (adapter);int err; - gmcs = new0(struct gmcs, 1); + gmcs = new0(struct mcs_instance, 1); gmcs->adapter = adapter; gmcs->uinput = bt_uinput_new(name, " (MCS)",
@@ -571,6 +943,10 @@ static struct gmcs *gmcs_new(struct btd_adapter *adapter) gmcs->uinput =NULL ; } + gmcs->player_links =queue_new (); + gmcs->player_watch_id =local_player_register_watch (gmcs_player_added, + gmcs); +DBG ("new %p" , gmcs);return gmcs; }
@@ -654,7 +1030,7 @@ static int gmcs_probe(struct btd_profile *p, struct btd_adapter *adapter) {struct btd_gatt_database *database =btd_adapter_get_database (adapter);struct gatt_db *db =btd_gatt_database_get_db (database); -struct gmcs *gmcs; +struct mcs_instance *gmcs;DBG ("Add GMCS server %s" ,adapter_get_path (adapter));
@@ -664,7 +1040,7 @@ static int gmcs_probe(struct btd_profile *p, struct btd_adapter *adapter) gmcs->mcs =bt_mcs_register (db, true, &gmcs_cb, gmcs);if (!gmcs->mcs) { -gmcs_destroy (gmcs); +mcs_destroy (gmcs);return -EINVAL ; }
Signature · 1 line
2.51.1
PATCH 3/3 tools/mpris-proxy: allow selecting which adapter to use
In reply to Pauli Virtanenmpris-proxy by default uses the first adapter it sees over DBus. Add option for selecting a specific one.
--- tools/mpris-proxy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/mpris-proxy.c +7 -1
@@ -62,6 +62,7 @@ static GSList *obex_sessions;static gboolean option_version = FALSE;static gboolean option_export = FALSE; +static gchar *option_adapter;struct tracklist {GDBusProxy *proxy;
@@ -753,6 +754,8 @@ static GOptionEntry options[] = { "Show version information and exit" }, {"export" ,'e' ,0 ,G_OPTION_ARG_NONE , &option_export, "Export remote players" }, + { "adapter", 'a', 0, G_OPTION_ARG_STRING, &option_adapter, + "DBus path of the adapter to use" }, { NULL }, };
@@ -2349,8 +2352,11 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) path =g_dbus_proxy_get_path (proxy);if (!strcmp (interface,BLUEZ_ADAPTER_INTERFACE )) { -if (adapter !=NULL ) +if ((option_adapter &&strcmp (path, option_adapter)) || + adapter !=NULL ) { +printf ("Bluetooth Adapter %s ignored\n" , path);return ; + }printf ("Bluetooth Adapter %s found\n" , path); adapter = proxy;
Signature · 1 line
2.51.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1033942
---Test result---
Test Summary:
CheckPatch PENDING 0.35 seconds GitLint PENDING 0.39 seconds BuildEll PASS 17.79 seconds BluezMake PASS 654.69 seconds MakeCheck PASS 21.73 seconds MakeDistcheck PASS 223.10 seconds CheckValgrind PASS 290.97 seconds CheckSmatch PASS 316.32 seconds bluezmakeextell PASS 168.35 seconds IncrementalBuild PENDING 0.33 seconds ScanBuild PASS 942.75 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 3/3] tools/mpris-proxy: allow selecting which adapter to use
In reply to Pauli VirtanenHi Pauli,
Quoted 20 lines · Pauli Virtanen
mpris-proxy by default uses the first adapter it sees over DBus. Add option for selecting a specific one.
--- tools/mpris-proxy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)tools/mpris-proxy.c +1
-0@@ -62,6 +62,7 @@ static GSList *obex_sessions;static gboolean option_version = FALSE;static gboolean option_export = FALSE; +static gchar *option_adapter;struct tracklist {GDBusProxy *proxy;
tools/mpris-proxy.c static GOptionEntry options[] = { · line 758
Quoted 5 lines
tools/mpris-proxy.c +2
-0@@ -753,6 +754,8 @@ static GOptionEntry options[] = { "Show version information and exit" }, {"export" ,'e' ,0 ,G_OPTION_ARG_NONE , &option_export, "Export remote players" }, + { "adapter", 'a', 0, G_OPTION_ARG_STRING, &option_adapter, + "DBus path of the adapter to use" },
It might be easier to the users to do based on the index (-i/--index) like most our tools do so the user don't have to copy/paste the whole path, that said Id still allow it enter the full path if that is known which probably result in doing a suffix matching logic so things like 0, hci0 or path/hci0 all match.
Quoted 20 lines
tools/mpris-proxy.c +4
-2{ NULL }, };@@ -2349,8 +2352,11 @@ static void proxy_added(GDBusProxy *proxy, void *user_data) path =g_dbus_proxy_get_path (proxy);if (!strcmp (interface,BLUEZ_ADAPTER_INTERFACE )) { -if (adapter !=NULL ) +if ((option_adapter &&strcmp (path, option_adapter)) || + adapter !=NULL ) { +printf ("Bluetooth Adapter %s ignored\n" , path);return ; + }printf ("Bluetooth Adapter %s found\n" , path); adapter = proxy; --2.51.1
Signature · 1 line
Luiz Augusto von Dentz