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

Commit 1180715d authored by Sandeep Samdaria's avatar Sandeep Samdaria
Browse files

AV Suspend from source device should not suspend a2dp source stream

Problem: While bluetooth's source profile is streaming audio to a
remote sink device and in parallel a source device connects to the
sink profile. The source device may send AV Suspend event
(for sink profile) to suspend the audio stream. Currently, it
results in the source profile to suspend the audio stream.
Also, when the a2dp stream goes idle, there is a possibility there
is no active device resulting in the idle event to be dropped.

Solution: Add additional check for which profile the stream is being
suspended/idle event for.

Bug: 325528613
Bug: 321806163
Test: atest net_*
Change-Id: I6d05dd28dc3bef068d95d3aa4b13aa4326d351a0
parent ecd7462d
Loading
Loading
Loading
Loading
+28 −8
Original line number Diff line number Diff line
@@ -136,26 +136,46 @@ void btif_a2dp_on_stopped(tBTA_AV_SUSPEND* p_av_suspend,
                          const A2dpType local_a2dp_type) {
  log::info("## ON A2DP STOPPED ## p_av_suspend={}", fmt::ptr(p_av_suspend));

  if (btif_av_get_peer_sep(local_a2dp_type) == AVDT_TSEP_SRC) {
  const uint8_t peer_type_sep = btif_av_get_peer_sep(local_a2dp_type);
  if (peer_type_sep == AVDT_TSEP_SRC) {
    btif_a2dp_sink_on_stopped(p_av_suspend);
    return;
  }
  if (!IS_FLAG_ENABLED(a2dp_concurrent_source_sink)) {
    if (bluetooth::audio::a2dp::is_hal_enabled() ||
        !btif_av_is_a2dp_offload_running()) {
      btif_a2dp_source_on_stopped(p_av_suspend);
      return;
    }
  } else if (peer_type_sep == AVDT_TSEP_SNK) {
    if (bluetooth::audio::a2dp::is_hal_enabled() ||
        !btif_av_is_a2dp_offload_running()) {
      btif_a2dp_source_on_stopped(p_av_suspend);
      return;
    }
  }
}

void btif_a2dp_on_suspended(tBTA_AV_SUSPEND* p_av_suspend,
                            const A2dpType local_a2dp_type) {
  log::info("## ON A2DP SUSPENDED ## p_av_suspend={}", fmt::ptr(p_av_suspend));
  if (btif_av_get_peer_sep(local_a2dp_type) == AVDT_TSEP_SRC) {
  const uint8_t peer_type_sep = btif_av_get_peer_sep(local_a2dp_type);
  if (peer_type_sep == AVDT_TSEP_SRC) {
    btif_a2dp_sink_on_suspended(p_av_suspend);
    return;
  }
  if (!IS_FLAG_ENABLED(a2dp_concurrent_source_sink)) {
    if (bluetooth::audio::a2dp::is_hal_enabled() ||
        !btif_av_is_a2dp_offload_running()) {
      btif_a2dp_source_on_suspended(p_av_suspend);
      return;
    }
  } else if (peer_type_sep == AVDT_TSEP_SNK) {
    if (bluetooth::audio::a2dp::is_hal_enabled() ||
        !btif_av_is_a2dp_offload_running()) {
      btif_a2dp_source_on_suspended(p_av_suspend);
      return;
    }
  }
}