History log of /system/bt/btif/src/btif_a2dp_control.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
dd8dfc4ec5c93fe779141e7e7e8857552299c7e6 20-Sep-2017 Pavlin Radoslavov <pavlin@google.com> Enable extra A2DP control log messages

Also, fixed a log message when failed to accept the
corresponding socket socket.

Test: manual
Bug: 63949429
Change-Id: I6d9af32f61974a739d179c37da36c360aefcca79
(cherry picked from commit 7b67302a28019468ae6df9cdb7f9085c6579b859)
/system/bt/btif/src/btif_a2dp_control.cc
304ceeb5202060a9c625a55369cbf28d72f5e2d9 06-Apr-2017 Pavlin Radoslavov <pavlin@google.com> Create unit test framework for audio_a2dp_hw

Create unit test framework for audio_a2dp_hw and implement a unit test
for function audio_a2dp_hw_stream_compute_buffer_size()

Also:
* Remove obsolete check for mixer unit size inside out_get_buffer_size()
* Reorganize the file structure inside directory audio_a2dp_hw/ :
- Moved the source code files *.cc to audio_a2dp_hw/src/
- Moved the header file(s) *.h to audio_a2dp_hw/include/
- The unit test file(s) are stored in audio_a2dp_hw/test/

Bug: 35849921
Test: This is the unit test. Code compilation and unit test succeed
Change-Id: I3dcc508cb6799462b7103cb2ee452b4399843899
/system/bt/btif/src/btif_a2dp_control.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/btif/src/btif_a2dp_control.cc
f2af1c42ccb2f642b241c2261b42d0be61d45438 13-Dec-2016 Jack He <siyuanh@google.com> Replace assert with CHECK from base/logging.h

* Replace assert with CHECK
* Remove all NDEBUG definitions
* Remove hacks for BT_LIBCHROME_NDEBUG
* Removed some removed directories from Makefile such as hcis, brcm, rpc

Coccinelle-assisted:

@@
@@

- #include "base/logging.h"
+ #include <base/logging.h>

@ assert_included @
@@

@ base_logging_included @
@@

@ depends on (assert_included && !(base_logging_included)) @
@@

- #include <assert.h>
+ #include <base/logging.h>

@ depends on (assert_included && base_logging_included) @
@@

- #include <assert.h>

@@
expression E;
@@

- assert(E);
+ CHECK(E);

And a bash script:

for file in $(find . -name "*.cc"); do
spatch --sp-file replace_assert_with_CHECK.cocci --in-place $file
done

The following files are maually edited:
btif/src/btif_config.cc
btif/src/btif_avrcp_audio_track.cc
btif/src/btif_gatt_client.cc
osi/src/data_dispatcher.cc
osi/src/reactor.cc
osi/src/thread.cc
osi/src/fixed_queue.cc
osi/src/list.cc
osi/src/allocation_tracker.cc
osi/src/alarm.cc
osi/test/wakelock_test.cc

Bug: 31781465
Test: Code compilation, Unit Tests, BtStressTest, BtFunhausMetricsTest
Change-Id: I21dc10a45be31665e41441b75b0515ed87523988
/system/bt/btif/src/btif_a2dp_control.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/btif/src/btif_a2dp_control.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/btif/src/btif_a2dp_control.cc
d7ffd64accbd50a27289a388856e56244ccbb5da 27-Oct-2016 Myles Watson <mylesgw@google.com> Remove deprecated UNUSED macro (5/5)

Include osi.h for UNUSED_ATTR.

Test: mma -j32

Change-Id: I43260669dc1f54639e46cc9620093d727ee86276
/system/bt/btif/src/btif_a2dp_control.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/btif/src/btif_a2dp_control.cc
1394c197027c0907932a814a786cc033870eb1c9 03-Oct-2016 Pavlin Radoslavov <pavlin@google.com> BTIF A2DP Source and Sink refactor and cleanup

* Moved bta/av/bta_av_sbc.c to stack/a2dp/a2d_sbc_up_sample.c
and renamed the corresponding bta_av_sbc_up_sample_* functions to
a2d_sbc_up_sample_*
Also, renamed bta_av_sbc_init_up_sample() to a2d_sbc_init_up_sample()
* Moved A2DP SBC Encoder-related tasks, state and constants from
btif_a2dp_source.cc to a2d_sbc_encoder.c
* Introduced A2DP encoder callbacks interface tA2D_ENCODER_INTERFACE,
and added A2D_GetEncoderInterface() to acccess the interface for a codec.
* Updated a2d_sbc_encoder_init() to specify callbacks:
- a2d_source_read_callback_t - a callback to read audio data for encoding
- a2d_source_enqueue_callback_t - a callback to enqueue A2DP source
packets for transmission
* Removed BTIF_MEDIA_TRSCD_* - the encoding is always PCM
* Removed conditionally defined constants and replaced them by
local definitions:
- BTIF_MEDIA_BITRATE_STEP -> A2D_SBC_BITRATE_STEP
- BTIF_A2DP_DEFAULT_BITRATE -> A2D_SBC_DEFAULT_BITRATE
- BTIF_A2DP_NON_EDR_MAX_RATE -> A2D_SBC_NON_EDR_MAX_RATE
* Hard-coded the read data timeout period A2DP_DATA_READ_POLL_MS to 10ms
* Merged the UNDERRUN read errors into the UNDERFLOW errors.
* Removed the following statistics, because they are not very useful:
- media_read_total_limited_frames
- media_read_max_limited_frames
- media_read_limited_count
- media_read_total_expected_frames
- media_read_max_expected_frames
- media_read_expected_count
* Updated the implementation of buffer_overruns_max_count to
use the (new) counter tx_queue_max_dropped_messages instead of
media_read_max_expected_frames
* Replaced usage of LOG_DEBUG() in stack/a2d/ with LOG_VERBOSE():
the former is enabled by default on some of the builds.
* Renamed:
- btif_a2dp_sink_audio_focus_state_t -> btif_a2dp_sink_focus_state_t
- btif_a2dp_sink_set_audio_focus_state_req() ->
btif_a2dp_sink_set_focus_state_req()
- tBTIF_A2DP_SINK_CB.RxSbcQ -> rx_audio_queue
- btif_a2dp_source_start_aa_req() -> btif_a2dp_source_start_audio_req()
- btif_a2dp_source_stop_aa_req() -> btif_a2dp_source_stop_audio_req()
- btif_a2dp_source_aa_readbuf() -> btif_a2dp_source_audio_readbuf()
- tBTIF_A2DP_SOURCE_CB.TxAaQ -> tx_audio_queue
- BTIF_A2DP_SOURCE_MEDIA_TIMER_MS -> A2D_SBC_ENCODER_INTERVAL_MS
- tA2D_AV_MEDIA_FEEDINGS -> tA2D_FEEDING_PARAMS
- tBTIF_A2DP_SOURCE_INIT_AUDIO -> tA2D_ENCODER_INIT_PARAMS
- tBTIF_A2DP_SOURCE_UPDATE_AUDIO -> tA2D_ENCODER_UPDATE_PARAMS
- tBTIF_A2DP_SOURCE_INIT_AUDIO_FEEDING -> tBTIF_A2DP_SOURCE_INIT_FEEDING

Bug: 30958229
Test: TestTracker/65192
Change-Id: Iba0a9694bda3dba73f211f1bde25821497fa6a06
/system/bt/btif/src/btif_a2dp_control.cc
08406e93e6027082f8102df21f7e59f27c502c18 24-Sep-2016 Pavlin Radoslavov <pavlin@google.com> Split btif_media_task into Source, Sink and Control

* btif/include/btif_a2dp.h and btif/src/btif_a2dp.cc implement
the entry points for the BTIF A2DP module.

* btif/include/btif_a2dp_source.h and btif/src/btif_a2dp_source.cc implement
the BTIF A2DP Source component.

* btif/include/btif_a2dp_sink.h and btif/src/btif_a2dp_sink.cc implement
the BTIF A2DP Sink component.

* btif/include/btif_a2dp_control.h and btif/src/btif_a2dp_control.cc
implement the A2DP control mechanism for the audio channel from the
Media Framework.

Also:
* Removed BTA_AV_SBC_HDR_SIZE and used A2D_SBC_MPL_HDR_LEN instead.
* Removed BTIF_AV_SINK_FOCUS_REQ_EVT, because it is not used.
* Removed many of the "#if (BTA_AV_SINK_INCLUDED == TRUE)" guards.
* Removed "#ifdef USE_AUDIO_TRACK" guard, and always compile the
corresponding code.
* Removed tBTIF_AV_MEDIA_FEEDINGS_PCM_STATE and moved its state
to tBTIF_AV_MEDIA_FEEDINGS_STATE .

Bug: 30958229
Test: TestTracker/65192
Change-Id: I20bc52a1d7a7f03c92628a1562f14b7df3ebb445
/system/bt/btif/src/btif_a2dp_control.cc