Skip to content

Instantly share code, notes, and snippets.

Last active April 5, 2020 02:23
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 maxrp/fe97f9c84c512536b7876042a14626ba to your computer and use it in GitHub Desktop.
Save maxrp/fe97f9c84c512536b7876042a14626ba to your computer and use it in GitHub Desktop.
Notes on getting audio out of my FreeBSD 13.0-CURRENT laptop over bluetooth to a speaker.

Bluetooth Audio from a Lenovo X220 running FreeBSD 13.0-CURRENT


The FreeBSD Handbook Bluetooth chapter is, as usual, great but I needed to do a bit more (or perhaps in a more specific way) to get audio from the Broadcom Bluetooth chip in my Lenovo X220 to the Soundblaster Roar SR20 that lives in my kitchen.


Load the user character device driver cuse and all the netgraph bluetooth modules, this is better done earlier to avoid the annoying (and possibly significant) WARNING: attempt to domain_add(xyz) after domainfinalize() errors at startup.

ng_ubt_load="YES"  # for most USB bluetooth, for others, refer to the handbook



Device configuration

Assuming your bluetooth device name is ubt0...

cp /etc/defaults/bluetooth.device.conf /etc/bluetooth/ubt0.conf

In my case I set local_name to the hostname and also set role_switch="NO"

Start the bluetooth stack

service hcsecd start
service bluetooth start ubt0  # if this fails, do it again

Pair with the device for the first time

If you're going to use encryption, set the audio device to pairing mode first.

# bluetooth-config scan
Scanning for new Bluetooth devices (Attempt 1 of 5) ... done.
Found 1 new bluetooth device (now scanning for names):
[ 1] 00:02:3c:xx:xx:xx	"SB ROAR SR20A" (SB_ROAR_SR20A)
Select device to pair with [1, or 0 to rescan]: 1

Writing pairing information description block to /etc/bluetooth/hcsecd.conf.    
(To get PIN, put device in pairing mode first.  )
Enter PIN [nopin]: 0000
Stopping hcsecd.
Waiting for PIDS: 58789.
Starting hcsecd.

bluetooth-config will create an entry in /etc/bluetooth/hosts mapping the bluetooth device's MAC address to a short name. In this case, the shortname for my device is SB_ROAR_SR20A.

Create the virtual OSS device

This step creates the virtual device /dev/dsp, the device /dev/bluetooth/SB_ROAR_SR20A won't actually exist in the dev filesystem so don't go looking for it. Also you can use the shortname defined in /etc/bluetooth/hosts or the full MAC address.

virtual_oss -C 2 -c 2 -r 48000 -b 16 -s 768 -R /dev/null -P /dev/bluetooth/SB_ROAR_SR20A -d dsp

After this on subsequent reboots I only needed to re-run the virtual_oss command to reconnect.

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