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 Merged-In: Icecd7fd44a222d939b63a7473a2239ae0679f08c (cherry picked from commit d9b0b593)
Showing
- system/binder/android/bluetooth/IBluetoothA2dp.aidl 5 additions, 4 deletionssystem/binder/android/bluetooth/IBluetoothA2dp.aidl
- system/bta/ar/bta_ar.cc 10 additions, 8 deletionssystem/bta/ar/bta_ar.cc
- system/bta/av/bta_av_aact.cc 211 additions, 324 deletionssystem/bta/av/bta_av_aact.cc
- system/bta/av/bta_av_act.cc 148 additions, 183 deletionssystem/bta/av/bta_av_act.cc
- system/bta/av/bta_av_api.cc 10 additions, 2 deletionssystem/bta/av/bta_av_api.cc
- system/bta/av/bta_av_cfg.cc 24 additions, 38 deletionssystem/bta/av/bta_av_cfg.cc
- system/bta/av/bta_av_ci.cc 15 additions, 5 deletionssystem/bta/av/bta_av_ci.cc
- system/bta/av/bta_av_int.h 41 additions, 30 deletionssystem/bta/av/bta_av_int.h
- system/bta/av/bta_av_main.cc 315 additions, 220 deletionssystem/bta/av/bta_av_main.cc
- system/bta/av/bta_av_ssm.cc 265 additions, 272 deletionssystem/bta/av/bta_av_ssm.cc
- system/bta/include/bta_ar_api.h 3 additions, 2 deletionssystem/bta/include/bta_ar_api.h
- system/bta/include/bta_av_api.h 14 additions, 16 deletionssystem/bta/include/bta_av_api.h
- system/bta/include/bta_av_ci.h 2 additions, 2 deletionssystem/bta/include/bta_av_ci.h
- system/bta/include/bta_av_co.h 30 additions, 19 deletionssystem/bta/include/bta_av_co.h
- system/bta/sys/bta_sys_conn.cc 2 additions, 0 deletionssystem/bta/sys/bta_sys_conn.cc
- system/btif/Android.bp 27 additions, 2 deletionssystem/btif/Android.bp
- system/btif/BUILD.gn 0 additions, 1 deletionsystem/btif/BUILD.gn
- system/btif/co/bta_av_co.cc 1478 additions, 929 deletionssystem/btif/co/bta_av_co.cc
- system/btif/include/btif_a2dp.h 3 additions, 1 deletionsystem/btif/include/btif_a2dp.h
- system/btif/include/btif_a2dp_source.h 4 additions, 1 deletionsystem/btif/include/btif_a2dp_source.h
Loading
Please register or sign in to comment