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

Commit 0784059d authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Automerger Merge Worker
Browse files

Merge "Pass sink metadata to Bluetooth" am: e3c3fdae

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

Change-Id: I7f9a47be30f454aa2416ce5706a7d73c72d60156
parents 04e6eab5 e3c3fdae
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -535,6 +535,21 @@ void BluetoothAudioPort::UpdateMetadata(
                                                         source_metadata);
}

void BluetoothAudioPort::UpdateSinkMetadata(
    const sink_metadata* sink_metadata) const {
  if (!in_use()) {
    LOG(ERROR) << __func__ << ": BluetoothAudioPort is not in use";
    return;
  }
  LOG(DEBUG) << __func__ << ": session_type=" << toString(session_type_)
             << ", cookie=" << StringPrintf("%#hx", cookie_)
             << ", state=" << state_ << ", " << sink_metadata->track_count
             << " track(s)";
  if (sink_metadata->track_count == 0) return;
  BluetoothAudioSessionControl_2_2::UpdateSinkMetadata(session_type_,
                                                       sink_metadata);
}

BluetoothStreamState BluetoothAudioPort::GetState() const { return state_; }

void BluetoothAudioPort::SetState(BluetoothStreamState state) {
+2 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ class BluetoothAudioPort {
  // source has been changed.
  void UpdateMetadata(const source_metadata* source_metadata) const;

  void UpdateSinkMetadata(const sink_metadata* sink_metadata) const;

  // Return the current BluetoothStreamState
  BluetoothStreamState GetState() const;

+9 −2
Original line number Diff line number Diff line
@@ -1143,9 +1143,16 @@ static int in_set_microphone_field_dimension(

static void in_update_sink_metadata(struct audio_stream_in* stream,
                                    const struct sink_metadata* sink_metadata) {
  LOG(INFO) << __func__;
  if (sink_metadata == nullptr || sink_metadata->track_count == 0) {
    return;
  }

  const auto* in = reinterpret_cast<const BluetoothStreamIn*>(stream);
  LOG(VERBOSE) << __func__
               << ": NOT HANDLED! state=" << in->bluetooth_input_.GetState();
  LOG(INFO) << __func__ << ": state=" << in->bluetooth_input_.GetState() << ", "
            << sink_metadata->track_count << " track(s)";

  in->bluetooth_input_.UpdateSinkMetadata(sink_metadata);
}

int adev_open_input_stream(struct audio_hw_device* dev,
+12 −3
Original line number Diff line number Diff line
@@ -17,14 +17,15 @@
#define LOG_TAG "BTAudioClientIf"

#include "client_interface.h"
#include "hal_version_manager.h"

#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioPort.h>
#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioPort.h>
#include <base/logging.h>
#include <hidl/MQDescriptor.h>

#include <future>

#include "common/stop_watch_legacy.h"
#include "hal_version_manager.h"
#include "osi/include/log.h"

namespace bluetooth {
@@ -33,8 +34,9 @@ namespace audio {
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::audio::common::V5_0::SinkMetadata;
using ::android::hardware::audio::common::V5_0::SourceMetadata;
using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
using ::bluetooth::common::StopWatchLegacy;

using DataMQ = ::android::hardware::MessageQueue<
@@ -156,6 +158,13 @@ class BluetoothAudioPortImpl : public IBluetoothAudioPort {
    return Void();
  }

  Return<void> updateSinkMetadata(const SinkMetadata& sinkMetadata) override {
    StopWatchLegacy stop_watch(__func__);
    LOG(INFO) << __func__ << ": " << sinkMetadata.tracks.size() << " track(s)";
    // TODO: pass the metadata up to transport_instance and LE Audio
    return Void();
  }

 private:
  IBluetoothTransportInstance* transport_instance_;
  const android::sp<IBluetoothAudioProvider> provider_;
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
namespace bluetooth {
namespace audio {

using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
using AudioCapabilities =
    ::android::hardware::bluetooth::audio::V2_0::AudioCapabilities;
using AudioCapabilities_2_1 =