How to use bta2dpd(8) with Bluetooth headphone under NetBSD-current


When USB Bluetooth dongle (ubt(4)) is used, classic Bluetooth SCO Audio (btsco(4)) requires USB isochronous transfer and ehci(4) and xhci(4) of NetBSD-current does not support USB isochronous transfer mode, So I cannot use btsco(4) to play audio under NetBSD-current.

Some time ago, bta2dpd(8) was imported to NetBSD-current by nat@. I had not tested bta2dpd(8) and I should test bta2dp(8) with Jabra MOVE Wireless. As a result, I can play audio with ubt(4) and Javra MOVE Wireless.

Basic Bluetooth settings

How to pairing and selecting profile is as same as btsco(4). Please perform the following steps.

At first, run daemon/service for Bluetooth. Please perform the following steps.

# vi /etc/rc.conf
# /etc/rc.d/bluetooth start
configuring Bluetooth controllers: ubt0.
starting Bluetooth Link Key/PIN Code manager
starting Bluetooth Service Discovery server
If your Bluetooth connection is temporary, you can perform the following steps instead.

# /etc/rc.d/bluetooth onestart
configuring Bluetooth controllers: ubt0.
starting Bluetooth Link Key/PIN Code manager
starting Bluetooth Service Discovery server

Next, turn your wireless headphone to pairing mode and perform the followings to get Bluetooth address.

$ btconfig ubt0 inquiry
Device Discovery from device: ubt0 ... 1 response
  1: bdaddr XX:YY:ZZ:XX:YY:ZZ
   : name "Jabra MOVE v2.5.0"
   : class [0x240404] Wearable Headset  
For easier to identification, record this address in /etc/bluetooth/hosts as headset1.

# vi /etc/bluetooth/hosts
XX:YY:ZZ:XX:YY:ZZ headset1

Next, set Bluetooth PIN.

$ btpin -d ubt0 -a headset1 -p 0000
Jabra MOVE Wireless assumes PIN as 0000.

Next, the device, set headset1 as headset (HSET).

# btdevctl -d ubt0 -a headset1 -s HSET -A
XXX: This setting is not required. (2020-06-06)

Above procedure is as same as btsco(4). I will use bta2dpd(8) as follows. Perform basic test.

$ file test.wav
test.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz
# bta2dpd -a headset1 test.wav
You may want to play mp3 file or others. If you use mplayer with OSS, you can use pad(4).

# bta2dpd -a headset1 /dev/pad
After this invocation, you can see as follows in your dmesg.

pad0: outputs: 44100Hz, 16-bit, stereo
audio2 at pad0: half duplex, playback, capture, mmap
pad0: Virtual format configured - Format SLINEAR, precision 16, channels 2, frequency 44100
spkr3 at audio2: PC Speaker (synthesized)
wsbell at spkr3 not configured
This messages show you that if you play audio to /dev/sound2, your audio stream will appear in /dev/pad0. For example, the following command plays audio your Bluetooth headphone.

$ mplayer -ao oss:/dev/sound2 test.mp3


You can use Bluetooth audio with xhci(4) of NetBSD-current.


この記事は、 NetBSD Advent Calendar 2023 の1日目の記事です。 はじめに 最近のMozilla Firefoxには、text-to-speech機能を利用するための仕組みが組み込まれています。 しかし、Firefox自体がテキストの内容を...