OSDN Git Service

Check A2DP source is not already shut{ting} down
authorSanket Agarwal <sanketa@google.com>
Wed, 2 Nov 2016 18:56:44 +0000 (11:56 -0700)
committerSanket Agarwal <sanketa@google.com>
Wed, 2 Nov 2016 19:23:02 +0000 (12:23 -0700)
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

index 13de212..d9e666e 100644 (file)
@@ -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;