I have my NAS on the base of Cubietruck (Ubuntu Xenial with Armbian Linux 3.4.113-sun7i) with integrated bluetooth. Now I'm trying to send audio to my bluetooth speaker via bluealsa.
Initially I've used this manual to install and setup bluealsa: https://forum.armbian.com/topic/6480-bluealsa-bluetooth-audio-using-alsa-not-pulseaudio/
I've ended with same problem as I'm having now after recompiling and setting up bluealsa again using this manual: https://raspberrypi.stackexchange.com/questions/90267/how-to-stream-sound-to-a-bluetooth-device-from-a-raspberry-pi-zero
which gave me a bit more progress, for example I can see such message while connecting to my bluetooth speaker: [BH129]# bluealsa: D: ../../src/bluez.c:1267: Signal: org.freedesktop.DBus.Objec tManager.InterfacesAdded()
I didn't see such message when installed and setup bluealsa according to 1st manual.
I'm starting bluealsa first manually after boot. By the way is bluetooth-profile correct: – hsp-hs Headset (v1.2)?
bluealsa -p hsp-hs &
Bluealsa seems to be running:
root@Artisan:~# ps -ef | grep bluealsa
root 2591 2557 0 15:16 pts/0 00:00:00 bluealsa -p hsp-hs
root 2803 2557 1 15:58 pts/0 00:00:00 grep --color=auto bluealsa
Here's how I connect to my speaker:
[bluetooth]# scan on
Discovery started
[CHG] Controller 43:29:B1:55:01:01 Discovering: yes
[NEW] Device EB:06:EF:47:83:A6 BH129
[bluetooth]# pair EB:06:EF:47:83:A6
Attempting to pair with EB:06:EF:47:83:A6
[CHG] Device EB:06:EF:47:83:A6 Class: 0x240404
[CHG] Device EB:06:EF:47:83:A6 Icon: audio-card
[CHG] Device EB:06:EF:47:83:A6 Connected: yes
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 00001108-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 UUIDs: 0000180f-0000-1000-8000-00805f9b34fb
[CHG] Device EB:06:EF:47:83:A6 Paired: yes
Pairing successful
[CHG] Device EB:06:EF:47:83:A6 Connected: no
[bluetooth]# trust EB:06:EF:47:83:A6
[CHG] Device EB:06:EF:47:83:A6 Trusted: yes
Changing EB:06:EF:47:83:A6 trust succeeded
[bluetooth]# connect EB:06:EF:47:83:A6
Attempting to connect to EB:06:EF:47:83:A6
[CHG] Device EB:06:EF:47:83:A6 Connected: yes
[BH129]# bluealsa: D: ../../src/bluez.c:1267: Signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded()
Connection successful
[BH129]# exit
[DEL] Controller 43:29:B1:55:01:01 BlueZ 5.37 [default]
Here's bluetooth status
root@Artisan:~# systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-12-18 15:13:37 UTC; 36min ago
Docs: man:bluetoothd(8)
Main PID: 1307 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─1307 /usr/lib/bluetooth/bluetoothd --noplugin=sap --plugin=a2dp
Dec 18 15:13:37 Artisan bluetoothd[1307]: Ignoring (cli) thermometer
Dec 18 15:13:37 Artisan bluetoothd[1307]: Ignoring (cli) heartrate
Dec 18 15:13:37 Artisan bluetoothd[1307]: Ignoring (cli) cyclingspeed
Dec 18 15:13:37 Artisan bluetoothd[1307]: Ignoring (cli) sixaxis
Dec 18 15:13:37 Artisan bluetoothd[1307]: Bluetooth management interface 1.0 initialized
Dec 18 15:13:37 Artisan bluetoothd[1307]: Failed to obtain handles for "Service Changed" characterist
Dec 18 15:13:37 Artisan systemd[1]: Started Bluetooth service.
Dec 18 15:14:36 Artisan bluetoothd[1307]: Endpoint registered: sender=:1.52 path=/MediaEndpoint/A2DPS
Dec 18 15:14:36 Artisan bluetoothd[1307]: Endpoint registered: sender=:1.52 path=/MediaEndpoint/A2DPS
Dec 18 15:14:40 Artisan bluetoothd[1307]: Ignoring unsupported UUID for addition
I was a bit confused with "Alsa config" section and ended with configuring it this way:
root@Artisan:~# cat /usr/share/alsa/alsa.conf.d/20-bluealsa.conf # BlueALSA integration setup
defaults.bluealsa.service "org.bluealsa"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 20000
defaults.bluealsa.battery "yes"
ctl.bluealsa {
@args [ SRV BAT ]
@args.SRV {
type string
default {
@func refer
name defaults.bluealsa.service
}
}
@args.BAT {
type string
default {
@func refer
name defaults.bluealsa.battery
}
}
type bluealsa
service $SRV
battery $BAT
}
pcm.bluealsa {
@args [ SRV DEV PROFILE DELAY ]
@args.SRV {
type string
default {
@func refer
name defaults.bluealsa.service
}
}
@args.DEV {
type string
default {
@func refer
name defaults.bluealsa.device
}
}
@args.PROFILE {
type string
default {
@func refer
name defaults.bluealsa.profile
}
}
@args.DELAY {
type integer
default {
@func refer
name defaults.bluealsa.delay
}
}
type plug
slave.pcm {
type bluealsa
service $SRV
device $DEV
profile $PROFILE
delay $DELAY
}
hint {
show {
@func refer
name defaults.namehint.extended
}
description "Bluetooth Audio Hub"
}
}
pcm {
type bluealsa
interface "hci0"
device EB:06:EF:47:83:A6
profile "a2dp"
}
ctl.!default {
type bluealsa
interface "hci0"
}
Here's ~/asoundrc
root@Artisan:~# cat ~/.asoundrc
defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "EB:06:EF:47:83:A6"
defaults.bluealsa.profile "a2dp"
Here's what I get when I try to play mp3 file with aplay:
root@Artisan:~# aplay -D bluealsa:DEV=EB:06:EF:47:83:A6,PROFILE=a2dp,HCI=hci0 /ncsdata/Music/night.mp3
ALSA lib conf.c:4622:(parse_args) Unknown parameter HCI
ALSA lib conf.c:4755:(snd_config_expand) Parse arguments error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM bluealsa:DEV=EB:06:EF:47:83:A6,PROFILE=a2dp,HCI=hci0
aplay: main:722: audio open error: No such file or directory
root@Artisan:~# aplay -D bluealsa:DEV=EB:06:EF:47:83:A6,PROFILE=a2dp /ncsdata/Music/night.mp3
bluealsa: D: ../../src/bluealsa-dbus.c:139: Called: org.bluealsa.Manager1.GetPCMs()
ALSA lib ../../../src/asound/bluealsa-pcm.c:755:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: PCM not found
aplay: main:722: audio open error: No such device
mpd is configured for bluealsa
audio_output {
type "alsa"
name "ALSA Bluetooth Headset"
device "bluealsa"
mixer_type "software"
}
Here's what I get trying to play mp3 with mpd:
root@Artisan:~# /etc/init.d/mpd start
[ ok ] Starting mpd (via systemctl): mpd.service.
root@Artisan:~# mpc clear
volume: 90% repeat: off random: off single: off consume: off
ERROR: Failed to open audio output
root@Artisan:~# mpc add night.mp3
root@Artisan:~# mpc play
Unknown artist - Night (Original)
[playing] #1/1 0:00/2:46 (0%)
volume: 90% repeat: off random: off single: off consume: off
root@Artisan:~# mpc stop
volume: 90% repeat: off random: off single: off consume: off
ERROR: Failed to open audio output
Error messages were identical after setting everything up by 1st and 2nd manuals.
Speaker makes no sound of course. I feel that I'm near the solution, but can't figure out what am I missing. Googling aplay or mpd messages – no luck. I would appreciate your help.
Best Answer
Well then, after dancing around and buying another bluetooth receiver I've managed to stream audio on it via bluealsa and mpd.
Here are configs which I've edited:
/usr/share/alsa/alsa.conf.d/20-bluealsa.conf
/lib/systemd/system/bluetooth.service
/lib/systemd/system/bluealsa.service
Don't forget to enable bluealsa.service:
~/.asoundrc isn't necessary and removed.
Reboot and this worked for me. The other thing is how it works - unfortunately audio is extremely glitchy. It breaks every half second, not depending on distance between NAS and bluetooth receiver, not depending on file format. Can't understand why and looking for solution. Any ideas?