History log of /system/bt/bta/av/bta_av_ssm.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
40f9433098342816da0ea9e6e1cefd33fc4383ef 23-Apr-2018 Pavlin Radoslavov <pavlin@google.com> Save the AVDTP version after SDP discovery and read it on reconnect

* Save the AVDTP version discovered by SDP to the device's local
configuration section with key string of "AvdtpVersion"
* Refactor tBTA_AV_SCB and hide the AVDTP version and peer address
behind get/set methods:
AvdtpVersion() / SetAvdtpVersion() / PeerAddress().
* Added new methods tBTA_AV_SCB::OnConnected() and OnDisconnected().
The former is used to setup some of the internal state when
connected to a peer: the peer address and read the stored AVDTP
version from local configuration section.
The latter is used to reset that state when disconnected
from that peer.
* Removed field tBTA_AV_SDP_RES.avdt_version because it is never
set / used.
* Removed duplicate re-definition of AVDT_VERSION inside avdt_api.h

Bug: 78142165
Test: Manual: connect/reconnect with Sennheiser MOMENTUM M2 AEBT headset
Change-Id: Ib9dcd95dc9899fa81f3cd927f127e5cb0f21ef60
Merged-In: Ib9dcd95dc9899fa81f3cd927f127e5cb0f21ef60
(cherry picked from commit a634f4e30a28d38d5363e01a7d7b301c281f9df4)
/system/bt/bta/av/bta_av_ssm.cc
c7242818d4180dec4eae2e75f9fb91f7f6a160aa 25-Nov-2017 Pavlin Radoslavov <pavlin@google.com> Add support for Multi-A2DP state machines per device

* Reimplement most of the BTIF AV state machinery in C++
- Separate the BTIF AV Source from BTIF AV Sink state:
btif_av_source and btif_av_sink
- Remove the single btif_av_cb control block instance
- Add C++ based BtifStateMachine and remove the older C-based
btif_sm state machine
- Introduce C++ class BtifAvPeer to keep state per peer, and use
a single state machine instance per peer
- Update BTA_AvStart() and BTA_AvStop() to take tBTA_AV_HNDL handle
argument
- Register the BTA handles when enabling the Source/Sink service.
This needs to be done in advance during service startup, otherwise
a connection to a remote device will fail.
- Move local event_handler functions inside C++ ProcessEvent methods,
and pocess the BTIF, BTA AV and BTA AVRCP events per state machine
instance
- Cleanup callbacks and use do_in_jni_thread() to schedule the processing
- Add BTIF AV API that needs to be called by the AVRCP module for certain
AVRCP events: btif_av_avrcp_event_open(), btif_av_avrcp_event_close()
btif_av_avrcp_event_remote_play()
- Add a mechanism to set the active device
- Add BluetoothDevice argument to the codec-related internal Binder
APIs: getCodecStatus(), enableOptionalCodecs(),
disableOptionalCodecs(), setCodecConfigPreference()
- Rename btif_av_move_idle() to btif_av_acl_disconnected() and
refactor the processing to happen within each state machine on the
correct thread.
- Process cleanup_src and cleanup_sink on the JNI thread
- Add a mechanism to track the maximum number of connected devices.
- Add unit tests for the new BtifStateMachine class

* Redesign some of the AVDTP internals so it can handle multiple connected
devices
- Change some of the AVDTP struct entries to C++ classes.
This simplifies significantly the design fixes
- Reorganize the AvdtpScb entries: for each connection the
corresponding SEP entries are within the corresponding AvdtpCcb entry.
- Pass peer address as argument to the API functions inside bta_av_co.cc,
and update the peer address inside the corresponding peer entry in
bta_av_co.cc
- Add various log mesages
- Store precomputed BTA AV SCB index in the AvdtpCcb entry and use it as
appropriate.
- Fix the TCID computation and handling for the AvdtpAdaptationLayer
- Fix the computed value for AVDT_NUM_RT_TBL
- Remove video-related code inside AVDTP
- Refactor/cleanup hard-coded callbacks that depend on the BTA_AV_NUM_STRS
value.
- Update various #define values to support a larger number of connected
devices:
- Maximum number of streams:
BTA_AV_NUM_STRS: 2 -> 6
- BT_RC_NUM_APP: 1 -> 12 (AVRCP-related - 2 * MaxDevices)
- MAX_L2CAP_LINKS: 7 -> 13
- MAX_L2CAP_CHANNELS: 16 -> 32
- AVDT_NUM_LINKS: 2 -> 6
- AVDT_NUM_SEPS: (6 * AVDT_NUM_LINKS) -> 6
Now the value is used for the maximum number of SEPs per device
- AVDT_NUM_TC_TBL: 6 -> (AVDT_NUM_SEPS + AVDT_NUM_LINKS)
- AVCT_NUM_LINKS: 2 -> 6
- AVCT_NUM_CONN: 3 -> 14 (2 * MaxDevices + 2)

Also:
- Update the JNI codec-related calls to use const reference
instead of a pointer
- Update the implementation of bta_av_chk_2nd_start() so it is aligned
with bta_av_chk_start() and cleaned up both functions.
- Rename btif_dispatch_sm_event() to btif_av_dispatch_sm_event() and
btif_report_source_codec_state() to btif_av_report_source_codec_state()
for consistency with the rest of the BTIF AV API.
- Add new function btif_rc_is_connected_peer() and remove
btif_rc_get_connected_peer()
- Add new AVRCP header file btif/include/btif_rc.h
and move the AVRCP "extern" declarations from btif_av.cc there.
- Rename btif_av_execute_service() to btif_av_source_execute_service()
- Cleanup the btif_av.h API descriptions
- Print the BTIF AV state in the "dumpsys bluetooth_manager" output
- Print the BTA AV state in the "dumpsys bluetooth_manager" output
- Print the AVDTP state in the "dumpsys bluetooth_manager" output
- Refactor btif_a2dp_source_cb into a class with internal state.
- Refactor A2DP Source worker thread handling and replace it with
libchrome message handler
- Refactor BtaAvCo component (bta_av_co.cc)
- C++ classes and state
- Rename bta_av_co_audio_src_data_path to
bta_av_co_audio_source_data_path
- Remove most BTA_AV_CO_CP_SCMS_T checks
- Replace mutex_global_lock() usage with local mutex
- Keep codec-specific state per peer
- Keep state about the active peer - the first connected peer is the
default active peer
- Report source codec state only for valid peers; i.e., don't report
source codec state for empty RawAddress
- Keep the contect_protect_active flag per peer
- Print the BTA AV CO state in the dumpsys bluetooth_manager" output
- Misc cleanup in BTA AV
- Add ToString() method to struct btav_a2dp_codec_config_t
- Additional cleanup

Bug: 70350399
Test: Manual and unit tests
Change-Id: Icecd7fd44a222d939b63a7473a2239ae0679f08c
/system/bt/bta/av/bta_av_ssm.cc
56c48f06db8438ff66e6461823e50398e92826d6 18-Nov-2017 Pavlin Radoslavov <pavlin@google.com> Removed unused or unnecessary defines

Removed the following defines because they are unused or unnecessary:
- AVDT_REPORTING
- AVRC_METADATA_INCLUDED
- BTA_INCLUDED
- SBC_FOR_EMBEDDED_LINUX
- BTA_AVRCP_FF_RW_SUPPORT
- GATT_DB_BUF_SIZE
- BTM_DEFAULT_SCO_MODE
- BTM_BLE_ADV_TX_POWER
- BTM_BLE_ADV_TX_POWER_*
- ATT_INCLUDED
- ATT_DEBUG
- GAP_TRANSPORT_SUPPORTED
- GATTP_TRANSPORT_SUPPORTED
- PORT_CREDIT_RX_MAX
- PORT_CREDIT_RX_LOW
- AVDT_INCLUDED
- AVDT_REPORTING
- HID_DEV_SUBCLASS
- A2D_INCLUDED

Also:
- Changed tBTA_AV_SCB field p_cap from dynamically allocated to
inlined storage, and renamed it to peer_cap.
- Removed unused typedef tBTM_BLE_ADV_TX_POWER

Test: Manual: streaming to Headset.
Change-Id: I0db18cc7ae3b9e692c71b430436f3170e8e4d65e
/system/bt/bta/av/bta_av_ssm.cc
5b790feeeb211c42bf78ca3ae9c26aa30e516765 18-Sep-2017 Jakub Pawlowski <jpawlowski@google.com> Make copyright headers consistent with Google template; remove "(C)"

Test: Comment changes only; still compiles...
Change-Id: Id699a8170112f06e4a2c9f2e0f0834d1817ace4e
/system/bt/bta/av/bta_av_ssm.cc
a72b0e2757dce000a3d4fcd74cfc338b9154822e 11-Feb-2017 Pavlin Radoslavov <pavlin@google.com> Allow back-to-back AVDTP API_RECONFIG_EVT events

Based on AVDTP Spec 1.3, Section 9.8 StreamChangeParameters, the RECONFIG
procedure (AVDTP_RECONFIGURE_CMD) happens in OPEN state, and there is no
state transition that would prohibit calling the RECONFIG procedure
back-to-back.

Test: A2DP codec reconfiguration and audio play with several Sink devices
Bug: 35284763
Change-Id: Ie4ddca8545e2146fbd863e55713fd2d49994b4b0
/system/bt/bta/av/bta_av_ssm.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/bta/av/bta_av_ssm.cc
f33b6f434f086b20fabe5913016bc423ac975057 23-Nov-2016 Marie Janssen <jamuraa@google.com> readability fix: No assigns in if conditionals

Coccinelle-assisted:
@@
variable i;
expression E;
statement S1, S2;
@@

+ i = E;
if (
(
- (i = E)
+ i
!= ...
|
- (i = E)
+ i
== ...
|
- (i = E)
+ i
< ...
|
- (i = E)
+ i
> ...
|
- (i = E)
+ i
<= ...
|
- (i = E)
+ i
>= ...
|
- (i = E)
+ i
)
) S1 else S2

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

clang-format --style=file -i bta/**/*.cc

Test: mma -j37 and basic sanity testing on angler, sailfish

Change-Id: I41a2964afac347c24e13869b6c172e321e646091
/system/bt/bta/av/bta_av_ssm.cc
cd1fd07f1306e08fe048682dd5918987e579f937 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Apply clang-format

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

(twice)

Test: mma -j32
Change-Id: Ib118b1dfb6a34f9a5bfe153d65841e9041165264
/system/bt/bta/av/bta_av_ssm.cc
f355ef5a4d7fb667fc57a0dfb60f738d870e252e 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Prepare include statements for clang-format

bta: Separate includes of different types

Include "bta_sys.h" in bta/dm/bta_dm_int.h

Test: mma -j32
Change-Id: I292bc6518230201e1175937b9c6766c19709c9d5
/system/bt/bta/av/bta_av_ssm.cc
8af480e24549ba51a3f6858d9d9af504715e0bea 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Remove double asterisks in comments

Double asterisks at the beginning of the line
sed -i s,"^[*][*]"," *", bta/*/*

Double asterisks after a space
sed -i s,"^ [*][*]\([^*]\)"," *\1", bta/*/*
sed -i s,"^ [*][*]$"," *", bta/*/*

Test: mma -j32
Change-Id: Ib83b802c7000176683b4e7f24d1255b3c2c6c01c
/system/bt/bta/av/bta_av_ssm.cc
cc26bfcba0d5cc2473b34dc1b51913995e2db67e 14-Oct-2016 Pavlin Radoslavov <pavlin@google.com> Renamed files: *.c to *.cc in bta/av and stack/a2dp

Also, fixed C++ related compilation errors.

Test: code compilation from top-level directory
Change-Id: I60367ee7bc54b891cb05bb3f88dd11ebe5b2ca83
/system/bt/bta/av/bta_av_ssm.cc