I followed this tutorial to connect and play audio over bluetooth - How to Setup Bluetooth Audio Profiles (Linux) | Toradex Developer Center
Everything works until I get to the last step with Hands Free Phone calls. I initiate the call, but audio is never played through the speakers on my device. I’ve tried 4 different phones (Android & iPhone) but none seem to work.
This is the error message I get in the console
underrun for playback bluealsa:SRV=org.bluealsa,DEV=74:9E:AF:12:A2:04,PROFILE=sco
System Information:
root@verdin-imx8mp-15006329:~# bluealsa-aplay -L
bluealsa:SRV=org.bluealsa,DEV=74:9E:AF:12:A2:04,PROFILE=a2dp
David’s iPhone, phone, capture
A2DP (SBC): S16_LE 2 channels 44100 Hz
bluealsa:SRV=org.bluealsa,DEV=74:9E:AF:12:A2:04,PROFILE=sco
David’s iPhone, phone, playback
SCO (CVSD): S16_LE 1 channel 8000 Hz
bluealsa:SRV=org.bluealsa,DEV=74:9E:AF:12:A2:04,PROFILE=sco
David’s iPhone, phone, capture
SCO (CVSD): S16_LE 1 channel 8000 Hz
root@verdin-imx8mp-15006329:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: imx8mpnau8822 [imx8mp-nau8822], device 0: 30c10000.sai-nau8822-hifi nau8822-hifi-0 [30c10000.sai-nau8822-hifi nau8822-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: audiohdmi [audio-hdmi], device 0: i.MX HDMI i2s-hifi-0 [i.MX HDMI i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
root@verdin-imx8mp-15006329:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: imx8mpnau8822 [imx8mp-nau8822], device 0: 30c10000.sai-nau8822-hifi nau8822-hifi-0 [30c10000.sai-nau8822-hifi nau8822-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
root@verdin-imx8mp-15006329:~# tdx-info
Software summary
Bootloader: U-Boot
Kernel version: 5.15.129-6.4.0-devel+git.67c3153d20ff #1 SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023
Kernel command line: root=PARTUUID=c43924ef-02 ro rootwait console=tty1 console=ttymxc2,115200 consoleblank=0 earlycon
Distro name: NAME=“TDX Wayland with XWayland”
Distro version: VERSION_ID=6.4.0-devel-20231220205908-build.0
Hostname: verdin-imx8mp-15006329
Hardware info
HW model: Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version: 0058 V1.1A
Serial number: 15006329
Processor arch: aarch64
Additional Information:
When I added -v to the alsaloop command, this is the output I received:
root@verdin-imx8mp-15006329:~# ./alsa-call.sh
Scheduler set to Round Robin with priority 99
Scheduler set to Round Robin with priority 99
Scheduler set to Round Robin with priority 99
playback plughw:0,0 open error: Device or resource busy
Loopback initialization failure.
Hardware PCM card 0 ‘imx8mp-nau8822’ device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 1920
period_size : 240
period_time : 5000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 1560
period_event : 0
start_threshold : 2147483647
stop_threshold : 1920
silence_threshold: 0
silence_size : 0
boundary : 8646911284551352320
appl_ptr : 0
hw_ptr : 0
Hardware PCM card 0 ‘imx8mp-nau8822’ device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 1920
period_size : 240
period_time : 5000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 240
period_event : 0
start_threshold : 2147483647
stop_threshold : 1920
silence_threshold: 0
silence_size : 0
boundary : 8646911284551352320
appl_ptr : 0
hw_ptr : 0
Latency 480 frames, 10000.000us, 10.000000ms (100.0000Hz)
playback hw:0,0/capture hw:0,0 sync type: SAMPLERATE (SRC_SINC_FASTEST)
New pitch for playback hw:0,0/capture hw:0,0: 1.00000000 (min/max samples = 0/0)
New pitch for playback hw:0,0/capture hw:0,0: 0.99998958 (min/max samples = -72/0)
ALSA lib …/…/…/git/src/asound/bluealsa-pcm.c:1313:(_snd_pcm_bluealsa_open) Couldn’t get BlueALSA PCM: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
playback bluealsa:SRV=org.bluealsa,DEV=74:9E:AF:12:A2:04,PROFILE=sco open error: No such device
Loopback initialization failure.
New pitch for playback hw:0,0/capture hw:0,0: 0.99998958 (min/max samples = -72/0)
New pitch for playback hw:0,0/capture hw:0,0: 0.99998958 (min/max samples = -72/0)
New pitch for playback hw:0,0/capture hw:0,0: 0.99998958 (min/max samples = -72/0)
New pitch for playback hw:0,0/capture hw:0,0: 1.00000000 (min/max samples = -72/6)
Hello @david.bouthillier ,
On the output of alsaloop -v
, we can see that it failed to open the playback device:
plughw:0,0 open error: Device or resource busy
Usually, when this happens there’s something else in the system already using that resource. Could you check if there are other processes doing anything with sound?
You can try to do that with fuser
:
fuser /dev/snd/*
If that doesn’t show any result, and you know other alsa commands are working on your device (you can play audio with aplay
for instance), please let us know.
Best regards,
Rafael
Hi Rafael,
Thanks for the help.
I ran fuser /dev/snd/*
before and after attempting the hands free phone call. In both cases, the result was empty.
And yes, I verified that I can play a wav file using aplay
Also for clarification, I can get audio to play when in the A2DP role. Music from Spotify on my phone is played through the speaker on the device.
I can reproduce this issue here. After some investigation, I could get a partially working setup doing the following:
# setup sending sco data through host interface (hci)
hcitool -i hci0 cmd 0x3F 0x001D 0x00
alsaloop -g /dev/stdin <<EOF
-C bluealsa:SRV=org.bluealsa,DEV=<connected_bluetooth_mac>,PROFILE=sco -P plughw:0 -r 8000 -c 1 -f s16_le -n -t 40000 -T 1
-C plughw:0 -P bluealsa:SRV=org.bluealsa,DEV=<connected_bluetooth_mac>,PROFILE=sco -r 8000 -c 1 -f s16_le -n -t 40000 -T 2
EOF
But with this, I only get audio coming from the device, but cannot get microphone data out.
I reached this state by reading this excellent page:
It includes lots of information about the potential pitfalls of hands-free profile use.
Is the hands-free use case with a microphone required for your application?
I’m glad to hear that you can reproduce the issue!
Yes, a microphone is critical to our product.
I can confirm the hcitool command fixes the audio portion of the call.
Have you had any luck getting the microphone to work?
Unfortunately, I didn’t have time to continue the investigation, and I’ll probably not be able to come back to it in the next few days.
Hi Rafael. Could you point me to where you found the documentation for the HCI commands for the Azurewave chip? Thanks!
Sure, I found it on the UM11490 document from NXP:
Feature Configuration Guide for NXP-based Wireless Modules on i.MX 8M Quad EVK - User manual
You’ll have to have an account with NXP to download it from this link.
Hi @rafael.tx ,
Good news, it turns out the mic I was using was broken So running the hcitool command is the fix in our situation.
One question though, is the HCI command something the Bluez driver should be doing, or PulseAudio perhaps? Or should our application run this command?
Great! I guess mine must have some problem as well… I’m glad it worked now.
One question though, is the HCI command something the Bluez driver should be doing, or PulseAudio perhaps? Or should our application run this command?
According to here , bluez-alsa does that for some broadcom BT modules where they could find definitive documentation about the correct command. For the TI modules they aren’t sure it will work for all modules, so they don’t do it automatically.
I guess something similar is going on here, either not a lot of people uses the NXP modules to have asked specifically for that, or the developers didn’t have access to the documentation.
1 Like
eric.tx
September 17, 2024, 6:52pm
14
Hey @david.bouthillier ,
It’s been awhile. Have you found a solution/work around to this topic?
Our team has been able to add pluseaudio and webtrc to to try as an alternative method. This can successfully build, but there does still pose some audio issues that may need some effort to fix. Is this something you would be interested in?
-Eric