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

Commit 8fc1865a authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge "Flag 24Q3: a2dp_concurrent_source_sink" into main am: 1941c52c

parents 167a4d5a 1941c52c
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -235,16 +235,6 @@ public class Config {
            }
        }

        // TODO: b/321806163 Cleanup post the flag cleanup.
        // Disable A2DP source profile for automotive devices only if sink is enabled and
        // concurrent support is not enabled.
        if (!Flags.a2dpConcurrentSourceSink()
                && Utils.isAutomotive(ctx)
                && A2dpSinkService.isEnabled()) {
            setProfileEnabled(BluetoothProfile.A2DP, false);
            setProfileEnabled(BluetoothProfile.AVRCP, false);
        }

        // Disable ASHA if BLE is not supported on this platform even if the platform enabled ASHA
        // accidentally
        if (!Utils.isBleSupported(ctx)) {
+0 −7
Original line number Diff line number Diff line
@@ -9,13 +9,6 @@ flag {
    bug: "308686081"
}

flag {
    name: "a2dp_concurrent_source_sink"
    namespace: "bluetooth"
    description: "Support for concurrent A2DP source and sink"
    bug : "321806163"
}

flag {
    name: "a2dp_service_looper"
    namespace: "bluetooth"
+20 −60
Original line number Diff line number Diff line
@@ -131,13 +131,7 @@ bool BtaAvCo::IsSupportedCodec(btav_a2dp_codec_index_t codec_index) {
A2dpCodecConfig* BtaAvCo::GetActivePeerCurrentCodec() {
  std::lock_guard<std::recursive_mutex> lock(peer_cache_->codec_lock_);

  BtaAvCoState* reference_state = nullptr;
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
    reference_state = &bta_av_source_state_;
  } else {
    reference_state = &bta_av_legacy_state_;
  }
  BtaAvCoPeer* active_peer = reference_state->getActivePeer();
  BtaAvCoPeer* active_peer = bta_av_source_state_.getActivePeer();
  if (active_peer == nullptr || active_peer->GetCodecs() == nullptr) {
    return nullptr;
  }
@@ -618,13 +612,7 @@ BT_HDR* BtaAvCo::GetNextSourceDataPacket(const uint8_t* p_codec_info, uint32_t*
    return nullptr;
  }

  BtaAvCoState* reference_state = nullptr;
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
    reference_state = &bta_av_source_state_;
  } else {
    reference_state = &bta_av_legacy_state_;
  }
  BtaAvCoPeer* active_peer = reference_state->getActivePeer();
  BtaAvCoPeer* active_peer = bta_av_source_state_.getActivePeer();
  // if offset is 0, the decremental operation may result in
  // underflow and OOB access
  if (ContentProtectEnabled() && (active_peer != nullptr) && active_peer->ContentProtectActive() &&
@@ -701,7 +689,6 @@ bool BtaAvCo::SetActivePeer(const RawAddress& peer_address, const uint8_t t_loca
}

BtaAvCoState* BtaAvCo::getStateFromLocalProfile(const uint8_t t_local_sep) {
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
  if (t_local_sep == AVDT_TSEP_SRC) {
    return &bta_av_source_state_;
  } else if (t_local_sep == AVDT_TSEP_SNK) {
@@ -710,9 +697,6 @@ BtaAvCoState* BtaAvCo::getStateFromLocalProfile(const uint8_t t_local_sep) {
    log::warn("Invalid bta av state for local sep type {}", t_local_sep);
    return nullptr;
  }
  } else {
    return &bta_av_legacy_state_;
  }
}

void BtaAvCo::SaveCodec(const RawAddress& peer_address, const uint8_t* new_codec_config) {
@@ -725,11 +709,7 @@ void BtaAvCo::SaveCodec(const RawAddress& peer_address, const uint8_t* new_codec
    }
    return;
  }
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
  bta_av_sink_state_.setCodecConfig(new_codec_config);
  } else {
    bta_av_legacy_state_.setCodecConfig(new_codec_config);
  }
}

void BtaAvCo::GetPeerEncoderParameters(const RawAddress& peer_address,
@@ -772,11 +752,8 @@ const tA2DP_ENCODER_INTERFACE* BtaAvCo::GetSourceEncoderInterface(const RawAddre
    }
    return nullptr;
  }
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
  return A2DP_GetEncoderInterface(bta_av_source_state_.getCodecConfig());
}
  return A2DP_GetEncoderInterface(bta_av_legacy_state_.getCodecConfig());
}

bool BtaAvCo::SetCodecUserConfig(const RawAddress& peer_address,
                                 const btav_a2dp_codec_config_t& codec_user_config,
@@ -862,12 +839,7 @@ done:
  // and informing the Media Framework about the change.

  // Find the peer that is currently open
  BtaAvCoPeer* active_peer;
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
    active_peer = bta_av_source_state_.getActivePeer();
  } else {
    active_peer = bta_av_legacy_state_.getActivePeer();
  }
  BtaAvCoPeer* active_peer = bta_av_source_state_.getActivePeer();
  if (p_peer != nullptr && (!restart_output || !success || p_peer != active_peer)) {
    return ReportSourceCodecState(p_peer);
  }
@@ -883,12 +855,7 @@ bool BtaAvCo::SetCodecAudioConfig(const btav_a2dp_codec_config_t& codec_audio_co
  log::verbose("codec_audio_config: {}", codec_audio_config.ToString());

  // Find the peer that is currently open
  BtaAvCoPeer* p_peer;
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
    p_peer = bta_av_source_state_.getActivePeer();
  } else {
    p_peer = bta_av_legacy_state_.getActivePeer();
  }
  BtaAvCoPeer* p_peer = bta_av_source_state_.getActivePeer();
  if (p_peer == nullptr) {
    log::error("no active peer to configure");
    return false;
@@ -952,11 +919,8 @@ int BtaAvCo::GetSourceEncoderEffectiveFrameSize(const RawAddress& peer_address)
    }
    return 0;
  }
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
  return A2DP_GetEecoderEffectiveFrameSize(bta_av_source_state_.getCodecConfig());
}
  return A2DP_GetEecoderEffectiveFrameSize(bta_av_legacy_state_.getCodecConfig());
}

int BtaAvCo::GetSourceEncoderPreferredIntervalUs() {
  const BtaAvCoPeer* active_peer = bta_av_source_state_.getActivePeer();
@@ -1347,7 +1311,6 @@ void BtaAvCo::SaveNewCodecConfig(BtaAvCoPeer* p_peer, const uint8_t* new_codec_c
}

BtaAvCoState* BtaAvCo::getStateFromPeer(const BtaAvCoPeer* p_peer) {
  if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
  if (p_peer->uuid_to_connect == UUID_SERVCLASS_AUDIO_SINK) {
    return &bta_av_source_state_;
  } else if (p_peer->uuid_to_connect == UUID_SERVCLASS_AUDIO_SOURCE) {
@@ -1357,9 +1320,6 @@ BtaAvCoState* BtaAvCo::getStateFromPeer(const BtaAvCoPeer* p_peer) {
              p_peer->uuid_to_connect);
    return nullptr;
  }
  } else {
    return &bta_av_legacy_state_;
  }
}

tA2DP_STATUS BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config,
+2 −6
Original line number Diff line number Diff line
@@ -352,12 +352,8 @@ struct CoreInterfaceImpl : bluetooth::core::CoreInterface {
      return;
    }

    if (com::android::bluetooth::flags::a2dp_concurrent_source_sink()) {
    btif_av_acl_disconnected(bd_addr, A2dpType::kSource);
    btif_av_acl_disconnected(bd_addr, A2dpType::kSink);
    } else {
      btif_av_acl_disconnected(bd_addr, A2dpType::kUnknown);
    }
  }
};

+2 −24
Original line number Diff line number Diff line
@@ -42,18 +42,6 @@ using bluetooth::audio::a2dp::BluetoothAudioStatus;
void btif_a2dp_on_idle(const RawAddress& peer_addr, const A2dpType local_a2dp_type) {
  log::verbose("Peer stream endpoint type:{}",
               peer_stream_endpoint_text(btif_av_get_peer_sep(local_a2dp_type)));
  if (!com::android::bluetooth::flags::a2dp_concurrent_source_sink() &&
      btif_av_src_sink_coexist_enabled()) {
    bool is_sink = btif_av_peer_is_sink(peer_addr);
    bool is_source = btif_av_peer_is_source(peer_addr);
    log::info("## ON A2DP IDLE ## is_sink:{} is_source:{}", is_sink, is_source);
    if (is_sink) {
      btif_a2dp_source_on_idle();
    } else if (is_source) {
      btif_a2dp_sink_on_idle();
    }
    return;
  }
  if (btif_av_get_peer_sep(local_a2dp_type) == AVDT_TSEP_SNK) {
    btif_a2dp_source_on_idle();
  } else if (btif_av_get_peer_sep(local_a2dp_type) == AVDT_TSEP_SRC) {
@@ -113,12 +101,7 @@ void btif_a2dp_on_stopped(tBTA_AV_SUSPEND* p_av_suspend, const A2dpType local_a2
    btif_a2dp_sink_on_stopped(p_av_suspend);
    return;
  }
  if (!com::android::bluetooth::flags::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 (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;
@@ -133,12 +116,7 @@ void btif_a2dp_on_suspended(tBTA_AV_SUSPEND* p_av_suspend, const A2dpType local_
    btif_a2dp_sink_on_suspended(p_av_suspend);
    return;
  }
  if (!com::android::bluetooth::flags::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 (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;
Loading