Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63d2fa3e authored by Jack He's avatar Jack He
Browse files

Use MessageLoopThread in A2DP source, JNI, BTA, HCI and module bring-up

* Replace OSI thread with MessageLoopThread in
  - btif_a2dp_source (A2DP encoding thread)
  - btif_core (JNI thread)
  - btu_init (BTA thread)
  - hci_layer (HCI thread)
  - module (module bring up thread)
  - various unit test threads
* Code that uses reactor from OSI thread is not replaced in this change
  because they need to move from using reactor to message loop first
* Main difference:
  - HCI layer no longer has access to mutex protecting message loop
    set up and tear down. Messages posted to thread after ShutDown()
    is called become no-op
  - In all cases QuitClosure() is used instead of QuitWhenIdleClosure().
    This means that we will never force kill a thread. An infinite loop
    will delay the shutdown of Bluetooth stack.
* do_in_hci_thread is actually do_in_bta_thread
* Move the definition of do_in_bta_thread from bta to btu since btu is
  where the thread actually lives
* Remove bta_closure_api.h and replace it with stack/include/btu.h
* Remove header inclusion in bta_sys.h and include stack/include/btu.h
  in individual compilation units
* Fixed a bug in btif_cleanup_bluetooth where btif_jni_disassociate()
  was not called on the JNI thread
* Make setting real time priority a requirement
* Crash during the following scenario:
  - When btif_profile_queue cleanup failed to be scheduled on JNI thread
  - When A2DP encoder thread failed to gain real time priority
  - When BTA thread failed to start up
  - When BTA thread failed to gain real time priority
  - When BTA thread failed to schedule its first callback
* Turn off Bluetooth in the following scenario:
  - When HCI thread failed to gain real time priority
  - When bt_workqueue thread failed to gain real time priority

Bug: 110303473
Test: make, native and Java unit tests,
      Connect to headset and listen to music through A2DP,
      testplans/details/184455/3975
Change-Id: Ib448992fc0ba5af82c2d117dd65f1abd45d2acb6
parent 0ac5b1b6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "bta_ag_int.h"
#include "bta_api.h"
#include "bta_sys.h"
#include "stack/include/btu.h"

/*****************************************************************************
 *  Constants
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "osi/include/osi.h"
#include "port_api.h"
#include "rfcdefs.h"
#include "stack/include/btu.h"
#include "utl.h"

/* Event mask for RfCOMM port callback */
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "device/include/controller.h"
#include "device/include/esco_parameters.h"
#include "osi/include/osi.h"
#include "stack/include/btu.h"
#include "utl.h"

/* Codec negotiation timeout */
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "btm_api.h"
#include "osi/include/osi.h"
#include "sdp_api.h"
#include "stack/include/btu.h"
#include "utl.h"

using bluetooth::Uuid;
+1 −1
Original line number Diff line number Diff line
@@ -26,13 +26,13 @@

#include "bt_common.h"
#include "bta_api.h"
#include "bta_closure_api.h"
#include "bta_dm_int.h"
#include "bta_sys.h"
#include "bta_sys_int.h"
#include "btm_api.h"
#include "btm_int.h"
#include "osi/include/osi.h"
#include "stack/include/btu.h"
#include "utl.h"

using bluetooth::Uuid;
Loading