
Audio over Bluetooth: as detailed as possible about profiles, codecs and devices

Due to the massive launch of smartphones without 3.5mm audio jack, Bluetooth wireless headphones have become the main way to listen to music and communicate in headphone mode for many.

Manufacturers of wireless devices do not always write detailed product specifications, and articles on Bluetooth audio on the Internet are contradictory, in some places incorrect, do not count all functions, and often copy the same information that does not correspond to reality.
Let’s try to understand the protocol, the capabilities of the Bluetooth operating system stacks, headphones and speakers, Bluetooth codecs for music and voice, find out what affects transmitted sound quality and latency, learn how to collect and decode information about supported codecs and other capabilities. Of the device.
Bluetooth music
The functional component of Bluetooth is defined by profiles: specific function specifications. Bluetooth music streaming is done using the A2DP high-quality one-way audio streaming profile. The A2DP standard was adopted in 2003 and has not changed dramatically since then.
Within the profile, 1 mandatory SBC codec of low computational complexity, created specifically for Bluetooth, and 3 additional ones are standardized. It is also allowed to use undocumented codecs of your own implementation.
Why do you need codecs at all, you wonder, when Bluetooth has EDR, which allows data transfer rates at 2 and 3 Mbps, and 1.4 Mbps is sufficient for uncompressed 2-channel 16-bit PCM?
Bluetooth data transmission
In Bluetooth, there are two types of data transfer: Asynchronous Connection Less (ACL) for asynchronous transfer without establishing a connection, and Synchronous Connection Oriented (SCO), for synchronous transfer with prior agreement of the connection.
Transmission is carried out using a time division scheme and the selection of the transmission channel for each packet separately (Frequency Hopping / Time Division-Duplex, FH / TDD), for which time is divided into slots of 625 microseconds called slots. One of the devices transmits in even slot numbers, the other in odd slots. The transmitted packet can occupy 1, 3 or 5 slots, depending on the size of the data and the type of transmission configured, in this case the transmission by a device is carried out in even and odd slots until the end of the transmission. In just one second, you can receive and send up to 1600 packets, if each of them occupies 1 slot, and both devices transmit and receive something without stopping.
2 and 3 Mbps for EDR, which can be found in the advertisements and on the Bluetooth website, are the maximum channel transmission rate of all data in total (including technical headers for all protocols in which they must be encapsulate the data) in two directions simultaneously. Actual data transfer rates will vary greatly.
To transfer music, an asynchronous method is used, almost always with the help of packets of the type 2-DH5 and 3-DH5, which carry the maximum amount of data in EDR mode of 2 Mbps and 3 Mbps, respectively, and occupy 5 time division slots.
Schematic representation of a transmission with 5 slots for one device and 1 slot for another (DH5 / DH1):
5 слотов на передачу, каждый из которых передаётся 625 микросекунд, и один слот на приём, тоже 625 микукро. В сумме – 3.75 миллисекунды.
Due to the principle of division of air in time, we have to wait a time interval of 625 microseconds after transmitting a packet if the second device does not transmit anything or a small packet, and a longer amount of time if the second device is transmitting in large packets. If more than one device is connected to the phone (for example, headphones, watches, and a fitness bracelet), the transfer time is shared among all.










