History log of /system/bt/stack/a2dp/a2dp_sbc_encoder.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
7fe032bf56bac9adc920dec7ae0755f616c291bd 21-Jul-2017 Pavlin Radoslavov <pavlin@google.com> Revert "Always restrict the AVDTP MTU for SBC codec to MAX_2MBPS_AVDTP_MTU(663)"

This reverts commit 9eee3a772b3f23e5c33845422203f0dec07be234.

Not needed anymore - handled by the interoperability database.

Bug: 62394764
Bug: 34127145
Test: Audio streaming to headset that supports 3Mbps
Change-Id: I143c07c171e0fe9ef882c5e506545187f9e41498
(cherry picked from commit a97b0381c8626320151c246cfd9a71dedcf635ff)
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
c95e5dd827275ca33d84ee8084b8511c0dd9892e 11-May-2017 Pavlin Radoslavov <pavlin@google.com> Removed A2DP_GetTrackBitsPerSample() API because it is not needed

The A2DP_GetTrackBitsPerSample() API was replaced in the past
by A2dpCodecConfig::getAudioBitsPerSample() .
* Removed A2DP_GetTrackBitsPerSample() and related codec-specific APIs:
- A2DP_GetTrackBitsPerSampleSbc
- A2DP_GetTrackBitsPerSampleAac
- A2DP_GetTrackBitsPerSampleAptx
- A2DP_GetTrackBitsPerSampleAptxHd
- A2DP_GetTrackBitsPerSampleLdac
NOTE: The removed A2DP_GetTrackBitsPerSampleLdac implementation
had a bug: a2dp_ldac_caps.bits_per_sample -> ldac_cie.bits_per_sample
This bug itself was uncovered when switching to clang-3960126
- A2DP_VendorGetTrackBitsPerSample()
* Replaced few leftover usages of A2DP_GetTrackBitsPerSample()
A2dpCodecConfig::getAudioBitsPerSample()
* Updated the unit tests

Test: Code compilation, unit tests, A2DP streaming
Bug: 37752547
Change-Id: I7feeda0f32922b8ef888b157673e3e2ade98b179
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
302113d4e44f06e90f90a5903e33ae830edb58a3 07-Apr-2017 Pavlin Radoslavov <pavlin@google.com> Add A2DP codec-specific information to dumpsys output

Now we print the following information:
* Current codec name
* Info for each supported codec:
- Priority
- Encoder interval (ms)
- Codec Config: Sampling rate, Bits per sample, Channel mode (MONO/STEREO)
- Selectable codec configuration
- Codec's local capability
- Packet counts (expected/dropped)
- PCM read counts (expected/actual)
- PCM read bytes (expected/actual)
* LDAC codec-specific info:
- LDAC quality mode: HIGH/MID/LOW/ABR
- LDAC saved transmit queue length [used in ABR mode]
* SBC codec-specific info:
- Frames counts (expected/dropped)

Sample of the new format is below:

---
A2DP Codecs State:
Current Codec: LDAC

A2DP LDAC State:
Priority: 1000000
Encoder interval (ms): 20
Config: Rate=96000 Bits=32 Mode=STEREO
Selectable: Rate=44100|48000|88200|96000 Bits=16|24|32 Mode=MONO|STEREO
Local capability: Rate=44100|48000|88200|96000 Bits=16|24|32 Mode=MONO|STEREO
Packet counts (expected/dropped) : 596 / 161
PCM read counts (expected/actual) : 2488 / 2488
PCM read bytes (expected/actual) : 2547712 / 2547712
LDAC quality mode : ABR
LDAC saved transmit queue length : 0

A2DP aptX-HD State:
Priority: 4001
Encoder interval (ms): 0
Config: Invalid
Selectable: Invalid
Local capability: Rate=44100|48000 Bits=24 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP aptX State:
Priority: 3001
Encoder interval (ms): 0
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100|48000 Bits=16 Mode=STEREO
Local capability: Rate=44100|48000 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP AAC State:
Priority: 2001
Encoder interval (ms): 20
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100|48000 Bits=16 Mode=STEREO
Local capability: Rate=44100|48000|88200|96000 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP SBC State:
Priority: 1001
Encoder interval (ms): 20
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100 Bits=16 Mode=STEREO
Local capability: Rate=44100 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 580 / 0
PCM read counts (expected/actual) : 2900 / 2900
PCM read bytes (expected/actual) : 1484800 / 1484800
Frames counts (expected/dropped) : 3724 / 0
---

Bug: 36567128
Test: Stream A2DP and "adb shell dumpsys bluetooth_manager"
Change-Id: Idd86005b842a4e569b7df91b8bbaf0632ed7f7c9
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
9eee3a772b3f23e5c33845422203f0dec07be234 01-Mar-2017 Pavlin Radoslavov <pavlin@google.com> Always restrict the AVDTP MTU for SBC codec to MAX_2MBPS_AVDTP_MTU(663)

Some devices claim they can handle large MTU and large SBC bitpool.
However, they are struggling and eventually over time they
start delaying the "Rcvd Number of Completed Packets" reports.
Now we always limit the payload MTU to MAX_2MBPS_AVDTP_MTU(663) -
with the overhead of (4 bytes L2CAP Header + 12 bytes AVDTP Header)
such packet can fit within 2-DH5 payload size of 679 bytes.

Bug: 34127145
Test: A2DP SBC streaming to headsets and carkit
Change-Id: I2f32becba703d77d36be46158f68b8a9ef3f299a
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
39bbfab26d69fe373b3e11843d1157249db86d09 14-Jan-2017 Pavlin Radoslavov <pavlin@google.com> Reduced the log verbosity level for aptX/aptX-HD data packets

Also, fixed a typo in a log message.

Test: A2DP streaming to headset, and capturing "adb logcat" output
Change-Id: I525d78e3ebde334857261f0cbd256a7f6a946e96
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
f8e2670d12ee55ec48635ef55a86ecfa643cc761 11-Jan-2017 Pavlin Radoslavov <pavlin@google.com> Removed the feeding_init call from tA2DP_ENCODER_INTERFACE

The feeding_init call is not used anymore - it has been superseded
by the newer A2dpCodecs.setCodecAudioConfig() mechanism.

Also, moved aptx_init_framing_params() and aptx_hd_init_framing_params()
calls to the corresponding encoder_update functions.

Test: A2DP streaming to Bluetooth headsets
Change-Id: I52f42b4701d04fe2ddb8f115bb9cd57fe38e2b38
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
5ce0116fbf5b530d5b93f11312096eade1021c1e 05-Dec-2016 Pavlin Radoslavov <pavlin@google.com> Add a mechanism for configuring the A2DP Source codecs

* Codec config internal abstraction:
- Add new classes A2dpCodecConfig and A2dpCodecs that (will)
encapsulate all codec-related APIs
- Add unit tests for the above two classes
- Add method A2dpCodecConfig.buildCodecConfig(), and use it when
creating the codec configuration instead of A2DP_InitSource2SinkCodec().
The new method can build the codec config by taking into account
optional user codec-related configuration preferences.
- Use the A2DP codec config API from the hardware/libhardware bt_av.h API
- Replace enum tA2DP_CODEC_SEP_INDEX with btav_a2dp_codec_index_t
from the bt_av.h API
- Move codec-specific functions from stack/include/a2dp_api.h
and stack/a2dp/a2dp_api.cc to stack/include/a2dp_codec_api.h
and stack/a2dp/a2dp_codec_config.cc
- Create a new base class A2dpCodecConfig() to hold some of the
codec-related state, and implement the corresponding A2dpCodecConfigSbc
and A2dpCodecConfigSbcSink derived classes.
- Move A2DP spec-related constants from stack/include/a2dp_api.h
to stack/include/a2dp_constants.h
- Move A2DP-related error codes from stack/include/a2dp_api.h
to stack/include/a2dp_error_codes.h
- Move A2DP SBC spec-related constants from stack/include/a2dp_sbc.h to
stack/include/a2dp_sbc_constants.h

* Implement the backend mechanism for handling user (re)configuration of
A2DP Source codecs as requested via the JNI API calls.
Also, any codec changes are reported back via JNI API callbacks.
The current audio parameter selection (sample rate, bits per
sample, channel mode - mono/stereo) is as follows:
- If the user selected parameters are acceptable (based on
local codec capability and the remote Sink capability),
those parameters are used.
- Else if the Audio HAL's requested parameters are acceptable,
those are used.
- Else if the default settings are acceptable, those are used.
- Else use the best match among the local and the remote device's
capabilities.

* Update the mechanism for handling OTA configuration requests from the
remote Sink device.
- The OTA prefered codec configuration is ignored if the current
codec configuration contains explicit user configuration, or if the
codec configuration for the same codec contains explicit user
configuration.

* Refactor the Audio HAL <-> Bluetooth audio parameter negotiation
mechanism:
The new mechanism gives some flexibility to the Media Framework to
choose the appropriate audio format (sample rate, bits per sample,
and channel mode - mono/stereo), and at the same time allows
the Bluetooth stack to double-check / overwrite the choice.
- out_get_parameters() on the Audio HAL side asks the Bluetooth stack
for all currently supported formats (for the current codec),
and returns them to the Media Framework: sample rate, bits per sample,
and channel mode (mono/stereo).
- The first time adev_open_output_stream() is called on the Audio HAL,
it asks the Bluetooth stack about the audio format currently selected
by the Bluetooth stack (based on codec negotiation with the Sink device,
and User Configuration).
- The second time adev_open_output_stream() is called on the Audio HAL,
its "config" will eventually contain the audio format selected
internally by the Media Framework. That audio format is sent to the
Bluetooth stack.
If that format is acceptable to the Bluetooth stack, the Bluetooth
stack will reconfigure itself internally, and will respond back with
those values. Otherwise, it will respond back with the values that
should be used instead.

* Misc other fixes and refactoring:
- Fix the BTA handling of A2DP codec reconfiguration
- Fix a bug in the implementation of A2DP_BitsSet(), and add the
approriate unit test. Also, fix the code that was using this function
incorrectly.
- The SBC encoder is compiled as a separate library
- Replace leftover usage of "false" with "FALSE" for macros, and
vice-versa for variable values.

Test: A2DP streaming to headsets, TestPlans/71390
Bug: 30958229
Change-Id: I440b6126e2250e33b0075f9789dd93154c007c2b
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
4ebaa86a3ab1ea390d238e1f6dee62cd837c60ed 22-Nov-2016 Pavlin Radoslavov <pavlin@google.com> Add a mechanism for Audio Feeding Parameters negotiation

Previously, the Audio Feeding Parameters between the Media Framework
and A2DP were hard-coded: 44.1 KHz sample rate, 16-bits per sample, Stereo.
Now the Media Framework queries A2DP, and uses the returned values.

Bug: b/30958229
Test: Manual testing: A2DP streaming to headphones. TestTracker/68727
Change-Id: I70b90d2961ceb9efcd7021d2e12c240fe531ee1c
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
cd02ce9c60da962a7981320b26aada8744718941 05-Nov-2016 Pavlin Radoslavov <pavlin@google.com> A2DP Codec related cleanup

* Add new A2DP API and the corresponding unit tests:
- A2DP_InitSource2SinkCodec()
- A2DP_SourceCodecSepIndex()
- A2DP_GetTrackBitsPerSample()
* Use the new API to simplify the codec selection and setup
* Rename A2DP_BldSbcMplHdr() to A2DP_BuildMediaPayloadHeaderSbc()
* Remove the following APIs, because they are not needed anymore:
- A2DP_BuildSinkConfig()
- A2DP_CodecConfigMatchesCapabilities()
- A2DP_SetSourceCodec()
- A2DP_CodecRequiresReconfig()
- A2DP_IsSourceCodecSupported()
* Remove the following generic APIs, and keep only the SBC-specific APIs.
The information returned by those functions is SBC-specific, and doesn't
apply to other codecs:
- A2DP_GetNumberOfSubbands()
- A2DP_GetNumberOfBlocks()
- A2DP_GetAllocationMethodCode()
- A2DP_GetChannelModeCode()
- A2DP_GetSamplingFrequencyCode()
- A2DP_GetMinBitpool()
- A2DP_GetMaxBitpool()
* Rename:
A2DP_GetTrackFrequency() -> A2DP_GetTrackSampleRate()
tA2DP_FEEDING_PARAMS.sampling_freq -> sample_rate
tA2DP_FEEDING_PARAMS.num_channel -> channel_count
tA2DP_FEEDING_PARAMS.bit_per_sample -> bits_per_sample
* Remove btif_a2dp_source_encoder_update(), tA2DP_ENCODER_UPDATE_PARAMS
and associated events and processing mechanism, because they are not
needed anymore.
* Remove tA2DP_ENCODER_INTERFACE.encoder_update, because it is not
used anymore.
Now it is superceded by tA2DP_ENCODER_INTERFACE.encoder_init.
* Fix a bug inside bta_av_api_register() when initializing
the stream control block.
* Refactor bta_av_co_audio_getconfig() and bta_av_co_audio_setconfig()
* Remove tBTA_AV_CO_CB.codec_config_setconfig field, because it is not
needed anymore.
* Remove unused arguments when opening/closing audio stream
* Remove #ifdef BTA_AV_DEBUG guards: BTA_AV_DEBUG is always TRUE
* Remove SBC Mono -> Stereo hack

Test: Manual testing: A2DP streaming to headphones. TestTracker/68727
Change-Id: Ie0b209f7ad6c21c2c6d8d2e6277b86dfa63388c6
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
feee26c3dae12b53773b31f57cf2533a3d993979 25-Oct-2016 Pavlin Radoslavov <pavlin@google.com> A2DP codec related fixes and cleanup

* Update bta_av_co_audio_getconfig() to select the preferred codec
* Fix a bug in selecting the A2DP codec inside
bta_av_co_audio_set_codec()
* No need for function A2DP_ParsSbcMplHdr() to be exposed in the API
* Generalize the following APIs, so they can be used to redirect
the call for vendor-specific codecs:
- A2DP_CodecSepIndexStr()
- A2DP_InitCodecConfig()
- A2DP_SetSourceCodec()
* Change tA2DP_ENCODER_INIT_PARAMS.SamplingFreq from uint16_t to
uint32_t so it can store larger sampling frequency.
* Rename content protection constants from BTA_AV_CP_*
to AVDT_CP_* and move them from bta_av_co.h to avdt_api.h
* Rename some of the internal functions in a2dp_sbc.cc
* Add extra debug logging and fix some comments

Test: A2DP streaming, unit tests passing
Change-Id: I1b67ff18dc568dd859429fcd89c644799fb1438d
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
26f21028e2c8538d166a9005dd6d30831059ea05 25-Oct-2016 Jakub Pawlowski <jpawlowski@google.com> Simplify SBC encoder API

Currently it is unclear what the input, output, and configuration of
the SBC codec are. This patch refactors the use of the SBC_Encoder
function. Parameters for input and output are added, instead of passing
them in alongside the configuration.

Test: Tested A2DP playback
Change-Id: I755a022983f823475c14815cc0610f90a5fbc813
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
4d237f22c0921d2746f427fb7006982676f52f05 18-Oct-2016 Jakub Pawlowski <jpawlowski@google.com> Linux build fix

Test: compile using ninja
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
397e5a5d6a6e14779af8431734ff605ccc49b2a7 15-Oct-2016 Pavlin Radoslavov <pavlin@google.com> Format A2DP-related code with clang-format

clang-format -style=file -i stack/a2dp/a2dp_* stack/include/a2dp_* \
btif/include/btif_a2dp* btif/src/btif_a2dp*

Test: top-level compilation and running A2DP
Change-Id: I66f0a047192b783ac0147def480754daf617dd8d
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc
f66f4e95f2b4bc8d36033f2d65b387e32601fcd8 15-Oct-2016 Pavlin Radoslavov <pavlin@google.com> A2DP-related renaming: a2d_* to a2dp_*

Test: top-level compilation and running A2DP

Change-Id: Ibbd3176b86667885666bfe29025ec2c120fafce6
/system/bt/stack/a2dp/a2dp_sbc_encoder.cc