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

Commit 5a4d07fb authored by Sal Savage's avatar Sal Savage
Browse files

Add max_connected_audio_devices parameter to A2DP Sink init

This movess us off of a hardcoded value for number of connected devices
and allows Java, through the JNI, to have input on the maximum number of
audio devices it would like to have connected. This moves A2DP Sink in
linne with A2DP Source. It will also enable easily configurable
multi-a2dp sink and avrcp controller experiences.

Tag: #refactor
Bug: 180039146
Test: atest BluetoothInstrumentationTests
Change-Id: I98b7d55d8aa53c07af6451f3d5dca529b96739fc
parent 771c552e
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -554,7 +554,8 @@ class BtifAvSink {
        max_connected_peers_(kDefaultMaxConnectedAudioDevices) {}
  ~BtifAvSink();

  bt_status_t Init(btav_sink_callbacks_t* callbacks);
  bt_status_t Init(btav_sink_callbacks_t* callbacks,
                   int max_connected_audio_devices);
  void Cleanup();

  btav_sink_callbacks_t* Callbacks() { return callbacks_; }
@@ -1179,12 +1180,14 @@ void BtifAvSource::BtaHandleRegistered(uint8_t peer_id,

BtifAvSink::~BtifAvSink() { CleanupAllPeers(); }

bt_status_t BtifAvSink::Init(btav_sink_callbacks_t* callbacks) {
  LOG_INFO("%s", __PRETTY_FUNCTION__);
bt_status_t BtifAvSink::Init(btav_sink_callbacks_t* callbacks,
                             int max_connected_audio_devices) {
  LOG_INFO("%s(max_connected_audio_devices=%d)", __PRETTY_FUNCTION__,
           max_connected_audio_devices);
  if (enabled_) return BT_STATUS_SUCCESS;

  CleanupAllPeers();
  max_connected_peers_ = kDefaultMaxConnectedAudioDevices;
  max_connected_peers_ = max_connected_audio_devices;
  callbacks_ = callbacks;

  std::vector<btav_a2dp_codec_config_t> codec_priorities;  // Default priorities
@@ -2759,9 +2762,10 @@ static bt_status_t init_src(
}

// Initializes the AV interface for sink mode
static bt_status_t init_sink(btav_sink_callbacks_t* callbacks) {
static bt_status_t init_sink(btav_sink_callbacks_t* callbacks,
                             int max_connected_audio_devices) {
  BTIF_TRACE_EVENT("%s", __func__);
  return btif_av_sink.Init(callbacks);
  return btif_av_sink.Init(callbacks, max_connected_audio_devices);
}

// Updates the final focus state reported by components calling this module
+2 −1
Original line number Diff line number Diff line
@@ -356,7 +356,8 @@ typedef struct {
  /**
   * Register the BtAv callbacks
   */
  bt_status_t (*init)(btav_sink_callbacks_t* callbacks);
  bt_status_t (*init)(btav_sink_callbacks_t* callbacks,
                      int max_connected_audio_devices);

  /** connect to headset */
  bt_status_t (*connect)(const RawAddress& bd_addr);
+6 −1
Original line number Diff line number Diff line
@@ -184,7 +184,12 @@ class BluetoothAvInterfaceImpl : public BluetoothAvInterface {
    if (sink_enabled_) {
      return true;
    }
    if (hal_sink_iface_->init(&av_sink_callbacks) != BT_STATUS_SUCCESS) {

    // Right now we only support one connected audio device.
    int max_connected_audio_devices = 1;
    if (hal_sink_iface_->init(&av_sink_callbacks,
                              max_connected_audio_devices) !=
        BT_STATUS_SUCCESS) {
      LOG(ERROR) << "Failed to initialize HAL A2DP sink interface";
      return false;
    }
+2 −1
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ bt_status_t FakeSourceInit(
  return BT_STATUS_SUCCESS;
}

bt_status_t FakeSinkInit(btav_sink_callbacks_t* callbacks) {
bt_status_t FakeSinkInit(btav_sink_callbacks_t* callbacks,
                         int max_connected_audio_devices) {
  return BT_STATUS_SUCCESS;
}