Skip to content

Instantly share code, notes, and snippets.

@tildebyte
Last active February 5, 2020 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tildebyte/dbce2ea7ba9f090759a8f985d0892ee0 to your computer and use it in GitHub Desktop.
Save tildebyte/dbce2ea7ba9f090759a8f985d0892ee0 to your computer and use it in GitHub Desktop.
Bluetooth audio on fates

Bluetooth audio for fates

Mostly this is from memory, and of dubious accuracy (but getting better :p)

Requirements:

  • bluetoothctl (probably installed by default on raspbian)
  • bluealsa (apt installable)
  • alsa_out (comes with jackd)
  • libsbc1 (apt installable)

Discussion

tldr; 1) the weakest part of this whole Rube Goldberg machine is alsa_out -- it's exceedingly noisy (logging-wise), and temperamental and 2) firing a script on device connect under rasbian is a bitch

You must add --noplugin=sap to the "ExecStart=/usr/lib/bluetooth/bluetoothd" command in "/etc/systemd/system/bluetooth.target.wants/bluetooth.service"

'~/.asoundrc' works as-is, and is a hard requirement (the "device" entry has to match the user's actual device, natch)

Pairing/connecting once successfully using bluetoothctl should be sufficient for fates & headset to auto-connect after that

Discovering the in/out-puts for use with jack_connect: use /usr/bin/jack_lsp.

Default fates:

/usr/bin/jack_lsp
system:capture_1
system:capture_2
system:playback_1
system:playback_2
crone:input_1
crone:input_2
**snip**
crone:output_1
crone:output_2
**snip**
softcut:input_1
**snip**
SuperCollider:out_1

fates with my Bose headset connected (n.b. the last two entries):

/usr/bin/jack_lsp
system:capture_1
**snip**
SuperCollider:out_1
boseqc35ii:playback_1
boseqc35ii:playback_2

Running systemctl start --user boseqc35ii works to hook up the headset to jack. I tried setting it up as a system service, thinking that permissions might be causing issues with udev, but it turns out that root can't use the user's jackd...

"Hot-plugging" does indeed trigger udev -- but the service doesn't start...

The commented-out bits in the "Unit" section of 'boseqc35ii.service' should in theory work -- but don't

udev/systemd stuff - my primary source of info

defaults.bluealsa {
service "org.bluealsa"
profile "a2dp"
delay 10000
}
pcm.boseqc35ii {
type plug
slave {
pcm {
type bluealsa
device XX:XX:XX:XX:XX:XX
profile "a2dp"
}
}
hint {
show on
description "Bose QC 35 II"
}
}
ctl.boseqc35ii {
type bluealsa
}
# /etc/udev/rules.d/00-boseqc35ii.rules
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci0:11", SYMLINK+="boseqc35ii", TAG+="systemd", MODE="0666", ENV{SYSTEMD_WANTS}="boseqc35ii.service"
# /etc/systemd/system/boseqc35ii.service
[Unit]
Description=Connect Bose QC35 II to crone
#After=sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-hci0:11.device
#BindsTo=sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-hci0:11.device
#Wants=sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-hci0:11.device
#Requires=sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-hci0:11.device
[Service]
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/alsa_out -j boseqc35ii -d boseqc35ii -p 1066 -n 9 -c 2 > /dev/null 2>&1
ExecStartPost=/bin/sleep 5
ExecStartPost=/usr/bin/jack_connect crone:output_1 boseqc35ii:playback_1
ExecStartPost=/usr/bin/jack_connect crone:output_2 boseqc35ii:playback_2
@tildebyte
Copy link
Author

Yep, moved the systemd file from '/etc/systemd/system' to '~/.config/systemd/user' and now I can successfully systemctl start --user boseqc35ii again.

@okyeron
Copy link

okyeron commented Feb 5, 2020

Additional notes:

SAP Driver Initialization Failure

RE: https://raspberrypi.stackexchange.com/questions/40839/sap-error-on-bluetooth-service-status

sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service

ExecStart=/usr/lib/bluetooth/bluetoothd --compat --noplugin=sap -E

Privacy Setting Rejected Failure

RE: https://peppe8o.com/2020/01/fixed-connect-bluetooth-headphones-with-your-raspberry-pi/
sudo nano /lib/systemd/system/bthelper@.service

add ExecStartPre=/bin/sleep 2 to service section

@okyeron
Copy link

okyeron commented Feb 5, 2020

may need to add -r 44100 to alsa_out (was needed for my anker BT speaker)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment