mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Pass sink metadata to Bluetooth" am: cd9bb98da1 am: 0b32a54b2a am: 4951286da9
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1907864 Change-Id: I42d12fbf09be44af086f83aa6240241a929d329c
This commit is contained in:
@@ -14,6 +14,7 @@ hidl_interface {
|
||||
root: "android.hardware",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IBluetoothAudioPort.hal",
|
||||
"IBluetoothAudioProvider.hal",
|
||||
"IBluetoothAudioProvidersFactory.hal",
|
||||
],
|
||||
|
||||
30
bluetooth/audio/2.2/IBluetoothAudioPort.hal
Normal file
30
bluetooth/audio/2.2/IBluetoothAudioPort.hal
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.bluetooth.audio@2.2;
|
||||
|
||||
import @2.0::IBluetoothAudioPort;
|
||||
import android.hardware.audio.common@5.0::SinkMetadata;
|
||||
|
||||
interface IBluetoothAudioPort extends @2.0::IBluetoothAudioPort {
|
||||
/**
|
||||
* Called when the metadata of the stream's sink has been changed.
|
||||
*
|
||||
* @param sinkMetadata Description of the audio that is recorded by the
|
||||
* clients.
|
||||
*/
|
||||
updateSinkMetadata(SinkMetadata sinkMetadata);
|
||||
};
|
||||
@@ -17,7 +17,7 @@
|
||||
package android.hardware.bluetooth.audio@2.2;
|
||||
|
||||
import @2.1::IBluetoothAudioProvider;
|
||||
import @2.0::IBluetoothAudioPort;
|
||||
import @2.2::IBluetoothAudioPort;
|
||||
import @2.0::Status;
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,7 +54,7 @@ bool A2dpOffloadAudioProvider::isValid(const V2_1::SessionType& sessionType) {
|
||||
}
|
||||
|
||||
Return<void> A2dpOffloadAudioProvider::startSession(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
|
||||
@@ -70,7 +70,7 @@ bool A2dpSoftwareAudioProvider::isValid(const V2_1::SessionType& sessionType) {
|
||||
}
|
||||
|
||||
Return<void> A2dpSoftwareAudioProvider::startSession(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
|
||||
@@ -40,7 +40,7 @@ class A2dpSoftwareAudioProvider : public BluetoothAudioProvider {
|
||||
bool isValid(const V2_1::SessionType& sessionType) override;
|
||||
bool isValid(const V2_0::SessionType& sessionType) override;
|
||||
|
||||
Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_0::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
|
||||
64
bluetooth/audio/2.2/default/AudioPort_2_0_to_2_2_Wrapper.h
Normal file
64
bluetooth/audio/2.2/default/AudioPort_2_0_to_2_2_Wrapper.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/bluetooth/audio/2.2/types.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace bluetooth {
|
||||
namespace audio {
|
||||
namespace V2_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
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_2::IBluetoothAudioPort;
|
||||
|
||||
class AudioPort_2_0_to_2_2_Wrapper : public V2_2::IBluetoothAudioPort {
|
||||
public:
|
||||
AudioPort_2_0_to_2_2_Wrapper(const sp<V2_0::IBluetoothAudioPort>& port) {
|
||||
this->port = port;
|
||||
}
|
||||
|
||||
Return<void> startStream() override { return port->startStream(); }
|
||||
Return<void> suspendStream() override { return port->suspendStream(); }
|
||||
Return<void> stopStream() override { return port->stopStream(); }
|
||||
Return<void> getPresentationPosition(
|
||||
getPresentationPosition_cb _hidl_cb) override {
|
||||
return port->getPresentationPosition(_hidl_cb);
|
||||
}
|
||||
Return<void> updateMetadata(const SourceMetadata& sourceMetadata) override {
|
||||
return port->updateMetadata(sourceMetadata);
|
||||
}
|
||||
Return<void> updateSinkMetadata(const SinkMetadata&) override {
|
||||
// DO NOTHING, 2.0 AudioPort doesn't support sink metadata updates
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<V2_0::IBluetoothAudioPort> port;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_2
|
||||
} // namespace audio
|
||||
} // namespace bluetooth
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "AudioPort_2_0_to_2_2_Wrapper.h"
|
||||
#include "BluetoothAudioSessionReport_2_2.h"
|
||||
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
|
||||
|
||||
@@ -51,7 +52,7 @@ BluetoothAudioProvider::BluetoothAudioProvider()
|
||||
audio_config_({}) {}
|
||||
|
||||
Return<void> BluetoothAudioProvider::startSession(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_0::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
AudioConfiguration audioConfig_2_2;
|
||||
|
||||
@@ -67,11 +68,13 @@ Return<void> BluetoothAudioProvider::startSession(
|
||||
audioConfig_2_2.codecConfig(audioConfig.codecConfig());
|
||||
}
|
||||
|
||||
return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
|
||||
sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
|
||||
new AudioPort_2_0_to_2_2_Wrapper(hostIf);
|
||||
return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> BluetoothAudioProvider::startSession_2_1(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_1::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
AudioConfiguration audioConfig_2_2;
|
||||
if (audioConfig.getDiscriminator() ==
|
||||
@@ -92,11 +95,13 @@ Return<void> BluetoothAudioProvider::startSession_2_1(
|
||||
audioConfig_2_2.codecConfig(audioConfig.codecConfig());
|
||||
}
|
||||
|
||||
return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
|
||||
sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
|
||||
new AudioPort_2_0_to_2_2_Wrapper(hostIf);
|
||||
return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> BluetoothAudioProvider::startSession_2_2(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
if (hostIf == nullptr) {
|
||||
_hidl_cb(BluetoothAudioStatus::FAILURE, DataMQ::Descriptor());
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace V2_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
|
||||
using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
|
||||
|
||||
using BluetoothAudioStatus =
|
||||
::android::hardware::bluetooth::audio::V2_0::Status;
|
||||
@@ -41,13 +41,13 @@ class BluetoothAudioProvider : public IBluetoothAudioProvider {
|
||||
virtual bool isValid(const V2_1::SessionType& sessionType) = 0;
|
||||
virtual bool isValid(const V2_0::SessionType& sessionType) = 0;
|
||||
|
||||
Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_0::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
Return<void> startSession_2_1(const sp<IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession_2_1(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_1::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
Return<void> startSession_2_2(const sp<IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
Return<void> streamStarted(BluetoothAudioStatus status) override;
|
||||
@@ -59,7 +59,7 @@ class BluetoothAudioProvider : public IBluetoothAudioProvider {
|
||||
|
||||
V2_1::SessionType session_type_;
|
||||
AudioConfiguration audio_config_;
|
||||
sp<V2_0::IBluetoothAudioPort> stack_iface_;
|
||||
sp<V2_2::IBluetoothAudioPort> stack_iface_;
|
||||
|
||||
virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ bool HearingAidAudioProvider::isValid(const V2_1::SessionType& sessionType) {
|
||||
}
|
||||
|
||||
Return<void> HearingAidAudioProvider::startSession(
|
||||
const sp<IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
|
||||
@@ -40,7 +40,7 @@ class HearingAidAudioProvider : public BluetoothAudioProvider {
|
||||
bool isValid(const V2_1::SessionType& sessionType) override;
|
||||
bool isValid(const V2_0::SessionType& sessionType) override;
|
||||
|
||||
Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const V2_0::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "AudioPort_2_0_to_2_2_Wrapper.h"
|
||||
#include "BluetoothAudioSessionReport_2_2.h"
|
||||
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
|
||||
|
||||
@@ -83,11 +84,13 @@ Return<void> LeAudioAudioProvider::startSession_2_1(
|
||||
.bitsPerSample = audioConfig.pcmConfig().bitsPerSample,
|
||||
.dataIntervalUs = 0});
|
||||
|
||||
return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
|
||||
sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
|
||||
new AudioPort_2_0_to_2_2_Wrapper(hostIf);
|
||||
return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> LeAudioAudioProvider::startSession_2_2(
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
|
||||
@@ -45,7 +45,7 @@ class LeAudioAudioProvider : public BluetoothAudioProvider {
|
||||
const V2_1::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
Return<void> startSession_2_2(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "AudioPort_2_0_to_2_2_Wrapper.h"
|
||||
#include "BluetoothAudioSessionReport_2_2.h"
|
||||
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
|
||||
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
|
||||
@@ -91,11 +92,13 @@ Return<void> LeAudioOffloadAudioProvider::startSession_2_1(
|
||||
.peerDelay = 0,
|
||||
.lc3Config = audioConfig.leAudioCodecConfig().lc3Config};
|
||||
|
||||
return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
|
||||
sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
|
||||
new AudioPort_2_0_to_2_2_Wrapper(hostIf);
|
||||
return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> LeAudioOffloadAudioProvider::startSession_2_2(
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
|
||||
@@ -38,7 +38,7 @@ class LeAudioOffloadAudioProvider : public BluetoothAudioProvider {
|
||||
const V2_1::AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
Return<void> startSession_2_2(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ cc_library_shared {
|
||||
export_include_dirs: ["session/"],
|
||||
header_libs: ["libhardware_headers"],
|
||||
shared_libs: [
|
||||
"android.hardware.audio.common@5.0",
|
||||
"android.hardware.bluetooth.audio@2.0",
|
||||
"android.hardware.bluetooth.audio@2.1",
|
||||
"android.hardware.bluetooth.audio@2.2",
|
||||
|
||||
@@ -132,6 +132,15 @@ class BluetoothAudioSessionControl_2_2 {
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateSinkMetadata(const SessionType_2_1& session_type,
|
||||
const struct sink_metadata* sink_metadata) {
|
||||
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
|
||||
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
|
||||
if (session_ptr != nullptr) {
|
||||
session_ptr->UpdateSinkMetadata(sink_metadata);
|
||||
}
|
||||
}
|
||||
|
||||
// The control API writes stream to FMQ
|
||||
static size_t OutWritePcmData(const SessionType_2_1& session_type,
|
||||
const void* buffer, size_t bytes) {
|
||||
|
||||
@@ -20,10 +20,16 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioPort.h>
|
||||
|
||||
namespace android {
|
||||
namespace bluetooth {
|
||||
namespace audio {
|
||||
|
||||
using ::android::hardware::audio::common::V5_0::AudioSource;
|
||||
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
|
||||
using ::android::hardware::audio::common::V5_0::SinkMetadata;
|
||||
|
||||
using SessionType_2_1 =
|
||||
::android::hardware::bluetooth::audio::V2_1::SessionType;
|
||||
using SessionType_2_0 =
|
||||
@@ -37,6 +43,9 @@ using AudioConfiguration_2_1 =
|
||||
::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
|
||||
BluetoothAudioSession_2_2::invalidOffloadAudioConfiguration = {};
|
||||
|
||||
using IBluetoothAudioPort_2_2 =
|
||||
::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
|
||||
|
||||
namespace {
|
||||
bool is_2_0_session_type(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
|
||||
@@ -84,6 +93,54 @@ BluetoothAudioSession_2_2::GetAudioSession_2_1() {
|
||||
return audio_session_2_1;
|
||||
}
|
||||
|
||||
void BluetoothAudioSession_2_2::UpdateSinkMetadata(
|
||||
const struct sink_metadata* sink_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 = sink_metadata->track_count;
|
||||
LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||
<< ", " << track_count << " track(s)";
|
||||
if (session_type_2_1_ == SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct record_track_metadata* track = sink_metadata->tracks;
|
||||
SinkMetadata sinkMetadata;
|
||||
RecordTrackMetadata* halMetadata;
|
||||
|
||||
sinkMetadata.tracks.resize(track_count);
|
||||
halMetadata = sinkMetadata.tracks.data();
|
||||
while (track_count && track) {
|
||||
halMetadata->source = static_cast<AudioSource>(track->source);
|
||||
halMetadata->gain = track->gain;
|
||||
// halMetadata->destination leave unspecified
|
||||
LOG(INFO) << __func__
|
||||
<< " - SessionType=" << toString(GetAudioSession()->session_type_)
|
||||
<< ", source=" << track->source
|
||||
<< ", dest_device=" << track->dest_device
|
||||
<< ", gain=" << track->gain
|
||||
<< ", dest_device_address=" << track->dest_device_address;
|
||||
--track_count;
|
||||
++track;
|
||||
++halMetadata;
|
||||
}
|
||||
|
||||
/* This is called just for 2.2 sessions, so it's safe to do this casting*/
|
||||
IBluetoothAudioPort_2_2* stack_iface_2_2_ =
|
||||
static_cast<IBluetoothAudioPort_2_2*>(audio_session->stack_iface_.get());
|
||||
auto hal_retval = stack_iface_2_2_->updateSinkMetadata(sinkMetadata);
|
||||
if (!hal_retval.isOk()) {
|
||||
LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
|
||||
<< toString(session_type_2_1_) << " failed";
|
||||
}
|
||||
}
|
||||
|
||||
// The control function is for the bluetooth_audio module to get the current
|
||||
// AudioConfiguration
|
||||
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
|
||||
|
||||
@@ -74,6 +74,8 @@ class BluetoothAudioSession_2_2 {
|
||||
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
|
||||
GetAudioConfig();
|
||||
|
||||
void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);
|
||||
|
||||
static constexpr ::android::hardware::bluetooth::audio::V2_2::
|
||||
AudioConfiguration& kInvalidSoftwareAudioConfiguration =
|
||||
invalidSoftwareAudioConfiguration;
|
||||
|
||||
Reference in New Issue
Block a user