History log of /system/bt/btif/src/btif_av.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
0035d8c9a8b50456f72874174857950df0ecfc67 03-May-2017 Philip Cuadra <philipcuadra@google.com> Revert "Revert "Make Bluetooth audio threads use RT scheduling""

This reverts commit feb2d84f4b69392b5f37ae1ec9d53ac728514275.

Bluetooth threads that are used in audio have deadline
requirements for glitchless playback. Those threads need to be
scheduled as RT tasks to ensure that they can meet the deadline even if
there is high system load.

Bug 37518404

Test: play Bluetooth audio, check for RT with systrace
(cherry picked from commit 96c42e70f5c6a74a737739aa9c297cd93540f43e)
/system/bt/btif/src/btif_av.cc
feb2d84f4b69392b5f37ae1ec9d53ac728514275 28-Apr-2017 Philip Cuadra <philipcuadra@google.com> Revert "Make Bluetooth audio threads use RT scheduling"

This reverts commit eaa42774f393eb3ccaee91a958e8df6a8fb09b91.

http://b/37733903
Test: confirmed switching users does not hang.

Change-Id: Ic54e4ed2dda057e681df225a37a574c221cd8fc3
/system/bt/btif/src/btif_av.cc
eaa42774f393eb3ccaee91a958e8df6a8fb09b91 23-Mar-2017 Philip Cuadra <philipcuadra@google.com> Make Bluetooth audio threads use RT scheduling

Bluetooth threads that are used in audio have deadline
requirements for glitchless playback. Those threads need to be
scheduled as RT tasks to ensure that they can meet the deadline even if
there is high system load.

Bug 37518404

Test: play Bluetooth audio, check for RT with systrace
Merged-In: I4505fbce55e5a4fe18d00dbda23646a60e482efd
Change-Id: I4505fbce55e5a4fe18d00dbda23646a60e482efd
(cherry picked from commit 96c42e70f5c6a74a737739aa9c297cd93540f43e)
/system/bt/btif/src/btif_av.cc
bdd34d216ae65e3d5e57457bb31a8e0b9ff3c31a 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
(cherry picked from commit 304ceeb5202060a9c625a55369cbf28d72f5e2d9)
/system/bt/btif/src/btif_av.cc
c338fe868cc78fca87d3827b568b0a997f575642 01-Feb-2017 Marie Janssen <jamuraa@google.com> btif: remove logspam at higher debug levels

Some CHECK macros had logs that printed the function name, which
duplicated the logs in the functions outside the checks, producing too
many logs.

Remove some unused macros.

Changes:
02-01 09:34:11.757 1259 1755 D bt_btif : get_folder_items_list_rsp
02-01 09:34:11.757 1259 1755 D bt_btif : get_folder_items_list_rsp: item_cnt: 0 len: 0
to
02-01 09:34:11.757 1259 1755 D bt_btif : get_folder_items_list_rsp: item_cnt: 0 len: 0

and similar.

Test: run logcat, check that we have less duplicated logs
Change-Id: Id6e57f38b34d176ed8be0c3baedfbcf55e61a9a4
/system/bt/btif/src/btif_av.cc
a6ba5aca4e8c1a200b8cc29fb60d390a7196416a 01-Feb-2017 Pavlin Radoslavov <pavlin@google.com> Add a mechanism to configure the default A2DP codec priorities

Previously, the relative codec priorities were hard-codec internally.
The new mechanism uses the following configurable resources in
packages/apps/Bluetooth/res/values/config.xml to re-assign the
default codec priorities per device, or to explicitly disable a codec.

- a2dp_source_codec_priority_sbc
- a2dp_source_codec_priority_aac
- a2dp_source_codec_priority_aptx
- a2dp_source_codec_priority_aptx_hd
- a2dp_source_codec_priority_ldac

Those values are assigned on startup.
Also, they can be changed per device by using an overlay:
device/<VENDOR>/<DEVICE>/overlay/packages/apps/Bluetooth/res/values/config.xml

Test: Manually streaming to a headset
Change-Id: I5312299aea4a11c92fbe999d521adb39346b9866
/system/bt/btif/src/btif_av.cc
494e53e904e8aecc28178fda5856071776b2caf0 26-Jan-2017 Pavlin Radoslavov <pavlin@google.com> Update the A2DP Codec Config API

Previously, the JNI upcall would contain only the current codec config.
In the new API, the upcall contains:
1. The current codec config
2. The list of codecs containing the local codecs capabilities
3. The list of codecs containing the selectable codecs capabilities.
This list is the intersection of the local codecs capabilities
and the capabilities of the paired device.

Also, updated the codec backend to accomodate the above changes:
* Update all selectable codecs inside bta_av_co_audio_set_codec()
* Changed getCodecConfigAndCapabilities() to return current codec
config, local codecs capabilities, and selectable codecs capabilities.
* Updated each codec to compute and store a copy of the selectable
capabilities, and the local capabilities.
* Updated tA2DP_SBC_CIE to include new field bits_per_sample
(for consistency with the rest of the codecs).
* Replaced usage of codec_priority of 0 with BTAV_A2DP_CODEC_PRIORITY_DEFAULT
* If there is user codec (re)config call, we always send an upcall
to inform the Java layer about the most recent codec info.
Thus, the caller would always know whether the request succeeded or failed.

Test: A2DP streaming with headsets and switching the codecs
Change-Id: Ie7a5cd5c2ab01bb8676032be05bc2ad03baa1e3f
/system/bt/btif/src/btif_av.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_av.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_av.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_av.cc
ee96a3c60fca590d38025925c072d264e06493c4 23-Nov-2016 Myles Watson <mylesgw@google.com> Fix asterisks in block quotes

Remove double asterisks from block quotes.

git grep -lP '^[*][*]' | xargs sed 's/^[*][*]/ \*/' -i

Fix asterisk line lengths

git grep -l '^[ /][*]\{79,\}[*/]' | \
xargs sed -i s,"^\([ /]\)[*]\([*]\{78\}\)[*]*\([*/]\)","\1\2\3",

Test: mma -j32
Change-Id: Ie3fd375ac2f804cb0f53bf1314a005e85973b3d7
/system/bt/btif/src/btif_av.cc
9008888d24407541aa383aa4bd363a40abbf954b 16-Nov-2016 Myles Watson <mylesgw@google.com> Fix formatting after removing defines

clang-format -i --style=file bta/*/* btif/*/* include/*

Test: mma -j32
Change-Id: I9ebb32f0cc5bd24a7cb2ae25699999aab5036b13
/system/bt/btif/src/btif_av.cc
681a3965154fc1eeb0c23d3a968524239f94c563 09-Nov-2016 Ajay Panicker <apanicke@google.com> Move callback to dispatch thread

Change the thread that the timeout posts a connection request event to
so that the state machine handles calling the callback on the correct
thread to prevent a JNI crash.

Bug: 32754737
Test: Manually paired a device that normally crashes phone
Change-Id: I2c3384feaa404cc583e81b2df994b7cbd079d25d
/system/bt/btif/src/btif_av.cc
583b817eda2dd638a5d14c5af2c77a850a796049 06-Dec-2013 Ayan Ghosh <abghosh@codeaurora.org> Restart sniff timer on AVDTP signalling channel establishment

VolksWagan UHV Preminum takes time to initiate AVDTP media channel
after AVDTP signalling channel is up. If mentioned duration exceeds
7 seconds then ACL link goes into sniff due to which A2dp Connection
fails.

With this change we make sure that when AVDTP signalling channel
is up and media channel is not connected we do not go to sniff,
which is achieved by restarting sniff timer on signalling channel up
so that link does not go to sniff in between ongoing connection.

Change-Id: Ic3f268703067155ffd55a43f320ce199641c6b3f
/system/bt/btif/src/btif_av.cc
98397944b8ed1ccfe808c9442e5258dd30e086c6 20-Jul-2016 Ting Zheng <ting.zheng@mediatek.com> bt address memory copy error in btif_av_state_opening_handler()

[Problem]
In btif_av_state_opening_handler() BTIF_AV_CONNECT_REQ_EVT
handling, it reported the wrong bt address. It happened when remote speaker
connected back and local also tried to initiate the connection almost at the
same time, so that A2dpStateMachine recognized mTargetDevice and mIncomingDevice
as two different deivices. When it was final connected, A2dpStateMachine ignored
the connected event as "ERROR: current, target, or mIncomingDevice not null in
Disconnected".

[Solution]
Modify (bt_bdaddr_t*)p_data to ((btif_av_connect_req_t *)p_data)->target_bda in
btif_av_state_opening_handler() BTIF_AV_CONNECT_REQ_EVT handling. In previous
design, it would copy the address of target_bda and uuid in
btif_av_connect_req_t rather than the real address pointed by target_bda.

Change-Id: Icbc5150016d6f75aa314b5d9e152a2de74f0cfbe
Signed-off-by: Ting Zheng <ting.zheng@mediatek.com>
/system/bt/btif/src/btif_av.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_av.cc
40cde56d28ab9751ba76bded0b7ac5974c750a97 21-Oct-2016 Myles Watson <mylesgw@google.com> btif: Add do-while blocks to macros

Test: mma -j32
Change-Id: Ie82465b8cef6c4f527fad13892abb365e15dad7c
/system/bt/btif/src/btif_av.cc
f45481678af0694902b5200ba69ced4cb61d73f0 19-Oct-2016 Myles Watson <mylesgw@google.com> btif: Fixup clang-format

In src/btif_sock_l2cap.cc:
Move a comment before the define and run clang-format again.

Fix formatting in comments that were more than 80-characters wide.

Test: mma -j32
Change-Id: I17465a1425d1de9a28f0675fe65c8529359a87af
/system/bt/btif/src/btif_av.cc
6bd442f543972b072ef2cbbcf2f7c91202de1045 19-Oct-2016 Myles Watson <mylesgw@google.com> btif: Apply clang-format

clang-format doesn't understand block quotes of this form:

/* This is not handled well
** because there are two asterisks
**/

cd btif/

# Replace '**' at the beginning of the line with ' *'

sed 's/^[*][*]/ \*/' -i include/* src/* test/* co/*
clang-format --style=file -i src/* include/* test/* co/*

Test: mma -j32
Change-Id: I2477eae5480602d5b2fee5ec89c9ed7888022341
/system/bt/btif/src/btif_av.cc
e7bd8905653ec2af14ae202f538ebc2646752ce0 11-May-2016 Sanket Agarwal <sanketa@google.com> Implement AVRCP Controller (Client) Browsing.

Following is included as part of the features:
a) Browsing for all 4 scopes (Media, VFS, Player and Now Playing)
b) Player selection and song selection from browse list.

The change constructs the following (from lower to upper protocol
layers):
1. AVCTP Browse (bta/ & stack/)
-- Connection Handling
-- Constructing browse commands
-- Parsing browse responses
2. AVRCP (btif/)
-- JNI interaction/API
-- Connection handling to Java
-- Delegating request and responses to Java

Bug: 28791287
Change-Id: Ibc97ded93cb9c469778ea1e37733390d561cd4cd
(cherry picked from commit 9ea8d07c9286a1f4d338dd64ee02266e324d28e5)
/system/bt/btif/src/btif_av.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/btif/src/btif_av.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_av.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_av.cc
d7ff47cc64838ecd9d5a8366b75815aab97b6f7d 08-Sep-2016 Pavlin Radoslavov <pavlin@google.com> A2DP related API update and cleanup

* Added new A2DP API and use it as appropriate
- A2D_GetTrackFrequency()
- A2D_GetTrackChannelCount()
- A2D_GetNumberOfSubbands()
- A2D_GetNumberOfBlocks()
- A2D_GetAllocationMethodCode()
- A2D_GetChannelModeCode()
- A2D_GetSamplingFrequencyCode()
- A2D_GetSinkTrackChannelType()
- A2D_GetSinkFramesCountToProcess()

* Added corresponding unit tests for the new API

Also, A2DP related cleanup:
- Renamed A2D_sbc_dump_codec_info to A2D_DumpCodecInfoSbc()
- Changed the order of tA2D_SBC_CIE.min_bitpool and
tA2D_SBC_CIE.max_bitpool to reflect the order of the corresponding
fields in the Bluetooth spec (A2DP spec v1.3, page 21).
- Added new API A2D_GetMediaType() and the corresponding unit test
- Renamed AVDT_MEDIA_AUDIO to AVDT_MEDIA_TYPE_AUDIO
- Renamed tA2D_SBC_CIE.alloc_mthd to alloc_method
- Renamed A2D_BAD_ALLOC_MTHD to A2D_BAD_ALLOC_METHOD
- Renamed A2D_NS_ALLOC_MTHD to A2D_NS_ALLOC_METHOD
- Eliminated usage of A2D_MEDIA_TYPE_AUDIO and replace it with
AVDT_MEDIA_TYPE_AUDIO.
Now the media_type value everywhere is the AVDT_MEDIA_TYPE_* value
without the reserved 4 bits (LSBs).
- Fixed macro defines in file "stack/avdt/avdt_defs.h"

Bug: 30958229
Change-Id: Id82653e9c9460aeb92d942a9179bb5abdb4bfdec
/system/bt/btif/src/btif_av.cc
a408eb7227b7060aaa84b2dada7ddd9b6a955761 22-Jun-2016 Avish Shah <avish.shah@broadcom.com> AVRCP 1.6: media browsing support on Target(1/3)

-> As a part of Avrcp 1.6 upgrade, added support
for following features:
[1] setAddressedPlayer
[2] setBrowsedPlayer
[3] getFolderItems scope=VFS/NowPlaying/Search
[4] changePath
[5] getItemAttributes
[6] playItem
[7] getTotalNumberOfItems
[8] search string in current browsed path.
[9] AddToNowPlaying
-> Defined functions and enhanced structures to
support above mentioned features.
-> Added Dual RC support.

Bug: 19361366
Merged-In: I45ed60e337b57c686d9693e19993fee1ce3c2504
Change-Id: I45ed60e337b57c686d9693e19993fee1ce3c2504
/system/bt/btif/src/btif_av.cc
a62c5a302e54568a3d2c164a7dbef52f279512f2 26-Aug-2016 Pavlin Radoslavov <pavlin@google.com> Cleanup and removed BTIF-related unused code

* Removed field tBTIF_MEDIA_CB.av_sm_hdl, because it is never used
after an assignment.
* Removed the corresponding function btif_av_get_sm_handle() which
is not used/needed anymore.
* Declared btif_hf_is_call_idle() function in a new header file
"btif_hf.h"
* Removed tBTIF_STATUS, BTIF_SUCCESS and BTIF_ERROR_SRV_* error codes
which are never used.
* Removed duplicate conditional define of BTA_AV_CO_CP_SCMS_T
* Removed unused typedef tBTA_AV_AUDIO_CODEC_INFO, and unused
BTA_AV_CO_* defines and enums.

Change-Id: I7bb49957fad94073d474fea6ea0d466f36df37fb
/system/bt/btif/src/btif_av.cc
8981fb2f359a89d9d7c8b543c1798b07f8352e07 16-Mar-2016 Pavlin Radoslavov <pavlin@google.com> Free av_open_on_rc_timer on cleanup

Bug: 27602473
Change-Id: I4b0f1563952be75a6dee238607e6674ce98ea623
/system/bt/btif/src/btif_av.cc
4008d1f73a065bf284f3b1866a73d5a55c05ee8e 24-Aug-2016 Pavlin Radoslavov <pavlin@google.com> Don't set the A2DP sink data callback when registering A2DP source

The p_sink_data_cback pointer should be NULL when registering
A2DP source with BTA_AvRegister()

Change-Id: I1a709c4e0d3cfe6faf0368a013b391c6e6a53a82
/system/bt/btif/src/btif_av.cc
7aaf7c6c42a06e174ce305000ab7a223dc99cbdf 23-Aug-2016 Pavlin Radoslavov <pavlin@google.com> A2DP-related naming refactoring and cleanup

* Renamed A2DP-related function names, types, constants and fields.
Also, move some of those functions to a better location.
- tAVDT_DATA_CBACK -> tAVDT_SINK_DATA_CBACK
- tAVDT_MEDIA_CBACK -> tAVDT_SINK_MEDIA_CBACK
- p_data_cback -> p_sink_data_cback
- p_media_cback -> p_sink_media_cback
- p_app_data_cback -> p_app_sink_data_cback
- tBTA_AV_DATA_CBACK -> tBTA_AV_SINK_DATA_CBACK
- BTA_AV_MEDIA_SINK_CFG_EVT -> BTA_AV_SINK_MEDIA_CFG_EVT
- BTA_AV_MEDIA_DATA_EVT -> BTA_AV_SINK_MEDIA_DATA_EVT
- bta_av_stream_data_cback() -> bta_av_sink_data_cback()
- bte_av_media_callback() -> bte_av_sink_media_callback()
- tBTA_AV_CODEC -> tA2D_CODEC
- btif_a2dp_get_track_frequency() -> A2D_sbc_get_track_frequency()
- btif_a2dp_get_track_channel_count() -> A2D_sbc_get_track_channel_count()
- dump_codec_info() -> A2D_sbc_dump_codec_info()

* Misc. other cleanup:
- log messages cleanup
- normalize usage of "+=" in Android.mk files

Change-Id: Ida1528fb5d75cc322533f921daefb65be44562f1
/system/bt/btif/src/btif_av.cc
09d91c0ceb9604c28ff98f524fa775c9a363d59a 22-Jul-2016 Ayan Ghosh <abghosh@codeaurora.org> Proper handling of AV connection collision

Use case:
1. Pair to Remote
2. Turn OFF/ON BT on DUT
3. After DUT's BT is turned ON, Remote would reconnect to DUT

Failure:
Bluetooth settings UI continues to display Connecting when
BT was Turned OFF and ON.

Root cause:
- This is a connection collision case where remote is not responding
to DUT initiated SDP attribute fetch request for AV. AV holds outgoing
connection for sometime and meanwhile remote starts AV connection
from its end. Then DUT disconnects the SDP channel after a second
without waiting to fetch requested info, and this confuses DUT's AV
state machine. The outgoing connection could not proceed as incoming
AV L2CAP connects, because DUT's AV state machine is not equipped
with handling this scenario. On incoming connection timer expiry, it
does not start AV media channel as it finds AV Open has not been done
from upper layer after incoming L2CAP got connected.

- When the incoming path 2s timer expires, the DUT checks whether Open
has been called after incoming state is set. This is not the case here,
because Open was triggered earlier as as part of the outgoing
connection. As a result, A2DP cannot connect at all.

Fix:
- Properly set collision flags for handling AV connection collision.
- Update BTA AV handle even when BTIF AV state machine is yet to be built.

Bug: 30362987
Change-Id: I02a3adb62479b0f762bc792a5727d06e11eaaa52
/system/bt/btif/src/btif_av.cc
b7f64bc45dec7f7fec74ceb04874f322b9434bbf 22-Jun-2016 Marie Janssen <jamuraa@google.com> btif: standardize types, #ifs

Use standard types everywhere.
Use standard style for #if statements:
- #if (VAR_NAME == TRUE)
- #if (VAR_NAME1 == TRUE && VAR_NAME2 == TRUE)
Use __func__ instead of __FUNCTION__

Change-Id: Ic29d1d0b32c3ca9953752a4e5da6c28f45ec8895
/system/bt/btif/src/btif_av.cc
1c512b851d76deac860fce1232e4a1fa1a097f1c 06-Apr-2016 AnubhavGupta <anubhavg@codeaurora.org> Do not request AVRC_CAP_COMPANY_ID if A2DP Sink is not enabled

Also fixed AVRC_PDU_GET_PLAY_STATUS timeout response.

Bug: 28177785
Change-Id: Icde64a5c1806453850abe101f9707fff61566566
/system/bt/btif/src/btif_av.cc
e9a52af36d087ea68ec7ba5ed3f25c24fb3cdf64 11-Nov-2013 Ayan Ghosh <abghosh@codeaurora.org> Limit number of SBC frames to fit into single MTU

- Calculate number of SBC frames to fit into single MTU for EDR capable
remote devices. This makes sure the maximum utilization of the
available bandwidth, keeping the bitrate at high quality.
- This change helps to address the discrepancy seen with a few available
2 Mbps headsets which set the AVDTP media MTU size greater than the
2DH5 packet payload size which eventually forces AVDTP packets to get
fragmented in the controller. This change ensures packing of the SBC
frames in a way that AVDTP packet size fits within the 2DH5 payload
size.
- As packet size is restricted to meet the required bit rate more than
one AVDTP packet can be sent to the controller in a given iteration
based on the bit rate requirement.

Bug: 24875861
Change-Id: Icae7656ad563bbbdef65ecbfa15a89b26cf9edb2
/system/bt/btif/src/btif_av.cc
71461b979a25adc0c30eae899837575e1d95490d 07-Apr-2016 AnubhavGupta <anubhavg@codeaurora.org> A2DP_SINK: create avrcp connection only if a2dp is successful

Scenario: Pair and connect carkit to a remote mobile
Disconnect from carkit
Initiate connection from carkit and turn BT-OFF
on remote mobile phone
Issuses: Even though A2DP connection is unsuccessful we
try to connect AVRCP connectoin
Solution:
- for a2dp sink, we should not send pending play command
- we should create avrcp connection only if a2dp connection
is successful

Change-Id: If2c6a3710b6ebdaa382a3d8bcae5c137aaef1f2c
/system/bt/btif/src/btif_av.cc
f9a8352fd2388b582b09fe01c9a4d4094b3c287c 03-May-2016 Jakub Pawlowski <jpawlowski@google.com> Build fix

Change-Id: I6fd0ebe5e1d650ef307b22f96869c0004f6c956f
/system/bt/btif/src/btif_av.cc
713993d1784ab7c23aee1fa3cf1ab8676cc0aa69 21-Apr-2016 Jakub Pawlowski <jpawlowski@google.com> Convert BTIF code from C to C++

Modifications required:
* added proper casting
* moved variable definitions before goto statements
* added 'extern "C"' markers where needed
* renamed 'operator' to 'operator_name'

Bug: 28485365
Change-Id: I903357967387207e678866c02e008f047f8263f6
/system/bt/btif/src/btif_av.cc