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

Commit 8006ec2c authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

stack/a2dp: Remove more unused functions am: c0337eef

parents 6b76dfde c0337eef
Loading
Loading
Loading
Loading
+1 −26
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ const char* A2DP_CodecIndexStrAac(void) { return "AAC"; }

const char* A2DP_CodecIndexStrAacSink(void) { return "AAC SINK"; }

void aac_source_caps_initialize() {
static void aac_source_caps_initialize() {
  if (aac_source_caps_configured) {
    return;
  }
@@ -703,31 +703,6 @@ bool A2DP_InitCodecConfigAacSink(AvdtpSepConfig* p_cfg) {
         A2DP_SUCCESS;
}

UNUSED_ATTR static void build_codec_config(const tA2DP_AAC_CIE& config_cie,
                                           btav_a2dp_codec_config_t* result) {
  if (config_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_44100) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_44100;
  }
  if (config_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_48000) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_48000;
  }
  if (config_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_88200) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_88200;
  }
  if (config_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_96000) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_96000;
  }

  result->bits_per_sample = config_cie.bits_per_sample;

  if (config_cie.channelMode & A2DP_AAC_CHANNEL_MODE_MONO) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_MONO;
  }
  if (config_cie.channelMode & A2DP_AAC_CHANNEL_MODE_STEREO) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
  }
}

A2dpCodecConfigAacSource::A2dpCodecConfigAacSource(btav_a2dp_codec_priority_t codec_priority)
    : A2dpCodecConfigAacBase(BTAV_A2DP_CODEC_INDEX_SOURCE_AAC, A2DP_CodecIndexStrAac(),
                             codec_priority, true) {
+0 −57
Original line number Diff line number Diff line
@@ -115,8 +115,6 @@ static const tA2DP_DECODER_INTERFACE a2dp_decoder_interface_sbc = {
static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc(const tA2DP_SBC_CIE* p_cap,
                                                       const uint8_t* p_codec_info,
                                                       bool is_capability);
static void A2DP_ParseMplHeaderSbc(uint8_t* p_src, bool* p_frag, bool* p_start, bool* p_last,
                                   uint8_t* p_num);

// Builds the SBC Media Codec Capabilities byte sequence beginning from the
// LOSC octet. |media_type| is the media type |AVDT_MEDIA_TYPE_*|.
@@ -266,40 +264,6 @@ static void A2DP_BuildMediaPayloadHeaderSbc(uint8_t* p_dst, bool frag, bool star
  *p_dst |= (A2DP_SBC_HDR_NUM_MSK & num);
}

/******************************************************************************
 *
 * Function         A2DP_ParseMplHeaderSbc
 *
 * Description      This function is called by an application to parse
 *                  the SBC Media Payload header.
 *                  Input Parameters:
 *                      p_src:  the byte sequence to parse..
 *
 *                  Output Parameters:
 *                      frag:  1, if fragmented. 0, otherwise.
 *
 *                      start:  1, if the starting packet of a fragmented frame.
 *
 *                      last:  1, if the last packet of a fragmented frame.
 *
 *                      num:  If frag is 1, this is the number of remaining
 *                            fragments
 *                            (including this fragment) of this frame.
 *                            If frag is 0, this is the number of frames in
 *                            this packet.
 *
 * Returns          void.
 *****************************************************************************/
UNUSED_ATTR static void A2DP_ParseMplHeaderSbc(uint8_t* p_src, bool* p_frag, bool* p_start,
                                               bool* p_last, uint8_t* p_num) {
  if (p_src && p_frag && p_start && p_last && p_num) {
    *p_frag = (*p_src & A2DP_SBC_HDR_F_MSK) ? true : false;
    *p_start = (*p_src & A2DP_SBC_HDR_S_MSK) ? true : false;
    *p_last = (*p_src & A2DP_SBC_HDR_L_MSK) ? true : false;
    *p_num = (*p_src & A2DP_SBC_HDR_NUM_MSK);
  }
}

const char* A2DP_CodecNameSbc(const uint8_t* /* p_codec_info */) { return "SBC"; }

bool A2DP_IsCodecValidSbc(const uint8_t* p_codec_info) {
@@ -825,27 +789,6 @@ bool A2DP_InitCodecConfigSbcSink(AvdtpSepConfig* p_cfg) {
  return true;
}

UNUSED_ATTR static void build_codec_config(const tA2DP_SBC_CIE& config_cie,
                                           btav_a2dp_codec_config_t* result) {
  if (config_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_44) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_44100;
  }
  if (config_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_48) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_48000;
  }

  result->bits_per_sample = config_cie.bits_per_sample;

  if (config_cie.ch_mode & A2DP_SBC_IE_CH_MD_MONO) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_MONO;
  }

  if (config_cie.ch_mode &
      (A2DP_SBC_IE_CH_MD_STEREO | A2DP_SBC_IE_CH_MD_JOINT | A2DP_SBC_IE_CH_MD_DUAL)) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
  }
}

A2dpCodecConfigSbcSource::A2dpCodecConfigSbcSource(btav_a2dp_codec_priority_t codec_priority)
    : A2dpCodecConfigSbcBase(BTAV_A2DP_CODEC_INDEX_SOURCE_SBC, A2DP_CodecIndexStrSbc(),
                             codec_priority, true) {
+0 −44
Original line number Diff line number Diff line
@@ -81,10 +81,6 @@ static const tA2DP_ENCODER_INTERFACE a2dp_encoder_interface_aptx = {
        nullptr  // set_transmit_queue_length
};

static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx(const tA2DP_APTX_CIE* p_cap,
                                                        const uint8_t* p_codec_info,
                                                        bool is_peer_codec_info);

// Builds the aptX Media Codec Capabilities byte sequence beginning from the
// LOSC octet. |media_type| is the media type |AVDT_MEDIA_TYPE_*|.
// |p_ie| is a pointer to the aptX Codec Information Element information.
@@ -185,46 +181,6 @@ bool A2DP_IsCodecValidAptx(const uint8_t* p_codec_info) {
         (A2DP_ParseInfoAptx(&cfg_cie, p_codec_info, true) == A2DP_SUCCESS);
}

// Checks whether A2DP aptX codec configuration matches with a device's codec
// capabilities. |p_cap| is the aptX codec configuration. |p_codec_info| is
// the device's codec capabilities.
// If |is_capability| is true, the byte sequence is codec capabilities,
// otherwise is codec configuration.
// |p_codec_info| contains the codec capabilities for a peer device that
// is acting as an A2DP source.
// Returns A2DP_SUCCESS if the codec configuration matches with capabilities,
// otherwise the corresponding A2DP error status code.
UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx(const tA2DP_APTX_CIE* p_cap,
                                                                    const uint8_t* p_codec_info,
                                                                    bool is_capability) {
  tA2DP_STATUS status;
  tA2DP_APTX_CIE cfg_cie;

  /* parse configuration */
  status = A2DP_ParseInfoAptx(&cfg_cie, p_codec_info, is_capability);
  if (status != A2DP_SUCCESS) {
    log::error("parsing failed {}", status);
    return status;
  }

  /* verify that each parameter is in range */

  log::verbose("FREQ peer: 0x{:x}, capability 0x{:x}", cfg_cie.sampleRate, p_cap->sampleRate);
  log::verbose("CH_MODE peer: 0x{:x}, capability 0x{:x}", cfg_cie.channelMode, p_cap->channelMode);

  /* sampling frequency */
  if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) {
    return A2DP_NS_SAMP_FREQ;
  }

  /* channel mode */
  if ((cfg_cie.channelMode & p_cap->channelMode) == 0) {
    return A2DP_NS_CH_MODE;
  }

  return A2DP_SUCCESS;
}

bool A2DP_VendorUsesRtpHeaderAptx(bool /* content_protection_enabled */,
                                  const uint8_t* /* p_codec_info */) {
  // no RTP header for aptX classic and no Copy Protection byte
+0 −43
Original line number Diff line number Diff line
@@ -88,10 +88,6 @@ static const tA2DP_ENCODER_INTERFACE a2dp_encoder_interface_aptx_hd = {
        nullptr  // set_transmit_queue_length
};

static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd(const tA2DP_APTX_HD_CIE* p_cap,
                                                          const uint8_t* p_codec_info,
                                                          bool is_peer_codec_info);

// Builds the aptX-HD Media Codec Capabilities byte sequence beginning from the
// LOSC octet. |media_type| is the media type |AVDT_MEDIA_TYPE_*|.
// |p_ie| is a pointer to the aptX-HD Codec Information Element information.
@@ -202,45 +198,6 @@ bool A2DP_IsCodecValidAptxHd(const uint8_t* p_codec_info) {
         (A2DP_ParseInfoAptxHd(&cfg_cie, p_codec_info, true) == A2DP_SUCCESS);
}

// Checks whether A2DP aptX-HD codec configuration matches with a device's
// codec capabilities. |p_cap| is the aptX-HD codec configuration.
// |p_codec_info| is the device's codec capabilities.
// If |is_capability| is true, the byte sequence is codec capabilities,
// otherwise is codec configuration.
// |p_codec_info| contains the codec capabilities for a peer device that
// is acting as an A2DP source.
// Returns A2DP_SUCCESS if the codec configuration matches with capabilities,
// otherwise the corresponding A2DP error status code.
UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd(
        const tA2DP_APTX_HD_CIE* p_cap, const uint8_t* p_codec_info, bool is_capability) {
  tA2DP_STATUS status;
  tA2DP_APTX_HD_CIE cfg_cie;

  /* parse configuration */
  status = A2DP_ParseInfoAptxHd(&cfg_cie, p_codec_info, is_capability);
  if (status != A2DP_SUCCESS) {
    log::error("parsing failed {}", status);
    return status;
  }

  /* verify that each parameter is in range */

  log::verbose("FREQ peer: 0x{:x}, capability 0x{:x}", cfg_cie.sampleRate, p_cap->sampleRate);
  log::verbose("CH_MODE peer: 0x{:x}, capability 0x{:x}", cfg_cie.channelMode, p_cap->channelMode);

  /* sampling frequency */
  if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) {
    return A2DP_NS_SAMP_FREQ;
  }

  /* channel mode */
  if ((cfg_cie.channelMode & p_cap->channelMode) == 0) {
    return A2DP_NS_CH_MODE;
  }

  return A2DP_SUCCESS;
}

bool A2DP_VendorUsesRtpHeaderAptxHd(bool /* content_protection_enabled */,
                                    const uint8_t* /* p_codec_info */) {
  return true;
+0 −31
Original line number Diff line number Diff line
@@ -605,37 +605,6 @@ bool A2DP_VendorInitCodecConfigLdacSink(AvdtpSepConfig* p_cfg) {
         A2DP_SUCCESS;
}

UNUSED_ATTR static void build_codec_config(const tA2DP_LDAC_CIE& config_cie,
                                           btav_a2dp_codec_config_t* result) {
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_44100) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_44100;
  }
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_48000) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_48000;
  }
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_88200) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_88200;
  }
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_96000) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_96000;
  }
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_176400) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_176400;
  }
  if (config_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_192000) {
    result->sample_rate |= BTAV_A2DP_CODEC_SAMPLE_RATE_192000;
  }

  result->bits_per_sample = config_cie.bits_per_sample;

  if (config_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_MONO) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_MONO;
  }
  if (config_cie.channelMode & (A2DP_LDAC_CHANNEL_MODE_DUAL | A2DP_LDAC_CHANNEL_MODE_STEREO)) {
    result->channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
  }
}

A2dpCodecConfigLdacSource::A2dpCodecConfigLdacSource(btav_a2dp_codec_priority_t codec_priority)
    : A2dpCodecConfigLdacBase(BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC, A2DP_VendorCodecIndexStrLdac(),
                              codec_priority, true) {
Loading