.\" $NetBSD: bta2dpd.8,v 1.6.2.1 2023/07/24 17:08:01 martin Exp $ .\" .\" Copyright (c) 2015 - 2016 Nathanial Sloss .\" All rights reserved. .\" .\" This software is dedicated to the memory of - .\" Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012. .\" .\" Barry was a man who loved his music. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd July 20, 2023 .Dt BTA2DPD 8 .Os .Sh NAME .Nm bta2dpd .Nd Bluetooth Advanced Audio Distribution Profile daemon .Sh SYNOPSIS .Nm .Op Fl \&Dnv .Op Fl A Ar bitpool_allocation .Op Fl B Ar bitpool .Op Fl b Ar blocks .Op Fl d Ar device .Op Fl e Ar encoding_bands .Op Fl f Ar channel_mode .Op Fl M Ar mtu .Op Fl m Ar mode .Op Fl r Ar rate .Op Fl V Ar volume .Fl a Ar address .Ar files ... .Nm .Fl K .Op Fl DIv .Op Fl A Ar bitpool_allocation .Op Fl B Ar bitpool .Op Fl b Ar blocks .Op Fl d Ar device .Op Fl e Ar encoding_bands .Op Fl f Ar channel_mode .Op Fl m Ar mode .Op Fl p Ar psm .Op Fl r Ar rate .Op a Ar address .Ar file .Nm .Fl t .Op Fl A Ar bitpool_allocation .Op Fl B Ar bitpool .Op Fl b Ar blocks .Op Fl e Ar encoding_bands .Op Fl f Ar channel_mode .Op Fl M Ar mtu .Op Fl r Ar rate .Op Fl V Ar volume .Ar files ... .Nm .Fl t .Fl K .Ar file .Sh DESCRIPTION The .Nm daemon is used to transmit/receive audio to/from Bluetooth devices such as speakers or headphones, using the Advanced Audio Distribution Profile (A2DP). .Bl -tag -width indent .It Fl a Ar address Remote device address. The .Ar address may be given as BDADDR or a name. .Pp If a name was specified, .Nm attempts to resolve the name via .Xr bt_gethostbyname 3 . .It Fl B Ar bitpool Allows setting the maximum bitpool value for your device. This may have to be lowered if audio is distorted. .Pp Use .Nm with only the .Fl v option and the maximum bitpool for your device will be printed to stdout. .It Fl D Run in the background. .It Fl n Do not close connection on end of file (EOF). Useful for .Xr pad 4 . .It Fl d Ar device Local device address. May be given as BDADDR or device name. .It Fl I Initiate a Discover command. Useful when used as an audio sink as some devices need this to pair. .It Fl K Allows registering as an audio sink receiving an incoming connection. .It Fl M Ar mtu Allows setting the Maximum Transmission Unit (MTU) for the streaming connections. .Pp For most devices this would be 672 but if audio is broken or has gaps lowering this value may help. .It Fl m Ar mode Set L2CAP connection link mode. Supported modes are: .Pp .Bl -tag -compact -width encrypt .It auth Require devices to be paired. .It encrypt Auth, plus enable encryption. .It secure Encryption, plus change of link key. .El .It Fl p Ar psm Allows changing the l2cap psm for an audio sink the default is 25. Most all devices will use 25. .It Fl t Test mode can be used with .Fl K to decode and receive encoded music from stdout/stdin to file. .It Fl V Ar volume Allows shifting the volume of the music by 1 or 2 bits prior to encoding for increased volume. .Pp .Sy USE WITH CARE as this may mean the output is quite loud. .It Fl v Be verbose. .It Ar files ... Files to stream. These can be WAV files or CD-Audio Red Book data or output from a .Xr pad 4 device. If not specified, the default is stdin or stdout if .Fl K applied and .Nm is used as an audio sink. .Pp 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 .Xr audioplay 1 command as stated in .Sx EXAMPLES . .El .Ss Channel Modes .Bl -tag -width indent .It Fl f Ar channel_mode .Bl -tag -width 2n .It Ar 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. .It Ar m This specifies that the input is monophonic. .It Ar 2 This specifies that the input is dual-channel. .It Ar j This specifies that the input is joint-stereo. .It Ar s This specifies that the input is stereo. This is the default. .El .Pp Specifying joint stereo as opposed to stereo would allow for a slightly higher quality of playback as .Nm will only encode stereo and monophonic streams. .It Fl r Ar rate The frequency of the input. Where rate is one of 0, 16000, 32000, 44100, 48000. This defaults to 44.1 kHz. .Pp A value of 0 will arbitrate from the highest to lowest frequency. .El .Ss Sub Band Codec (SBC) Encoding Options .Bl -tag -width indent .It Fl A Ar bitpool_allocation .Bl -tag -width 2n .It Ar 0 Bit Allocation is negotiated starting with Loudness then SNR. .It Ar S Audio is encoded with SNR (Signal to Noise Ratio) bit allocation. .It Ar L Audio is encoded with Loudness bit allocation. This is the default. .El .It Fl b Ar blocks Number of blocks to use for encoding. Where blocks is one of 0, 4, 8, 12, 16. This defaults to 16 blocks. .Pp In the case of 0 the number of blocks is negotiated starting from 16 down to 4. .It Fl e Ar bands .Bl -tag -width 2n .It Ar 0 Number of SBC bands is negotiated 8 then 4. .It Ar 4 Audio is encoded with 4 SBC bands. .It Ar 8 Audio is encoded with 8 SBC bands. This is the default. .El .El .Pp It may be necessary to use .Xr btconfig 8 to set the class of your Bluetooth adapter to that of headphones when using .Nm as an audio sink. I.e., .Dl btconfig ubt0 class 0x200418 Then start .Nm with .Fl K before pairing. .Pp This is necessary as some devices only perform an .Xr sdpquery 1 just after pairing and cache the result. .Pp It is possible to specify multiples of .Fl r Fl e Fl b Fl f . This will mean that the specified combinations are reported as being accepted by the source/sink. .Pp When used as a sink .Fl ( K ) , all modes, bands, blocks and allocation modes will be accepted unless specified as options. I.e., .Fl r Ar 44100 will only accept a connection with a rate of 44.1kHz. .Sh EXAMPLES .Dl bta2dpd -a spkr my.wav Encode and send audio .Pa my.wav to address .Sq spkr . .Pp .Dl bta2dpd -n -a spkr /dev/pad Encode and send audio from .Xr pad 4 to address .Sq spkr . .Pp .Dl bta2dpd -K out.pcm Decode stream from any connected address and write it to .Pa out.pcm . .Pp .Dl bta2dpd -K -a phone | audioplay -f -e slinear_le -P 16 -s 44100 -c 2 -- Decode stream from address .Sq phone and send to speakers. .Sh SEE ALSO .Xr audioplay 1 , .Xr sdpquery 1 , .Xr pad 4 , .Xr btconfig 8 .Sh AUTHORS .An Nathanial Sloss .Sh BUGS For some devices playback from file results in rapid playback or playback with stutter. For best results use with .Xr pad 4 .