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

Commit 8d481729 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Set Ecosystem Base interval when LE Audio is in use

Instruct controller to round connection events to same value that's used
by CIS audio stream

Bug: 300251578
Bug: 332574780
Test: mma -j32
Change-Id: If3dfc65ae46563f3070cd98cce183ff952f0eac6
parent 1077361f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1160,6 +1160,8 @@ class LeAudioClientImpl : public LeAudioClient {
      log::assert_that(true, "Both configs are invalid");
    }

    L2CA_SetEcosystemBaseInterval(frame_duration_us / 1250);

    audio_framework_source_config.data_interval_us = frame_duration_us;
    le_audio_source_hal_client_->Start(audio_framework_source_config,
                                       audioSinkReceiver, dsa_modes);
@@ -3838,7 +3840,10 @@ class LeAudioClientImpl : public LeAudioClient {
    CleanCachedMicrophoneData();
  }

  void StopAudio(void) { SuspendAudio(); }
  void StopAudio(void) {
    SuspendAudio();
    L2CA_SetEcosystemBaseInterval(0 /* clear recommendation */);
  }

  void printCurrentStreamConfiguration(int fd) {
    std::stringstream stream;
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <vector>

#include "btif/include/stack_manager_t.h"
#include "common/message_loop_thread.h"
#include "hal/snoop_logger.h"
#include "hci/controller_interface_mock.h"
#include "osi/include/allocator.h"
@@ -66,6 +67,7 @@ bt_status_t do_in_main_thread_delayed(base::Location const&,
  // any test cases
  abort();
}
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace bluetooth {
namespace os {
+2 −0
Original line number Diff line number Diff line
@@ -887,6 +887,8 @@ void L2CA_AdjustConnectionIntervals(uint16_t* min_interval,
                                    uint16_t* max_interval,
                                    uint16_t floor_interval);

void L2CA_SetEcosystemBaseInterval(uint32_t base_interval);

/**
 * Check whether an ACL or LE link to the remote device is established
 */
+27 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

#include <base/strings/stringprintf.h>
#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#ifdef __ANDROID__
#include <android/sysprop/BluetoothProperties.sysprop.h>
@@ -34,6 +35,7 @@
#include "btif/include/core_callbacks.h"
#include "btif/include/stack_manager_t.h"
#include "hci/controller_interface.h"
#include "hci/hci_layer.h"
#include "internal_include/bt_target.h"
#include "main/shim/entry.h"
#include "osi/include/allocator.h"
@@ -50,6 +52,7 @@
#include "stack/include/l2c_api.h"
#include "stack/include/l2cap_acl_interface.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/main_thread.h"
#include "stack/l2cap/l2c_int.h"
#include "types/raw_address.h"

@@ -1419,3 +1422,27 @@ void L2CA_AdjustConnectionIntervals(uint16_t* min_interval,
    *max_interval = phone_min_interval;
  }
}

void L2CA_SetEcosystemBaseInterval(uint32_t base_interval) {
  if (!com::android::bluetooth::flags::le_audio_base_ecosystem_interval()) {
    return;
  }

  log::info("base_interval: {}ms", base_interval);
  bluetooth::shim::GetHciLayer()->EnqueueCommand(
      bluetooth::hci::SetEcosystemBaseIntervalBuilder::Create(base_interval),
      get_main_thread()->BindOnce([](bluetooth::hci::CommandCompleteView view) {
        ASSERT(view.IsValid());
        auto status_view =
            bluetooth::hci::SetEcosystemBaseIntervalCompleteView::Create(
                bluetooth::hci::SetEcosystemBaseIntervalCompleteView::Create(
                    view));
        ASSERT(status_view.IsValid());

        if (status_view.GetStatus() != bluetooth::hci::ErrorCode::SUCCESS) {
          log::warn("Set Ecosystem Base Interval status {}",
                    ErrorCodeText(status_view.GetStatus()));
          return;
        }
      }));
}
+5 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ struct l2cble_send_peer_disc_req l2cble_send_peer_disc_req;
struct l2cble_sec_comp l2cble_sec_comp;
struct l2ble_sec_access_req l2ble_sec_access_req;
struct L2CA_AdjustConnectionIntervals L2CA_AdjustConnectionIntervals;
struct L2CA_SetEcosystemBaseInterval L2CA_SetEcosystemBaseInterval;
struct l2cble_use_preferred_conn_params l2cble_use_preferred_conn_params;
struct L2CA_SubrateRequest L2CA_SubrateRequest;
struct l2cble_process_subrate_change_evt l2cble_process_subrate_change_evt;
@@ -180,6 +181,10 @@ void L2CA_AdjustConnectionIntervals(uint16_t* min_interval,
  test::mock::stack_l2cap_ble::L2CA_AdjustConnectionIntervals(
      min_interval, max_interval, floor_interval);
}
void L2CA_SetEcosystemBaseInterval(uint32_t base_interval) {
  inc_func_call_count(__func__);
  test::mock::stack_l2cap_ble::L2CA_SetEcosystemBaseInterval(base_interval);
}
void l2cble_use_preferred_conn_params(const RawAddress& bda) {
  inc_func_call_count(__func__);
  test::mock::stack_l2cap_ble::l2cble_use_preferred_conn_params(bda);
Loading