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

Commit 83b7ecea authored by Henri Chataing's avatar Henri Chataing
Browse files

audio_hal_interface: Provide the preferred encoding interval

Adds the dataIntervalUs to the pcmConfig used for a2dp software
path. This value will inform the audio framework.

Bug: 336658618
Bug: 347781402
Test: m com.android.btservices
Test: Manual streaming test on pixel 6a
Flag: bluetooth.a2dp_aidl_encoding_interval
Change-Id: Ib80558184e094b801066bd1a4d7477dd9315382c
parent b9ee7a34
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -386,6 +386,11 @@ bool a2dp_get_selected_hal_pcm_config(PcmConfiguration* pcm_config) {
  pcm_config->sampleRateHz = A2dpCodecToHalSampleRate(current_codec);
  pcm_config->bitsPerSample = A2dpCodecToHalBitsPerSample(current_codec);
  pcm_config->channelMode = A2dpCodecToHalChannelMode(current_codec);

  if (com::android::bluetooth::flags::a2dp_aidl_encoding_interval()) {
    pcm_config->dataIntervalUs = bta_av_co_get_encoder_preferred_interval_us();
  }

  return (pcm_config->sampleRateHz > 0 && pcm_config->bitsPerSample > 0 &&
          pcm_config->channelMode != ChannelMode::UNKNOWN);
}
+9 −0
Original line number Diff line number Diff line
@@ -1001,6 +1001,11 @@ int BtaAvCo::GetSourceEncoderEffectiveFrameSize() {
      bta_av_legacy_state_.getCodecConfig());
}

int BtaAvCo::GetSourceEncoderPreferredIntervalUs() {
  const tA2DP_ENCODER_INTERFACE* encoder = GetSourceEncoderInterface();
  return encoder == nullptr ? 0 : encoder->get_encoder_interval_ms() * 1000;
}

bool BtaAvCo::ReportSourceCodecState(BtaAvCoPeer* p_peer) {
  btav_a2dp_codec_config_t codec_config = {
    .codec_type = BTAV_A2DP_CODEC_INDEX_SINK_MAX,
@@ -1686,6 +1691,10 @@ int bta_av_co_get_encoder_effective_frame_size() {
  return bta_av_co_cb.GetSourceEncoderEffectiveFrameSize();
}

int bta_av_co_get_encoder_preferred_interval_us() {
  return bta_av_co_cb.GetSourceEncoderPreferredIntervalUs();
}

btav_a2dp_scmst_info_t bta_av_co_get_scmst_info(
    const RawAddress& peer_address) {
  BtaAvCoPeer* p_peer = bta_av_co_cb.peer_cache_->FindPeer(peer_address);
+7 −0
Original line number Diff line number Diff line
@@ -345,6 +345,13 @@ class BtaAvCo {
   */
  int GetSourceEncoderEffectiveFrameSize();

  /**
   * Get the Source encoder preferred encoding interval.
   *
   * @return the preferred encoding interval for the current codec
   */
  int GetSourceEncoderPreferredIntervalUs();

  /**
   * Report the source codec state for a peer
   *
+5 −0
Original line number Diff line number Diff line
@@ -98,6 +98,11 @@ A2dpCodecConfig* bta_av_get_a2dp_peer_current_codec(
// Returns the effective frame size if the encoder is configured, otherwise 0.
int bta_av_co_get_encoder_effective_frame_size();

// Gets the preferred encoding interval from the current encoder.
// Returns the preferred encoding interval if the encoder is configured,
// otherwise 0.
int bta_av_co_get_encoder_preferred_interval_us();

// Dump A2DP codec debug-related information for the A2DP module.
// |fd| is the file descriptor to use for writing the ASCII formatted
// information.