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

Commit 2062d7e6 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by Andre Eisenbach
Browse files

Removed A2DP_GetTrackBitsPerSample() API because it is not needed

The A2DP_GetTrackBitsPerSample() API was replaced in the past
by A2dpCodecConfig::getAudioBitsPerSample() .
 * Removed A2DP_GetTrackBitsPerSample() and related codec-specific APIs:
   - A2DP_GetTrackBitsPerSampleSbc
   - A2DP_GetTrackBitsPerSampleAac
   - A2DP_GetTrackBitsPerSampleAptx
   - A2DP_GetTrackBitsPerSampleAptxHd
   - A2DP_GetTrackBitsPerSampleLdac
     NOTE: The removed A2DP_GetTrackBitsPerSampleLdac implementation
     had a bug: a2dp_ldac_caps.bits_per_sample -> ldac_cie.bits_per_sample
     This bug itself was uncovered when switching to clang-3960126
   - A2DP_VendorGetTrackBitsPerSample()
 * Replaced few leftover usages of A2DP_GetTrackBitsPerSample()
   A2dpCodecConfig::getAudioBitsPerSample()
 * Updated the unit tests

Test: Code compilation, unit tests, A2DP streaming
Bug: 37752547
Change-Id: I7feeda0f32922b8ef888b157673e3e2ade98b179
parent d9890e5c
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -368,22 +368,6 @@ int A2DP_GetTrackSampleRateAac(const uint8_t* p_codec_info) {
  return -1;
}

int A2DP_GetTrackBitsPerSampleAac(const uint8_t* p_codec_info) {
  tA2DP_AAC_CIE aac_cie;

  // Check whether the codec info contains valid data
  tA2DP_STATUS a2dp_status = A2DP_ParseInfoAac(&aac_cie, p_codec_info, false);
  if (a2dp_status != A2DP_SUCCESS) {
    LOG_ERROR(LOG_TAG, "%s: cannot decode codec information: %d", __func__,
              a2dp_status);
    return -1;
  }

  // NOTE: Hard-coded value - currently the AAC encoder library
  // is compiled with 16 bits per sample
  return 16;
}

int A2DP_GetTrackChannelCountAac(const uint8_t* p_codec_info) {
  tA2DP_AAC_CIE aac_cie;

+0 −20
Original line number Diff line number Diff line
@@ -1053,26 +1053,6 @@ int A2DP_GetTrackSampleRate(const uint8_t* p_codec_info) {
  return -1;
}

int A2DP_GetTrackBitsPerSample(const uint8_t* p_codec_info) {
  tA2DP_CODEC_TYPE codec_type = A2DP_GetCodecType(p_codec_info);

  LOG_VERBOSE(LOG_TAG, "%s: codec_type = 0x%x", __func__, codec_type);

  switch (codec_type) {
    case A2DP_MEDIA_CT_SBC:
      return A2DP_GetTrackBitsPerSampleSbc(p_codec_info);
    case A2DP_MEDIA_CT_AAC:
      return A2DP_GetTrackBitsPerSampleAac(p_codec_info);
    case A2DP_MEDIA_CT_NON_A2DP:
      return A2DP_VendorGetTrackBitsPerSample(p_codec_info);
    default:
      break;
  }

  LOG_ERROR(LOG_TAG, "%s: unsupported codec type 0x%x", __func__, codec_type);
  return -1;
}

int A2DP_GetTrackChannelCount(const uint8_t* p_codec_info) {
  tA2DP_CODEC_TYPE codec_type = A2DP_GetCodecType(p_codec_info);

+0 −13
Original line number Diff line number Diff line
@@ -519,19 +519,6 @@ int A2DP_GetTrackSampleRateSbc(const uint8_t* p_codec_info) {
  return -1;
}

int A2DP_GetTrackBitsPerSampleSbc(const uint8_t* p_codec_info) {
  tA2DP_SBC_CIE sbc_cie;

  tA2DP_STATUS a2dp_status = A2DP_ParseInfoSbc(&sbc_cie, p_codec_info, false);
  if (a2dp_status != A2DP_SUCCESS) {
    LOG_ERROR(LOG_TAG, "%s: cannot decode codec information: %d", __func__,
              a2dp_status);
    return -1;
  }

  return 16;  // For SBC we always use 16 bits per audio sample
}

int A2DP_GetTrackChannelCountSbc(const uint8_t* p_codec_info) {
  tA2DP_SBC_CIE sbc_cie;

+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ static void a2dp_sbc_encoder_update(uint16_t peer_mtu,
  tA2DP_FEEDING_PARAMS* p_feeding_params = &a2dp_sbc_encoder_cb.feeding_params;
  p_feeding_params->sample_rate = A2DP_GetTrackSampleRateSbc(p_codec_info);
  p_feeding_params->bits_per_sample =
      A2DP_GetTrackBitsPerSampleSbc(p_codec_info);
      a2dp_codec_config->getAudioBitsPerSample();
  p_feeding_params->channel_count = A2DP_GetTrackChannelCountSbc(p_codec_info);
  LOG_DEBUG(LOG_TAG, "%s: sample_rate=%u bits_per_sample=%u channel_count=%u",
            __func__, p_feeding_params->sample_rate,
+0 −26
Original line number Diff line number Diff line
@@ -313,32 +313,6 @@ int A2DP_VendorGetTrackSampleRate(const uint8_t* p_codec_info) {
  return -1;
}

int A2DP_VendorGetTrackBitsPerSample(const uint8_t* p_codec_info) {
  uint32_t vendor_id = A2DP_VendorCodecGetVendorId(p_codec_info);
  uint16_t codec_id = A2DP_VendorCodecGetCodecId(p_codec_info);

  // Check for aptX
  if (vendor_id == A2DP_APTX_VENDOR_ID &&
      codec_id == A2DP_APTX_CODEC_ID_BLUETOOTH) {
    return A2DP_VendorGetTrackBitsPerSampleAptx(p_codec_info);
  }

  // Check for aptX-HD
  if (vendor_id == A2DP_APTX_HD_VENDOR_ID &&
      codec_id == A2DP_APTX_HD_CODEC_ID_BLUETOOTH) {
    return A2DP_VendorGetTrackBitsPerSampleAptxHd(p_codec_info);
  }

  // Check for LDAC
  if (vendor_id == A2DP_LDAC_VENDOR_ID && codec_id == A2DP_LDAC_CODEC_ID) {
    return A2DP_VendorGetTrackBitsPerSampleLdac(p_codec_info);
  }

  // Add checks based on <vendor_id, codec_id>

  return -1;
}

int A2DP_VendorGetTrackChannelCount(const uint8_t* p_codec_info) {
  uint32_t vendor_id = A2DP_VendorCodecGetVendorId(p_codec_info);
  uint16_t codec_id = A2DP_VendorCodecGetCodecId(p_codec_info);
Loading