bluez-alsa: SCO record quality is not great
Hello,
I’m testing recording from two BT headsets. Zebra HS3100 and Plantronics Voyager Legend.
Playback quality is great, but recording is quiet, crackling, and slightly sped up.
I’m using the latest master (24b7300) with and without --enable-debug. Launched as: /usr/bin/bluealsa --syslog -p a2dp-sink -p a2dp-source -p hfp-hf -p hfp-ag -p hsp-hs -p hsp-ag
Any hints would be a appreciated to improve record quality.
If it helps, here are the logs from arecord:
# arecord -v -fS16_LE -r 8000 -Dbluealsa:DEV=00:1B:41:B2:86:9A,PROFILE=sco test.wav
D: src/asound/bluealsa-pcm.c:1312: Getting BlueALSA PCM: CAPTURE 00:1B:41:B2:86:9A sco
D: src/asound/bluealsa-pcm.c:1062: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Setting constraints
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
D: src/asound/bluealsa-pcm.c:532: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Initializing HW
D: src/asound/bluealsa-pcm.c:567: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: FIFO buffer size: 32768 frames
D: src/asound/bluealsa-pcm.c:573: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Selected HW buffer: 4 periods x 2000 bytes == 8000 bytes
D: src/asound/bluealsa-pcm.c:600: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Initializing SW
D: src/asound/bluealsa-pcm.c:600: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Initializing SW
D: src/asound/bluealsa-pcm.c:639: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Prepared
D: src/asound/bluealsa-pcm.c:600: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Initializing SW
Plug PCM: BlueALSA PCM: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source
BlueALSA BlueZ device: /org/bluez/hci0/dev_00_1B_41_B2_86_9A
BlueALSA Bluetooth codec: CVSD
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 8000
exact rate : 8000 (8000/1)
msbits : 16
buffer_size : 4000
period_size : 1000
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 1000
period_event : 0
start_threshold : 1
stop_threshold : 4000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
D: src/asound/bluealsa-pcm.c:356: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Starting
D: src/asound/bluealsa-pcm.c:226: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Starting IO loop: 7
-- a few seconds later I press Ctrl-C --
^CAborted by signal Interrupt...
arecord: pcm_read:2151: read error: Interrupted system call
D: src/asound/bluealsa-pcm.c:392: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Stopping
D: src/asound/bluealsa-pcm.c:161: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: IO thread cleanup
D: src/asound/bluealsa-pcm.c:592: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Freeing HW
D: src/asound/bluealsa-pcm.c:443: /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source: Closing
And here are the logs from BlueAlsa daemon:
user.debug /usr/bin/bluealsa: src/dbus.c:66: Called: org.bluealsa.PCM1.Open() on /org/bluealsa/hci0/dev_00_1B_41_B2_86_9A/hfpag/source
user.debug /usr/bin/bluealsa: src/ba-transport.c:710: New SCO link: 00:1B:41:B2:86:9A: 24
user.debug /usr/bin/bluealsa: src/hci.c:132: SCO link socket MTU: 24: 180
user.debug /usr/bin/bluealsa: src/ba-transport.c:1145: Starting transport: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/ba-transport.c:293: Created BT socket duplicate: [24]: 25
user.debug /usr/bin/bluealsa: src/ba-transport.c:1462: Created new IO thread [ba-sco-enc]: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/ba-transport.c:293: Created BT socket duplicate: [24]: 26
user.debug /usr/bin/bluealsa: src/ba-transport.c:1462: Created new IO thread [ba-sco-dec]: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/sco.c:229: IO loop: START: sco_cvsd_enc_thread: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/sco.c:297: IO loop: START: sco_cvsd_dec_thread: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/ba-transport.c:1377: PCM resumed: 21
user.debug /usr/bin/bluealsa: src/ba-transport.c:1424: Closing PCM: 21
user.debug /usr/bin/bluealsa: src/ba-transport.c:437: PCM clients check keep-alive: 0 ms
user.debug /usr/bin/bluealsa: src/ba-transport.c:386: Stopping transport: No PCM clients
user.debug /usr/bin/bluealsa: src/ba-transport.c:305: Closing BT socket duplicate [24]: 25
user.debug /usr/bin/bluealsa: src/ba-transport.c:725: Releasing SCO link: 24
user.debug /usr/bin/bluealsa: src/ba-transport.c:1487: Exiting IO thread [ba-sco-enc]: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/ba-transport.c:305: Closing BT socket duplicate [-1]: 26
user.debug /usr/bin/bluealsa: src/sco.c:319: IO loop: EXIT: sco_cvsd_dec_thread: HFP Audio Gateway (CVSD)
user.debug /usr/bin/bluealsa: src/ba-transport.c:1487: Exiting IO thread [ba-sco-dec]: HFP Audio Gateway (CVSD)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (10 by maintainers)
Commits related to this issue
- Always keep CVSD read buffer bigger than read MTU Read less data than the SCO MTU might cause issues with prompt SCO buffer flushing, which in turn might cause audio issues. Fixes #510 — committed to arkq/bluez-alsa by arkq 3 years ago
- Always keep CVSD read buffer bigger than read MTU Reading less data than the SCO MTU might cause issues with prompt SCO buffer flushing, which in turn might cause audio issues. Fixes #510 — committed to arkq/bluez-alsa by arkq 3 years ago
Yes, that might happen, but in such a case it will be a fatal error later (there is a check in https://github.com/Arkq/bluez-alsa/blob/master/src/ba-transport.c#L282).
@hrc-amilcar if you have time, please could you try my branch here: https://github.com/borine/bluez-alsa/tree/sco-mtu-bus-check
This is actually a work-in-progress implementing changes discussed in #400, but I think that the change in CVSD mtu handlng for UART adapters may also possibly help with the issue reported here.