Initial bluetooth transport delay is not applied to device port
- PipeWire version (
pipewire --version
):0.3.63
- Distribution and distribution version (
PRETTY_NAME
from/etc/os-release
): Arch Linux - Kernel version (
uname -r
): 6.1.0 - BlueZ version (
bluetoothctl --version
): 5.66 -
lsusb
:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp. Bluetooth wireless interface
[...]
- Bluetooth devices:
Device 74:74:XX:XX:XX:XX Pixel Buds
Description of Problem:
AV-sync doesn't work with my Bluetooth setup (Pixel Buds).
bluetoothctl
reports that the device supports delay reporting, but the delay information doesn't seem to be propagated properly.
Notably though, PipeWire's logs contain the correct delay value:
bluez5/media-sink.c:966:do_start: 0x7fa436fcb038: using A2DP codec SBC, delay:300 ms
But it's not applied to the port:
$ pw-cli e 61 Latency
Object: size 176, type Spa:Pod:Object:Param:Latency (262155), id Spa:Enum:ParamId:Latency (15)
Prop: key Spa:Pod:Object:Param:Latency:direction (1), flags 00000000
Id 0 (Spa:Enum:Direction:Input)
[...]
Prop: key Spa:Pod:Object:Param:Latency:minNs (6), flags 00000000
Long 0
Prop: key Spa:Pod:Object:Param:Latency:maxNs (7), flags 00000000
Long 0
It seems like the delay is/should be set here, but that value doesn't seem to stick.
There's a transport_delay_changed
function that works, but is not called in my case as the reported delay is static.
To work around this issue, I'm calling it manually when the transport is established: (I'm not sure this is the correct fix though ^^)
diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c
index ee6cef4ce..7c8044191 100644
--- a/spa/plugins/bluez5/media-sink.c
+++ b/spa/plugins/bluez5/media-sink.c
@@ -1637,6 +1641,8 @@ static void transport_state_changed(void *data,
spa_node_emit_event(&this->hooks,
spa_pod_builder_add_object(&b,
SPA_TYPE_EVENT_Node, SPA_NODE_EVENT_Error));
+ } else if (state == SPA_BT_TRANSPORT_STATE_ACTIVE) {
+ set_latency(this, true);
}
}
With this patch, the latency value is propagated to the port:
$ pw-cli e 61 Latency
[..]
Prop: key Spa:Pod:Object:Param:Latency:minNs (6), flags 00000000
Long 300000000
Prop: key Spa:Pod:Object:Param:Latency:maxNs (7), flags 00000000
Long 300000000
How Reproducible:
Steps to Reproduce:
- Connect bluetooth sink (I'm using wireplumber)
- Inspect port via
pw-cli ls Ports
andpw-cli e XX Latency
Actual Results:
Input-direction latency value is zero.
Expected Results:
I'm expecting ~300ms with my configuration.
Additional Info (as attachments):
-
pw-dump > pw-dump.log
: pw-dump.log - Bluetooth debug log, see here: pipewire-bluez.log