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

Commit 4af9bd9e authored by Qasim Javed's avatar Qasim Javed
Browse files

Fix bugs in OPUS codec wrappers.

Bug: 256013806
Tag: #refactor
Test: atest net_test_stack_a2dp_codecs_native
Ignore-AOSP-First: presubmit fails on AOSP because the OPUS codec only
exists on internal master

Change-Id: I7811e36170ff51d1e9863f2225816e5488e09054
parent f369fb0c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -100,6 +100,11 @@ bool a2dp_vendor_opus_decoder_decode_packet(BT_HDR* p_buf) {
    return false;
  }

  if (p_buf->len == 0) {
    LOG_ERROR("Empty packet");
    return false;
  }

  auto* pBuffer =
      reinterpret_cast<unsigned char*>(p_buf->data + p_buf->offset + 1);
  int32_t bufferSize = p_buf->len - 1;
+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,6 @@ static bool a2dp_vendor_opus_encoder_update(uint16_t peer_mtu,
  LOG_INFO("sample_rate=%u bits_per_sample=%u channel_count=%u",
           p_feeding_params->sample_rate, p_feeding_params->bits_per_sample,
           p_feeding_params->channel_count);
  a2dp_vendor_opus_feeding_reset();

  // The codec parameters
  p_encoder_params->sample_rate =
@@ -241,6 +240,8 @@ static bool a2dp_vendor_opus_encoder_update(uint16_t peer_mtu,
  p_encoder_params->framesize = A2DP_VendorGetFrameSizeOpus(p_codec_info);
  p_encoder_params->bitrate = A2DP_VendorGetBitRateOpus(p_codec_info);

  a2dp_vendor_opus_feeding_reset();

  uint16_t mtu_size =
      BT_DEFAULT_BUFFER_SIZE - A2DP_OPUS_OFFSET - sizeof(BT_HDR);
  if (mtu_size < peer_mtu) {