bluetooth: mSBC sink & source break after a stream ends
On my up-to-date Fedora 34 with pipewire 0.3.38, recently, mSBC bi-directional bluetooth audio became functional, and for the first time for me on Linux, I have on-par audio quality with an Android phone in conferences! Awesome work, guys!
However, there is an anoying bug in my setup. I can only use the headset once. It looks like whenever a (playback?) stream on the mSBC device is closed, all streams break, nothing can be recorded or played, until I turn off the headset.
Interestingly, in this state my bluetooth mouse and keyboard show a noticeable lag, and it takes a unusual long time for the headset to disappear after turning it off. Finally, the other bluetooth devices respond normally again.
Facts:
- Fedora 34 with KDE
- Sennheiser PXC550
- Bluetooth is part of the Atheros chip: ath10k_pci 0000:02:00.0: qca6174
How Reproducible: Noticable on every call, mostly at the end, sometimes in between. I found that the streams pavucontrol opens (for the VU meters?) probably cause this as well. But there is a simple reproducer.
Steps to Reproduce:
- Freshly connect the headset, switch it to HFP/HSP with mSBC (pavucontrol)
- record something with pw-record, this works repeatedly.
- play something with pw-play,
- further recordings deliver no data, it prints
now=0 rate=0/0 ticks=0 delay=0 queued=0
. Playback is broken, bluetooth input devices have a noticable lag.
% pw-play --list-targets
Available targets ("*" denotes default):
43: description="Built-in Audio Analog Stereo" prio=1009
* 73: description="PXC 550" prio=1010
% pw-record --list-targets
Available targets ("*" denotes default):
44: description="Built-in Audio Analog Stereo" prio=2009
* 69: description="PXC 550" prio=2010
% pw-play -v /tmp/pw.rec2
opened file "/tmp/pw.rec2" format 00010002 channels:2 rate:48000
using default channel map: FL,FR
rate=48000 channels=2 fmt=s16 samplesize=2 stride=4 latency=4800 (0.100s)
connecting playback stream; target_id=4294967295
stream state changed unconnected -> connecting
stream param change: id=2
stream properties:
media.type = "Audio"
media.category = "Playback"
media.role = "Music"
application.name = "pw-play"
media.filename = "/tmp/pw.rec2"
media.name = "/tmp/pw.rec2"
node.name = "pw-play"
media.format = "WAV (Microsoft)"
node.latency = "4800/48000"
node.rate = "1/48000"
stream.is-live = "true"
node.autoconnect = "true"
media.class = "Stream/Output/Audio"
now=0 rate=0/0 ticks=0 delay=0 queued=0
remote 0 is named "pipewire-0"
core done
stream state changed connecting -> paused
stream param change: id=2
stream param change: id=4
stream param change: id=15
stream param change: id=4
stream state changed paused -> streaming
stream param change: id=2
set stream volume to 1.000 - success
stream node 72
stream param change: id=15
now=205571415145 rate=1/48000 ticks=15240 delay=512 queued=0
now=206598902095 rate=1/48000 ticks=31680 delay=512 queued=0
now=207281421361 rate=1/48000 ticks=42600 delay=512 queued=0
now=208301414311 rate=1/48000 ticks=58920 delay=512 queued=0
now=209328923612 rate=1/48000 ticks=75360 delay=512 queued=0
now=210348852651 rate=1/48000 ticks=91680 delay=512 queued=0
stream drained
stream state changed streaming -> paused
stream param change: id=4
stream state changed paused -> unconnected
stream param change: id=4
% pw-record -v /tmp/pw.rec
opened file "/tmp/pw.rec" format 10010002 channels:2 rate:48000
rate=48000 channels=2 fmt=s16 samplesize=2 stride=4 latency=0 (0.000s)
connecting record stream; target_id=4294967295
stream state changed unconnected -> connecting
stream properties:
media.type = "Audio"
media.category = "Capture"
media.role = "Music"
application.name = "pw-record"
media.filename = "/tmp/pw.rec"
media.name = "/tmp/pw.rec"
node.name = "pw-record"
node.rate = "1/48000"
stream.is-live = "true"
node.autoconnect = "true"
media.class = "Stream/Input/Audio"
now=0 rate=0/0 ticks=0 delay=0 queued=0
remote 0 is named "pipewire-0"
core done
stream state changed connecting -> paused
stream param change: id=2
stream param change: id=4
stream param change: id=15
stream param change: id=4
stream state changed paused -> streaming
stream param change: id=2
set stream volume to 1.000 - success
stream node 78
now=0 rate=0/0 ticks=0 delay=0 queued=0
now=0 rate=0/0 ticks=0 delay=0 queued=0
now=0 rate=0/0 ticks=0 delay=0 queued=0
now=0 rate=0/0 ticks=0 delay=0 queued=0
^Cstream state changed streaming -> paused
stream param change: id=4
stream state changed paused -> unconnected
stream param change: id=4