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

Commit 22861fa0 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Pass sink metadata to Bluetooth

When just microphone is enabled, i.e. for recording audio, we will
receive just sink metadata update.

Bug: 150670922
Change-Id: I7394a077e1c161677191b587f0e94ad2c5520d2d
parent d10b0b4b
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 =