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

Commit 28e51040 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add updateTrackMetadata support with audioSerssion_2_2 control" am: 5ad2fe45

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1955919

Change-Id: If2765c7f9c4dd7ca3dac29703a3e8d69bbc8ced5
parents 23040264 5ad2fe45
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -761,6 +761,13 @@ void HidlToAidlMiddleware_2_2::StopStream(const SessionType_2_1& session_type) {
      from_session_type_2_1(session_type));
}

void HidlToAidlMiddleware_2_2::UpdateTracksMetadata(
    const SessionType_2_1& session_type,
    const struct source_metadata* source_metadata) {
  return BluetoothAudioSessionControl::UpdateSourceMetadata(
      from_session_type_2_1(session_type), *source_metadata);
}

void HidlToAidlMiddleware_2_2::UpdateSinkMetadata(
    const SessionType_2_1& session_type,
    const struct sink_metadata* sink_metadata) {
+4 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ class HidlToAidlMiddleware_2_2 {

  static void StopStream(const SessionType_2_1& session_type);

  static void UpdateTracksMetadata(
      const SessionType_2_1& session_type,
      const struct source_metadata* source_metadata);

  static void UpdateSinkMetadata(const SessionType_2_1& session_type,
                                 const struct sink_metadata* sink_metadata);
};
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ class BluetoothAudioSessionControl_2_2 {
    std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
        BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
    if (session_ptr != nullptr) {
      session_ptr->GetAudioSession()->UpdateTracksMetadata(source_metadata);
      session_ptr->UpdateTracksMetadata(source_metadata);
    }
  }

+51 −0
Original line number Diff line number Diff line
@@ -31,9 +31,13 @@ namespace audio {

using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_0;
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_2;
using ::android::hardware::audio::common::V5_0::AudioContentType;
using ::android::hardware::audio::common::V5_0::AudioSource;
using ::android::hardware::audio::common::V5_0::AudioUsage;
using ::android::hardware::audio::common::V5_0::PlaybackTrackMetadata;
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
using ::android::hardware::audio::common::V5_0::SinkMetadata;
using ::android::hardware::audio::common::V5_0::SourceMetadata;
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration;
@@ -128,6 +132,53 @@ BluetoothAudioSession_2_2::GetAudioSession_2_1() {
  return audio_session_2_1;
}

void BluetoothAudioSession_2_2::UpdateTracksMetadata(
    const struct source_metadata* source_metadata) {
  if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
    return HidlToAidlMiddleware_2_2::UpdateTracksMetadata(raw_session_type_,
                                                          source_metadata);
  std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
  if (!IsSessionReady()) {
    LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
               << " has NO session";
    return;
  }

  ssize_t track_count = source_metadata->track_count;
  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
            << ", " << track_count << " track(s)";

  if (session_type_2_1_ == SessionType_2_1::UNKNOWN) {
    audio_session->UpdateTracksMetadata(source_metadata);
    return;
  }

  struct playback_track_metadata* track = source_metadata->tracks;
  SourceMetadata sourceMetadata;
  PlaybackTrackMetadata* halMetadata;

  sourceMetadata.tracks.resize(track_count);
  halMetadata = sourceMetadata.tracks.data();
  while (track_count && track) {
    halMetadata->usage = static_cast<AudioUsage>(track->usage);
    halMetadata->contentType =
        static_cast<AudioContentType>(track->content_type);
    halMetadata->gain = track->gain;
    LOG(VERBOSE) << __func__ << " - SessionType=" << toString(session_type_2_1_)
                 << ", usage=" << toString(halMetadata->usage)
                 << ", content=" << toString(halMetadata->contentType)
                 << ", gain=" << halMetadata->gain;
    --track_count;
    ++track;
    ++halMetadata;
  }
  auto hal_retval = audio_session->stack_iface_->updateMetadata(sourceMetadata);
  if (!hal_retval.isOk()) {
    LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
                 << toString(session_type_2_1_) << " failed";
  }
}

void BluetoothAudioSession_2_2::UpdateSinkMetadata(
    const struct sink_metadata* sink_metadata) {
  if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+1 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ class BluetoothAudioSession_2_2 {
  const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
  GetAudioConfig();

  void UpdateTracksMetadata(const struct source_metadata* source_metadata);
  void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);

  static constexpr ::android::hardware::bluetooth::audio::V2_2::