BTA2DPD(8) | System Manager's Manual | BTA2DPD(8)

# NAME

`bta2dpd` —
Bluetooth Advanced Audio Distribution Profile daemon

# SYNOPSIS

`bta2dpd` | [`-Dv`] [`-A` bitpool_allocation] [`-B` bitpool] [`-b` blocks] [`-d` device] [`-e` encoding_bands] [`-f` channel_mode] [`-M` mtu] [`-m` mode] [`-r` rate] [`-V` volume] `-a` address files ...

`bta2dpd` | `-K` [`-DIv`] [`-A` bitpool_allocation] [`-B` bitpool] [`-b` blocks] [`-d` device] [`-e` encoding_bands] [`-f` channel_mode] [`-m` mode] [`-p` psm] [`-r` rate] [a address] file

`bta2dpd` | `-t` [`-A` bitpool_allocation] [`-B` bitpool] [`-b` blocks] [`-e` encoding_bands] [`-f` channel_mode] [`-M` mtu] [`-r` rate] [`-V` volume] files ...

`bta2dpd` | `-t` `-K` file

# DESCRIPTION

The `bta2dpd` daemon is used to transmit/receive audio to/from Bluetooth devices such as speakers or headphones, using the Advanced Audio Distribution Profile (A2DP).

`-a` address
  Remote device address. The address may be given as BDADDR or a name.

  If a name was specified, `bta2dpd` attempts to resolve the name via bt_gethostbyname(3).

`-B` bitpool
  Allows setting the maximum bitpool value for your device. This may have to be lowered if audio is distorted.

  Use `bta2dpd` with only the `-v` option and the maximum bitpool for your device will be printed to stdout.

`-D`
  Run in the background.
`-d` device
  Local device address. May be given as BDADDR or device name.
`-I`
  Initiate a Discover command.
  Useful when used as an audio sink as some devices need this to pair.
`-K`
  Allows registering as an audio sink receiving an incoming connection.
`-M` mtu
  Allows setting the Maximum Transmission Unit (MTU) for the streaming connections.

  For most devices this would be 672 but if audio is broken or has gaps lowering this value may help.

`-m` mode
  Set L2CAP connection link mode. Supported modes are:

  auth
    Require devices to be paired.
  encrypt
    Auth, plus enable encryption.
  secure
    Encryption, plus change of link key.
`-p` psm
  Allows changing the l2cap psm for an audio sink the default is 25. Most all devices will use 25.
`-t`
  Test mode can be used with `-K` to decode and receive encoded music from stdout/stdin to file.
`-V` volume
  Allows shifting the volume of the music by 1 or 2 bits prior to encoding for increased volume.

  USE WITH CARE as this may mean the output is quite loud.

`-v`
  Be verbose.
files ...
  Files to stream. These can be WAV files or CD-Audio Red Book data or output from a pad(4) device. If not specified, the default is stdin or stdout if `-K` applied and `bta2dpd` is used as an audio sink.

  When writing to a file or stdout it is raw 16-bit little endian (pulse coded modulation) PCM data. So a utility must be used to convert the file to add a header or use the audioplay(1) command as stated in EXAMPLES.

## Channel Modes

`-f` channel_mode
  0
    This specifies that all possible input formats are accepted and then one is chosen starting with joint stereo then stereo then 2 channel then mono.
  m
    This specifies that the input is monophonic.
  2
    This specifies that the input is dual-channel.
  j
    This specifies that the input is joint-stereo.
  s
    This specifies that the input is stereo. This is the default.

  Specifying joint stereo as opposed to stereo would allow for a slightly higher quality of playback as `bta2dpd` will only encode stereo and monophonic streams.

`-r` rate
  The frequency of the input. Where rate is one of 0, 16000, 32000, 44100, 48000. This defaults to 44.1 kHz.

  A value of 0 will arbitrate from the highest to lowest frequency.

## Sub Band Codec (SBC) Encoding Options

`-A` bitpool_allocation
  0
    Bit Allocation is negotiated starting with Loudness then SNR.
  S
    Audio is encoded with SNR (Signal to Noise Ratio) bit allocation.
  L
    Audio is encoded with Loudness bit allocation. This is the default.
`-b` blocks
  Number of blocks to use for encoding. Where blocks is one of 0, 4, 8, 12, 16. This defaults to 16 blocks.

  In the case of 0 the number of blocks is negotiated starting from 16 down to 4.

`-e` bands
  0
    Number of SBC bands is negotiated 8 then 4.
  4
    Audio is encoded with 4 SBC bands.
  8
    Audio is encoded with 8 SBC bands. This is the default.

It may be necessary to use btconfig(8) to set the class of your Bluetooth adapter to that of headphones when using `bta2dpd` as an audio sink. I.e.,

`btconfig ubt0 class 0x200418`
Then start `bta2dpd` with `-K` before pairing.

This is necessary as some devices only perform an sdpquery(1) just after pairing and cache the result.

It is possible to specify multiples of `-r` `-e` `-b` `-f`. This will mean that the specified combinations are reported as being accepted by the source/sink.

When used as a sink (`-K`), all modes, bands, blocks and allocation modes will be accepted unless specified as options. I.e., `-r` 44100 will only accept a connection with a rate of 44.1kHz.

# EXAMPLES

`bta2dpd -a spkr my.wav`
Encode and send audio my.wav to address ‘spkr’.

`bta2dpd -a spkr /dev/pad`
Encode and send audio from pad(4) to address ‘spkr’.

`bta2dpd -K out.pcm`
Decode stream from any connected address and write it to out.pcm.

`bta2dpd -K -a phone | audioplay -f -e linear -P 16 -s 44100 -c 2 --`
Decode stream from address ‘phone’ and send to speakers.

# SEE ALSO

audioplay(1), sdpquery(1), pad(4), btconfig(8)

# AUTHORS

Nathanial Sloss

July 27, 2019 | NetBSD 9.2