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

Commit 21e8b420 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Bluetooth LE Audio: pass the 24 bit stream as unpacked through HAL"...

Merge "Bluetooth LE Audio: pass the 24 bit stream as unpacked through HAL" into tm-dev am: dd935193 am: f789e5f6

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/18197542



Change-Id: Ic3abe0d848f790bcfc6c7c76a9d478aa74196acb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 83623fb6 f789e5f6
Loading
Loading
Loading
Loading
+17 −4
Original line number Original line Diff line number Diff line
@@ -70,12 +70,23 @@ audio_channel_mask_t InputChannelModeToAudioFormat(ChannelMode channel_mode) {
  }
  }
}
}


audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample) {
audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample,
                                          const SessionType& session_type) {
  switch (bits_per_sample) {
  switch (bits_per_sample) {
    case 16:
    case 16:
      return AUDIO_FORMAT_PCM_16_BIT;
      return AUDIO_FORMAT_PCM_16_BIT;
    case 24:
    case 24:
      /* Now we use knowledge that Classic sessions used packed, and LE Audio
       * LC3 encoder uses unpacked as input. This should be passed as parameter
       * from BT stack through AIDL, but it would require new interface version,
       * so sticking with this workaround for now. */
      if (session_type ==
              SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
          session_type == SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH) {
        return AUDIO_FORMAT_PCM_24_BIT_PACKED;
        return AUDIO_FORMAT_PCM_24_BIT_PACKED;
      } else {
        return AUDIO_FORMAT_PCM_8_24_BIT;
      }
    case 32:
    case 32:
      return AUDIO_FORMAT_PCM_32_BIT;
      return AUDIO_FORMAT_PCM_32_BIT;
    default:
    default:
@@ -354,7 +365,8 @@ bool BluetoothAudioPortAidlOut::LoadAudioConfig(
      (is_stereo_to_mono_
      (is_stereo_to_mono_
           ? AUDIO_CHANNEL_OUT_STEREO
           ? AUDIO_CHANNEL_OUT_STEREO
           : OutputChannelModeToAudioFormat(pcm_cfg.channelMode));
           : OutputChannelModeToAudioFormat(pcm_cfg.channelMode));
  audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample);
  audio_cfg->format =
      BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_);
  return true;
  return true;
}
}


@@ -388,7 +400,8 @@ bool BluetoothAudioPortAidlIn::LoadAudioConfig(


  audio_cfg->sample_rate = pcm_cfg.sampleRateHz;
  audio_cfg->sample_rate = pcm_cfg.sampleRateHz;
  audio_cfg->channel_mask = InputChannelModeToAudioFormat(pcm_cfg.channelMode);
  audio_cfg->channel_mask = InputChannelModeToAudioFormat(pcm_cfg.channelMode);
  audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample);
  audio_cfg->format =
      BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_);
  return true;
  return true;
}
}


+3 −0
Original line number Original line Diff line number Diff line
@@ -465,6 +465,9 @@ static char* out_get_parameters(const struct audio_stream* stream,
    if (audio_cfg.format == AUDIO_FORMAT_PCM_24_BIT_PACKED) {
    if (audio_cfg.format == AUDIO_FORMAT_PCM_24_BIT_PACKED) {
      param = "AUDIO_FORMAT_PCM_24_BIT_PACKED";
      param = "AUDIO_FORMAT_PCM_24_BIT_PACKED";
    }
    }
    if (audio_cfg.format == AUDIO_FORMAT_PCM_8_24_BIT) {
      param = "AUDIO_FORMAT_PCM_8_24_BIT";
    }
    if (audio_cfg.format == AUDIO_FORMAT_PCM_32_BIT) {
    if (audio_cfg.format == AUDIO_FORMAT_PCM_32_BIT) {
      param = "AUDIO_FORMAT_PCM_32_BIT";
      param = "AUDIO_FORMAT_PCM_32_BIT";
    }
    }
+6 −2
Original line number Original line Diff line number Diff line
@@ -82,10 +82,14 @@ bool LeAudioClientAudioSource::SinkOnResumeReq(bool start_media_task) {
}
}


void LeAudioClientAudioSource::SendAudioData() {
void LeAudioClientAudioSource::SendAudioData() {
  // 24 bit audio is aligned to 32bit
  int bytes_per_sample = (source_codec_config_.bits_per_sample == 24)
                             ? 4
                             : (source_codec_config_.bits_per_sample / 8);

  uint32_t bytes_per_tick =
  uint32_t bytes_per_tick =
      (source_codec_config_.num_channels * source_codec_config_.sample_rate *
      (source_codec_config_.num_channels * source_codec_config_.sample_rate *
       source_codec_config_.data_interval_us / 1000 *
       source_codec_config_.data_interval_us / 1000 * bytes_per_sample) /
       (source_codec_config_.bits_per_sample / 8)) /
      1000;
      1000;


  std::vector<uint8_t> data(bytes_per_tick);
  std::vector<uint8_t> data(bytes_per_tick);
+2 −1
Original line number Original line Diff line number Diff line
@@ -506,7 +506,8 @@ TEST_F(LeAudioClientAudioTest,
            std::future_status::ready);
            std::future_status::ready);


  // Check agains expected payload size
  // Check agains expected payload size
  const uint32_t channel_bytes_per_sample = (24 /*bps*/ / 8);
  // 24 bit audio stream is sent as unpacked, each sample takes 4 bytes.
  const uint32_t channel_bytes_per_sample = 4;
  const uint32_t channel_bytes_per_10ms_at_16000Hz =
  const uint32_t channel_bytes_per_10ms_at_16000Hz =
      ((10ms).count() * channel_bytes_per_sample * 16000 /*Hz*/) /
      ((10ms).count() * channel_bytes_per_sample * 16000 /*Hz*/) /
      (1000ms).count();
      (1000ms).count();