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

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

Add missing codec initialization for A2DP Sink

Also:
 * Added missing assert to check when local codecs are not initialized
 * Removed unnecessary local copy: BtifAvSource::codec_priorities_

Bug: 74079615
Test: Manual: Enable A2DP Sink profile and initiate the connection from
      Remote A2DP Source
Change-Id: I40ea1aa2164612bbe108ac06be7f6cae8be30a72
(cherry picked from commit b27aa7ebbf373fe2ddc4d75a19d02c7b3ea5359e)
parent 6ff95b64
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1484,8 +1484,10 @@ bool BtaAvCo::ReportSourceCodecState(BtaAvCoPeer* p_peer) {

  APPL_TRACE_DEBUG("%s: peer_address=%s", __func__,
                   p_peer->addr.ToString().c_str());
  if (!p_peer->GetCodecs()->getCodecConfigAndCapabilities(
          &codec_config, &codecs_local_capabilities,
  A2dpCodecs* codecs = p_peer->GetCodecs();
  CHECK(codecs != nullptr);
  if (!codecs->getCodecConfigAndCapabilities(&codec_config,
                                             &codecs_local_capabilities,
                                             &codecs_selectable_capabilities)) {
    APPL_TRACE_WARNING(
        "%s: Peer %s : error reporting audio source codec state: "
+8 −6
Original line number Diff line number Diff line
@@ -341,12 +341,12 @@ class BtifAvSource {
        max_connected_peers_(kDefaultMaxConnectedAudioDevices) {}
  ~BtifAvSource();

  btav_source_callbacks_t* Callbacks() { return callbacks_; }
  bt_status_t Init(
      btav_source_callbacks_t* callbacks, int max_connected_audio_devices,
      const std::vector<btav_a2dp_codec_config_t>& codec_priorities);
  void Cleanup();

  btav_source_callbacks_t* Callbacks() { return callbacks_; }
  bool Enabled() const { return enabled_; }
  bool A2dpOffloadEnabled() const { return a2dp_offload_enabled_; }

@@ -447,7 +447,6 @@ class BtifAvSource {
  std::map<RawAddress, BtifAvPeer*> peers_;
  RawAddress active_peer_;
  std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_;
  std::vector<btav_a2dp_codec_config_t> codec_priorities_;
};

class BtifAvSink {
@@ -461,12 +460,13 @@ class BtifAvSink {
        enabled_(false),
        max_connected_peers_(kDefaultMaxConnectedAudioDevices) {}
  ~BtifAvSink();
  bt_status_t Init(btav_sink_callbacks_t* callbacks);

  btav_sink_callbacks_t* Callbacks() { return callbacks_; }
  bt_status_t Init(btav_sink_callbacks_t* callbacks);
  void Cleanup();

  btav_sink_callbacks_t* Callbacks() { return callbacks_; }
  bool Enabled() const { return enabled_; }

  BtifAvPeer* FindPeer(const RawAddress& peer_address);
  BtifAvPeer* FindPeerByHandle(tBTA_AV_HNDL bta_handle);
  BtifAvPeer* FindPeerByPeerId(uint8_t peer_id);
@@ -863,8 +863,7 @@ bt_status_t BtifAvSource::Init(
  BTIF_TRACE_DEBUG("a2dp_offload.enable = %d", a2dp_offload_enabled_);

  callbacks_ = callbacks;
  codec_priorities_ = codec_priorities;
  bta_av_co_init(codec_priorities_);
  bta_av_co_init(codec_priorities);

  if (!btif_a2dp_source_init()) {
    return BT_STATUS_FAIL;
@@ -1041,6 +1040,9 @@ bt_status_t BtifAvSink::Init(btav_sink_callbacks_t* callbacks) {
  max_connected_peers_ = kDefaultMaxConnectedAudioDevices;
  callbacks_ = callbacks;

  std::vector<btav_a2dp_codec_config_t> codec_priorities;  // Default priorities
  bta_av_co_init(codec_priorities);

  if (!btif_a2dp_sink_init()) {
    return BT_STATUS_FAIL;
  }