doc/org.bluez.MediaTransport: Add Mute property
PATCH 1/4 doc/org.bluez.MediaTransport: Add Mute property
Add a Mute property for LE Audio (BAP) transports with a Volume Control Service session, next to Volume.
--- doc/org.bluez.MediaTransport.rst | 10 ++++++++++ 1 file changed, 10 insertions(+)
doc/org.bluez.MediaTransport.rst +10 -0
@@ -160,6 +160,16 @@ Examples: :bluetoothctl: > transport.volume <transport> [value] +boolean Mute [readwrite, optional] +`````````````````````````````````` + +Indicates mute state of the transport, only present for LE Audio (BAP) +transports backed by VCS. + +Examples: + +:bluetoothctl: > transport.mute <transport> [on/off] + object Endpoint [readonly, optional, experimental] ``````````````````````````````````````````````````
base-commit: 1608f836188610aabeff5a3164169ebe0360e443
Signature · 1 line
2.43.0
PATCH 2/4 shared/vcp: Add bt_vcp_get_mute and bt_vcp_set_mute
Keep the Mute field of Volume State next to the volume. As a client, setting it writes Mute or Unmute to the remote Volume Control Point. As a server, it updates the local Volume State and notifies it.
The volume callback now also runs when only the mute state changes, so its user sees a remote client muting or unmuting the server.
--- src/shared/vcp.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++ src/shared/vcp.h | 3 ++ 2 files changed, 104 insertions(+)
src/shared/vcp.c +101 -0
@@ -216,6 +216,7 @@ struct bt_vcp {uint8_t volume;uint8_t volume_counter; +uint8_t mute;struct bt_vcp_client_op pending_op;
@@ -977,6 +978,18 @@ struct vocs_op_handler { {} }; +static void vcp_mute_changed (struct bt_vcp *vcp,uint8_t mute) +{ +if (vcp->mute == mute) +return ; + + vcp->mute = mute; + +/* The volume callback reports any Volume State change */ +if (vcp->volume_changed) + vcp->volume_changed (vcp, vcp->volume); +} + static void vcs_cp_write(struct gatt_db_attribute *attrib, unsigned int id, uint16_t offset, const uint8_t *value, size_t len,
@@ -991,6 +1004,7 @@ static void vcs_cp_write(struct gatt_db_attribute *attrib, };uint8_t *vcp_op;struct vcs_op_handler *handler; +struct vol_state *vstate;uint8_t ret =BT_ATT_ERROR_REQUEST_NOT_SUPPORTED ;DBG (vcp,"VCP Control Point Write" );
@@ -1032,6 +1046,10 @@ static void vcs_cp_write(struct gatt_db_attribute *attrib,DBG (vcp,"%s" , handler->str); ret = handler->func (vcs, vcp, &iov); + + vstate =vdb_get_vstate (vcs->vdb); +if (!ret && vstate) +vcp_mute_changed (vcp, vstate->mute); }else {DBG (vcp,"Unknown opcode 0x%02x" , *vcp_op); ret =BT_ATT_ERROR_OPCODE_NOT_SUPPORTED ;
@@ -2076,6 +2094,7 @@ static void vcp_vstate_notify(struct bt_vcp *vcp, uint16_t value_handle, vcp->volume = vstate->vol_set; vcp->volume_counter = vstate->counter; + vcp->mute = vstate->mute;if (vcp->volume_changed) vcp->volume_changed (vcp, vcp->volume);
@@ -2207,6 +2226,87 @@ uint8_t bt_vcp_get_volume(struct bt_vcp *vcp)return vcp->volume; } +static void vcp_mute_cp_sent (bool success,uint8_t err,void *user_data) +{ +struct bt_vcp *vcp = user_data; + +if (!success) +DBG (vcp,"setting mute failed: error 0x%x" , err); +} + +static bool vcp_set_mute_client (struct bt_vcp *vcp,uint8_t mute) +{ +struct bt_vcs_param req; +uint16_t value_handle; +struct bt_vcs *vcs =vcp_get_vcs (vcp); + +if (!vcs || !vcs->vol_cp) { +DBG (vcp,"error: vol_cp characteristic not available" ); +return false; + } + +if (!gatt_db_attribute_get_char_data (vcs->vol_cp,NULL , &value_handle, +NULL ,NULL ,NULL )) { +DBG (vcp,"error: vol_cp characteristic not available" ); +return false; + } + +if (vcp->mute == mute) +return true; + + req.op = mute ?BT_VCS_MUTE :BT_VCS_UNMUTE ; + req.change_counter = vcp->volume_counter; + +if (!bt_gatt_client_write_value (vcp->client, value_handle, (void *)&req, +sizeof (req), vcp_mute_cp_sent, vcp, +NULL )) { +DBG (vcp,"error writing mute" ); +return false; + } + +return true; +} + +static bool vcp_set_mute_server (struct bt_vcp *vcp,uint8_t mute) +{ +struct bt_vcp_db *vdb =vcp_get_vdb (vcp); +struct vol_state *vstate; + +if (!vdb) { +DBG (vcp,"error: VDB not available" ); +return false; + } + + vstate =vdb_get_vstate (vdb); +if (!vstate) { +DBG (vcp,"error: VSTATE not available" ); +return false; + } + +if (vstate->mute == mute) +return true; + + vstate->mute = mute; + vstate->counter = -~vstate->counter;/*Increment Change Counter*/ +gatt_db_attribute_notify (vdb->vcs->vs, (void *) vstate, +sizeof (struct vol_state ),bt_vcp_get_att (vcp)); +vcp_mute_changed (vcp, mute); +return true; +} + +bool bt_vcp_set_mute (struct bt_vcp *vcp,uint8_t mute) +{ +if (vcp->client) +return vcp_set_mute_client (vcp, mute); +else +return vcp_set_mute_server (vcp, mute); +} + +uint8_t bt_vcp_get_mute (struct bt_vcp *vcp) +{ +return vcp->mute; +} +static void vcp_voffset_state_notify (struct bt_vcp *vcp,uint16_t value_handle,const uint8_t *value,uint16_t length,void *user_data)
@@ -2320,6 +2420,7 @@ static void read_vol_state(struct bt_vcp *vcp, bool success, uint8_t att_ecode, vcp->volume = vs->vol_set; vcp->volume_counter = vs->counter; + vcp->mute = vs->mute; } static void read_vol_offset_state(struct bt_vcp *vcp, bool success,
src/shared/vcp.h +3 -0
@@ -42,6 +42,9 @@ void bt_vcp_detach(struct bt_vcp *vcp);uint8_t bt_vcp_get_volume (struct bt_vcp *vcp);bool bt_vcp_set_volume (struct bt_vcp *vcp,uint8_t volume); +uint8_t bt_vcp_get_mute (struct bt_vcp *vcp); +bool bt_vcp_set_mute (struct bt_vcp *vcp,uint8_t mute); +bool bt_vcp_set_debug (struct bt_vcp *vcp,bt_vcp_debug_func_t cb,void *user_data,bt_vcp_destroy_func_t destroy);
Signature · 1 line
2.43.0
PATCH 3/4 audio/transport: Add Mute property
In reply to Simon MikudaAdd Mute to BAP unicast transports that have a VCP session, read and written through VCP like Volume. A2DP transports don't get it: AVRCP has no mute.
--- profiles/audio/transport.c | 93 ++++++++++++++++++++++++++++++++++++++ profiles/audio/vcp.c | 20 ++++++++ profiles/audio/vcp.h | 12 +++++ 3 files changed, 125 insertions(+)
profiles/audio/transport.c +93 -0
@@ -1267,6 +1267,64 @@ static void set_volume(const GDBusPropertyTable *property,g_dbus_pending_property_success (id); } +static int transport_bap_get_mute (struct media_transport *transport); +static int transport_bap_set_mute (struct media_transport *transport, +bool mute); + +static gboolean mute_exists (const GDBusPropertyTable *property,void *data) +{ +struct media_transport *transport = data; + +return transport_bap_get_mute (transport) >=0 ; +} + +static gboolean get_mute (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *data) +{ +struct media_transport *transport = data; +dbus_bool_t mute; +int ret; + + ret =transport_bap_get_mute (transport); +if (ret <0 ) +return FALSE; + + mute = ret; + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &mute); + +return TRUE; +} + +static void set_mute (const GDBusPropertyTable *property, +DBusMessageIter *iter,GDBusPendingPropertySet id, +void *data) +{ +struct media_transport *transport = data; +dbus_bool_t mute; +int err; + +if (dbus_message_iter_get_arg_type (iter) !=DBUS_TYPE_BOOLEAN ) { +g_dbus_pending_property_error (id, +ERROR_INTERFACE ".InvalidArguments" , +"Expected BOOLEAN" ); +return ; + } + +dbus_message_iter_get_basic (iter, &mute); + + err =transport_bap_set_mute (transport, mute); +if (err) { +error ("Unable to set mute: %s (%d)" ,strerror (-err), err); +g_dbus_pending_property_error (id,ERROR_INTERFACE ".Failed" , +"Internal error %s (%d)" , +strerror (-err), err); +return ; + } + +g_dbus_pending_property_success (id); +} +static gboolean endpoint_exists (const GDBusPropertyTable *property,void *data) {struct media_transport *transport = data;
@@ -1620,6 +1678,7 @@ static const GDBusPropertyTable transport_bap_uc_properties[] = { { "Metadata", "ay", get_metadata, set_metadata }, { "Links", "ao", get_links, NULL, links_exists }, { "Volume", "q", get_volume, set_volume, volume_exists }, + { "Mute", "b", get_mute, set_mute, mute_exists }, { } };
@@ -1635,6 +1694,7 @@ static const GDBusPropertyTable transport_bap_uc_test_properties[] = { { "Metadata", "ay", get_metadata, set_metadata }, { "Links", "ao", get_links, NULL, links_exists }, { "Volume", "q", get_volume, set_volume, volume_exists }, + { "Mute", "b", get_mute, set_mute, mute_exists }, { "Desynchronized", "b", get_desync, set_desync, links_exists}, { } };
@@ -2620,6 +2680,22 @@ static int transport_bap_set_volume(struct media_transport *transport,return -ENOTSUP ;/* TODO: MICP */ } +static int transport_bap_get_mute (struct media_transport *transport) +{ +if (transport_bap_is_playback (transport)) +return bt_audio_vcp_get_mute (transport->device); +else +return -ENOTSUP ;/* TODO: MICP */ +} + +static int transport_bap_set_mute (struct media_transport *transport,bool mute) +{ +if (transport_bap_is_playback (transport)) +return bt_audio_vcp_set_mute (transport->device, mute); +else +return -ENOTSUP ;/* TODO: MICP */ +} +static void transport_bap_destroy (void *data) {struct bap_transport *bap = data;
@@ -3198,6 +3274,22 @@ static void media_transport_emit_volume(struct media_transport *transport) MEDIA_TRANSPORT_INTERFACE, "Volume"); } +static void media_transport_emit_mute (struct media_transport *transport) +{ +const char *uuid =media_endpoint_get_uuid (transport->endpoint); + +if (strcasecmp (uuid,PAC_SINK_UUID ) && +strcasecmp (uuid,PAC_SOURCE_UUID )) +return ; + +if (!mute_exists (NULL , transport)) +return ; + +g_dbus_emit_property_changed (btd_get_dbus_connection (), + transport->path, +MEDIA_TRANSPORT_INTERFACE ,"Mute" ); +} +int media_transport_get_a2dp_volume (struct btd_device *dev) {GSList *l;
@@ -3272,6 +3364,7 @@ void media_transport_volume_changed(struct btd_device *dev)continue ;media_transport_emit_volume (transport); +media_transport_emit_mute (transport); } }
profiles/audio/vcp.c +20 -0
@@ -185,6 +185,26 @@ int bt_audio_vcp_set_volume(struct btd_device *device, uint8_t volume)return -ENODEV ; } +int bt_audio_vcp_get_mute (struct btd_device *device) +{ +struct vcp_data *data =queue_find (sessions, match_device, device); + +if (data) +return bt_vcp_get_mute (data->vcp); + +return -ENODEV ; +} + +int bt_audio_vcp_set_mute (struct btd_device *device,bool mute) +{ +struct vcp_data *data =queue_find (sessions, match_device, device); + +if (data) +return bt_vcp_set_mute (data->vcp, mute) ?0 : -EIO ; + +return -ENODEV ; +} +static void vcp_remote_client_detached (struct bt_vcp *vcp,void *user_data) {struct vcp_data *data;
profiles/audio/vcp.h +12 -0
@@ -12,6 +12,8 @@int bt_audio_vcp_get_volume (struct btd_device *device);int bt_audio_vcp_set_volume (struct btd_device *device,uint8_t volume); +int bt_audio_vcp_get_mute (struct btd_device *device); +int bt_audio_vcp_set_mute (struct btd_device *device,bool mute);#else
@@ -26,4 +28,14 @@ static inline int bt_audio_vcp_set_volume(struct btd_device *device, return -ENODEV; } +static inline int bt_audio_vcp_get_mute (struct btd_device *device) +{ +return -ENODEV ; +} + +static inline int bt_audio_vcp_set_mute (struct btd_device *device,bool mute) +{ +return -ENODEV ; +} +#endif
Signature · 1 line
2.43.0
PATCH 4/4 client/player: Add transport.mute command
In reply to Simon MikudaGet or set the Mute property of a transport, like transport.volume.
--- client/player.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
client/player.c +51 -0
@@ -6160,6 +6160,54 @@ static void cmd_volume_transport(int argc, char *argv[]) } } +static void mute_callback (const DBusError *error,void *user_data) +{ +if (dbus_error_is_set (error)) { +bt_shell_printf ("Failed to set Mute: %s\n" , error->name); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +bt_shell_printf ("Changing Mute succeeded\n" ); + +return bt_shell_noninteractive_quit (EXIT_SUCCESS ); +} + +static void cmd_mute_transport (int argc,char *argv[]) +{ +GDBusProxy *proxy; +dbus_bool_t mute; + + proxy =g_dbus_proxy_lookup (transports,NULL , argv[1 ], +BLUEZ_MEDIA_TRANSPORT_INTERFACE ); +if (!proxy) { +bt_shell_printf ("Transport %s not found\n" , argv[1 ]); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +if (argc ==2 ) { +print_property (proxy,"Mute" ); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +if (!strcasecmp (argv[2 ],"on" ) || !strcasecmp (argv[2 ],"yes" ) || + !strcmp (argv[2 ],"1" )) + mute = TRUE; +else if (!strcasecmp (argv[2 ],"off" ) || !strcasecmp (argv[2 ],"no" ) || + !strcmp (argv[2 ],"0" )) + mute = FALSE; +else { +bt_shell_printf ("Invalid argument: %s\n" , argv[2 ]); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +if (!g_dbus_proxy_set_property_basic (proxy,"Mute" ,DBUS_TYPE_BOOLEAN , + &mute, mute_callback, +NULL ,NULL )) { +bt_shell_printf ("Failed to set mute\n" ); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } +} +static void set_metadata_cb (const DBusError *error,void *user_data) {if (dbus_error_is_set (error)) {
@@ -6278,6 +6326,9 @@ static const struct bt_shell_menu transport_menu = { {"volume" ,"<transport> [value]" , cmd_volume_transport,"Get/Set transport volume" , transport_generator }, + { "mute", "<transport> [on/off]", cmd_mute_transport, +"Get/Set transport mute" , + transport_generator }, { "select", "<transport> [transport1...]", cmd_select_transport,"Select Transport" , transport_generator },
Signature · 1 line
2.43.0
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/series/1220854/
---Test result---
Test Summary:
CheckPatch PASS 1.51 seconds GitLint PASS 0.87 seconds BuildEll PASS 20.59 seconds BluezMake PASS 318.79 seconds MakeCheck PASS 14.72 seconds MakeDistcheck PASS 148.94 seconds CheckValgrind PASS 358.45 seconds CheckSmatch PASS 319.44 seconds bluezmakeextell PASS 103.55 seconds TestFunctional PASS 1184.52 seconds IncrementalBuild PASS 346.05 seconds ScanBuild PASS 1191.79 seconds
https://github.com/bluez/bluez/pull/2900
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Simon,
Quoted 27 lines · On Tue, Nov 24, 2026 at 4:02 PM <[email protected]> wrote:
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/series/1220854/---Test result---
Test Summary:
CheckPatch PASS 1.51 seconds GitLint PASS 0.87 seconds BuildEll PASS 20.59 seconds BluezMake PASS 318.79 seconds MakeCheck PASS 14.72 seconds MakeDistcheck PASS 148.94 seconds CheckValgrind PASS 358.45 seconds CheckSmatch PASS 319.44 seconds bluezmakeextell PASS 103.55 seconds TestFunctional PASS 1184.52 seconds IncrementalBuild PASS 346.05 seconds ScanBuild PASS 1191.79 seconds
Quoted 1 line
Copilot flagged a couple of problems:
https://github.com/bluez/bluez/pull/2900#pullrequestreview-6046509783
Signature · 1 line
Luiz Augusto von Dentz