From f436d2f131cea47a20c9f5864c09d329af8872b0 Mon Sep 17 00:00:00 2001 From: Sanket Agarwal Date: Wed, 2 Nov 2016 11:56:44 -0700 Subject: [PATCH] Check A2DP source is not already shut{ting} down In case A2DP is not enabled we are still executing the shut down path which is leading to a race condition and posting to a thread queue which is never created. Bug: b/32610895 Change-Id: Id0cf95f4c7b5be26be28db5e837fbca3a0a87072 --- btif/src/btif_a2dp_source.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/btif/src/btif_a2dp_source.cc b/btif/src/btif_a2dp_source.cc index 13de212e3..d9e666ed4 100644 --- a/btif/src/btif_a2dp_source.cc +++ b/btif/src/btif_a2dp_source.cc @@ -244,6 +244,11 @@ static void btif_a2dp_source_startup_delayed(UNUSED_ATTR void* context) { } void btif_a2dp_source_shutdown(void) { + if ((btif_a2dp_source_state == BTIF_A2DP_SOURCE_STATE_OFF) || + (btif_a2dp_source_state == BTIF_A2DP_SOURCE_STATE_SHUTTING_DOWN)) { + return; + } + /* Make sure no channels are restarted while shutting down */ btif_a2dp_source_state = BTIF_A2DP_SOURCE_STATE_SHUTTING_DOWN; -- 2.11.0