[pulseaudio-discuss] [PATCH v8 00/12] New API for Bluetooth A2DP codecs
Pali Rohár
pali.rohar at gmail.com
Sat Apr 6 09:15:55 UTC 2019
This is 8th version of my patch series for modular A2DP codec API and
aptX support. This version address review comments by Tanu.
This patch series provides new modular API for Bluetooth A2DP codecs,
clean up module-bluez5-device and bluez5-util to be codec independent
and convert SBC codec into this new API for A2DP codecs. Also it adds
support for aptX, aptX HD and FastStream A2DP codecs.
New codec API is designed in way, that for adding new codec is not
needed to touch bluez5-util nor module-bluez5-device files. Whole
codec registration is done in a2dp-codec-util.c file, without need
to update any header file.
Some A2DP codecs are bidirectional and support backchannel for
microphone voice. This new A2DP codec API fully supports this feature
and module-bluez5-device was extended to support microphone voice source
for codecs which declares such support. FastStream is example of such
codec.
For every A2DP codec is created card profile. When using bluez from
current git master then only those profiles codec profiles are created
which are supported by remote headset/endpoint.
With this new modular API it should be easy to add other codec support
like MP3, AAC or LDAC.
API is designed also for ability to register "more variants" of one
A2DP codec. This is used by SBC codec. It exports 5 different variants:
Low Quality, Medium Quality, High Quality, Ultra High Quality and
Automatic Quality. Also if remote device exports more endpoints for SBC
codec with different quality, pulseaudio SBC code properly find and use
endpoint which matches defined quality.
I tested playback with SBC, aptX and FastStream codecs, including
switching between them while playing music and it is working fine. When
switching codec there is some 1-2s quiet window. Also microphone voice
in FastStream is working and has slightly better quality as in HSP profile.
Changes in v8:
* Address Tanu's review comments
* Dropped patch: switch-on-port-available: Fix null pointer dereference
* Renamed lot of API functions and members:
- codec_name --> name
- codec_description --> description
- codec_id --> id
- codec_init --> init
- codec_finish --> deinit
- codec_reset --> reset
- accept_capabilities --> can_accept_capabilities
- choose_capabilities --> choose_remote_endpoint
- validate_configuration --> is_configuration_valid
- bitpool --> initial_bitpool
* New macro MAX_A2DP_CAPS_SIZE
* Fixed a2dp_prepare_encoder_buffer and a2dp_prepare_decoder_buffer
* Fixed usage and return value of decode_buffer
* Fixed setting read_block_size
* Fixed enumeration of remote endpoints when remote device supports
both sink and source
* Fixed commit message of sbc endianty patch
Changes in v7:
* Split patch "Modular API for A2DP codecs" into two parts:
- 4/13: Implementation of codec API (without exporting new profiles)
- 12/13: Implementation of codec switching via bluez; exporting profile per codec
* Fixed A2DP SBC endianity in SBC and FastStream codecs for bigendian hosts
* Fixed checks for SetConfiguration call
* Fixed checks for transport_config
Changes in v6:
* Change A2DP profile immediately and remove -EAGAIN problem,
this fixes the last problem with switching from one A2DP codec
profile to another, now it is fully transparent
* Add more variants of SBC codec, including SBC Ultra High Quality which
beats aptX and should be supported by most bluetooth headsets
* Update module-bluetooth-policy code to prefer using bi-directional
A2DP profiles for VOIP applications as it has better VOIP quality as
HSP/HFP profiles
* Add missing validations for SBC codec parameters
* Clean up SBC bitpool calculation
* Fixed debug usage of sbc_get_implementation_info()
* Update a2dp-codecs.h from upstream bluez project again
* Use bluez's "Device" key for determining device path for SEP endpoint
(instead of guessing it directly from SEP endpoint string)
* Simplify aptX and aptX HD code as they share lot of common parts
* Fix assigning sink/sources into port profiles
* Remove a2dp_sink_codecs/a2dp_source_codecs hashmaps to simplify code
* Fix announcing transport availability when bluez supports codec changing
* Fix switching A2DP codec when bluez removed/re-added remote endpoints
Changes in v5:
* Added support for switching between A2DP codec via profiles.
This requires bluez patches from above link.
Changes in v4:
* Added support for aptX HD codec
* Changed codec API for reading block size and reducing encoder bitrate
* Added support for microphone backchannel into module-bluez5-device
* Added support for microphone backchannel into FastStream codec
* Fixed parsing FastStream A2DP config buffer
* Fixed validation for config buffers
* Fixed calculating block size for aptX codec
* Fixed resetting SBC and FastStream codecs
Changes in v3:
* Fixed problems pointed by Tanu
Pali Rohár (12):
bluetooth: policy: Remove BlueZ 4 related code
bluetooth: Update a2dp-codecs.h from upstream bluez project
bluetooth: Modular API for A2DP codecs
bluetooth: Add missing validations for SBC codec parameters
bluetooth: Clean up SBC bitpool calculation
bluetooth: Set correct endianity of audio samples for SBC codec
bluetooth: Add A2DP aptX and aptX HD codecs support
bluetooth: Add A2DP FastStream codec support
bluetooth: Add more variants of SBC codec
bluetooth: policy: Reflect a2dp profile names
bluetooth: Implement A2DP codec switching and backchannel support
bluetooth: policy: Treat bi-directional A2DP profiles as suitable for
VOIP
configure.ac | 36 +
src/Makefile.am | 20 +-
src/modules/bluetooth/a2dp-codec-api.h | 95 ++
src/modules/bluetooth/a2dp-codec-aptx.c | 445 ++++++++++
src/modules/bluetooth/a2dp-codec-faststream.c | 436 ++++++++++
src/modules/bluetooth/a2dp-codec-sbc.c | 1065 +++++++++++++++++++++++
src/modules/bluetooth/a2dp-codec-util.c | 78 ++
src/modules/bluetooth/a2dp-codec-util.h | 34 +
src/modules/bluetooth/a2dp-codecs.h | 336 ++++++-
src/modules/bluetooth/bluez5-util.c | 774 ++++++++++------
src/modules/bluetooth/bluez5-util.h | 39 +-
src/modules/bluetooth/module-bluetooth-policy.c | 117 +--
src/modules/bluetooth/module-bluez5-device.c | 902 +++++++++----------
13 files changed, 3590 insertions(+), 787 deletions(-)
create mode 100644 src/modules/bluetooth/a2dp-codec-api.h
create mode 100644 src/modules/bluetooth/a2dp-codec-aptx.c
create mode 100644 src/modules/bluetooth/a2dp-codec-faststream.c
create mode 100644 src/modules/bluetooth/a2dp-codec-sbc.c
create mode 100644 src/modules/bluetooth/a2dp-codec-util.c
create mode 100644 src/modules/bluetooth/a2dp-codec-util.h
--
2.11.0
More information about the pulseaudio-discuss
mailing list