From d4aea810b1b4c2ae6a968f65348c099f09d9d162 Mon Sep 17 00:00:00 2001 From: Cheney Ni Date: Wed, 27 Mar 2019 20:58:49 +0800 Subject: [PATCH] A2DP: Initialize the UIPC HAL only when those binderized HALs are not enabled When using BluetoothA2dp / BluetoothAudio HAL, the UIPC won't be used, and is no need to do the initialization. If it is up, there will be an uipc-main thread running, and we have to release by the UIPC_Close API before the A2DP source restarting. If we are acquiring a new one before released, some of its resource will be leaked, and causes the stack abnormal. Bug: 128256722 Test: Check uipc-main is running when using the legacy HAL only Change-Id: Icc8ea102d29c92b58c77099979d17e85e5cb9a83 --- btif/src/btif_a2dp_source.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/btif/src/btif_a2dp_source.cc b/btif/src/btif_a2dp_source.cc index 335e62a4c..9951ce1c1 100644 --- a/btif/src/btif_a2dp_source.cc +++ b/btif/src/btif_a2dp_source.cc @@ -357,8 +357,12 @@ static void btif_a2dp_source_startup_delayed() { LOG(FATAL) << __func__ << ": unable to enable real time scheduling"; } if (!bluetooth::audio::a2dp::init(&btif_a2dp_source_thread)) { - LOG(WARNING) << __func__ << ": Using legacy HAL"; - btif_a2dp_control_init(); + if (btif_av_is_a2dp_offload_enabled()) { + LOG(WARNING) << __func__ << ": Using BluetoothA2dp HAL"; + } else { + LOG(WARNING) << __func__ << ": Using legacy HAL"; + btif_a2dp_control_init(); + } } btif_a2dp_source_cb.SetState(BtifA2dpSource::kStateRunning); } -- 2.11.0