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

Commit e2fbecd5 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Free the A2DP Source media alarm on the A2DP Source worker thread

Move the alarm_free() for the A2DP Source media alarm from
btif_a2dp_source_shutdown() to btif_a2dp_source_shutdown_delayed().
The latter is executed on the btif_a2dp_source_thread.
This avoids a race condition with btif_a2dp_source_audio_tx_stop_event()
that also might attempt to free the same alarm.

Test: Manual - unpair A2DP device while A2DP streaming.
Bug: 73741079
Change-Id: Ia871fcbeaae7c351878228e7605e65307a3d1583
parent 7f1a8971
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -414,10 +414,6 @@ void btif_a2dp_source_shutdown(void) {

  APPL_TRACE_EVENT("## A2DP SOURCE STOP MEDIA THREAD ##");

  // Stop the timer
  alarm_free(btif_a2dp_source_cb.media_alarm);
  btif_a2dp_source_cb.media_alarm = nullptr;

  // Exit the thread
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_shutdown_delayed));
@@ -425,6 +421,10 @@ void btif_a2dp_source_shutdown(void) {
}

static void btif_a2dp_source_shutdown_delayed(void) {
  // Stop the timer
  alarm_free(btif_a2dp_source_cb.media_alarm);
  btif_a2dp_source_cb.media_alarm = nullptr;

  btif_a2dp_control_cleanup();
  fixed_queue_free(btif_a2dp_source_cb.tx_audio_queue, nullptr);
  btif_a2dp_source_cb.tx_audio_queue = nullptr;