* [PATCH BlueZ 2/4] shared/vcp: Add bt_vcp_get_mute and bt_vcp_set_mute
2026-11-24 13:20 [PATCH BlueZ 1/4] doc/org.bluez.MediaTransport: Add Mute property Simon Mikuda
@ 2026-11-24 13:20 ` Simon Mikuda
2026-11-24 13:20 ` [PATCH BlueZ 3/4] audio/transport: Add Mute property Simon Mikuda
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
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.
Assisted-by: Claude:claude-opus-5-5
---
src/shared/vcp.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++
src/shared/vcp.h | 3 ++
2 files changed, 104 insertions(+)
diff --git a/src/shared/vcp.c b/src/shared/vcp.c
index c7f74956e..c0bb535ec 100644
--- a/src/shared/vcp.c
+++ b/src/shared/vcp.c
@@ -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,
diff --git a/src/shared/vcp.h b/src/shared/vcp.h
index e031beafd..807d2bdbe 100644
--- a/src/shared/vcp.h
+++ b/src/shared/vcp.h
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 3/4] audio/transport: Add Mute property
2026-11-24 13:20 [PATCH BlueZ 1/4] doc/org.bluez.MediaTransport: Add Mute property Simon Mikuda
2026-11-24 13:20 ` [PATCH BlueZ 2/4] shared/vcp: Add bt_vcp_get_mute and bt_vcp_set_mute Simon Mikuda
@ 2026-11-24 13:20 ` Simon Mikuda
2026-11-24 13:20 ` [PATCH BlueZ 4/4] client/player: Add transport.mute command Simon Mikuda
2026-11-24 21:02 ` [BlueZ,1/4] doc/org.bluez.MediaTransport: Add Mute property bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
Add 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.
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/transport.c | 93 ++++++++++++++++++++++++++++++++++++++
profiles/audio/vcp.c | 20 ++++++++
profiles/audio/vcp.h | 12 +++++
3 files changed, 125 insertions(+)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index ad2fc2c1c..ca5bda560 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -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);
}
}
diff --git a/profiles/audio/vcp.c b/profiles/audio/vcp.c
index 00ee2b64b..7adac4dd5 100644
--- a/profiles/audio/vcp.c
+++ b/profiles/audio/vcp.c
@@ -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;
diff --git a/profiles/audio/vcp.h b/profiles/audio/vcp.h
index b538cebf0..35ffc09f8 100644
--- a/profiles/audio/vcp.h
+++ b/profiles/audio/vcp.h
@@ -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
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 4/4] client/player: Add transport.mute command
2026-11-24 13:20 [PATCH BlueZ 1/4] doc/org.bluez.MediaTransport: Add Mute property Simon Mikuda
2026-11-24 13:20 ` [PATCH BlueZ 2/4] shared/vcp: Add bt_vcp_get_mute and bt_vcp_set_mute Simon Mikuda
2026-11-24 13:20 ` [PATCH BlueZ 3/4] audio/transport: Add Mute property Simon Mikuda
@ 2026-11-24 13:20 ` Simon Mikuda
2026-11-24 21:02 ` [BlueZ,1/4] doc/org.bluez.MediaTransport: Add Mute property bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
Get or set the Mute property of a transport, like transport.volume.
Assisted-by: Claude:claude-opus-5-5
---
client/player.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/client/player.c b/client/player.c
index 932338ef5..591c73a62 100644
--- a/client/player.c
+++ b/client/player.c
@@ -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 },
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* RE: [BlueZ,1/4] doc/org.bluez.MediaTransport: Add Mute property
2026-11-24 13:20 [PATCH BlueZ 1/4] doc/org.bluez.MediaTransport: Add Mute property Simon Mikuda
` (2 preceding siblings ...)
2026-11-24 13:20 ` [PATCH BlueZ 4/4] client/player: Add transport.mute command Simon Mikuda
@ 2026-11-24 21:02 ` bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-11-24 21:02 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]
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
^ permalink raw reply [flat|nested] 5+ messages in thread