bluetooth.audio@2.1: add internal HW offloading data path routing am: c8861ece90
am: 560e842d71
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1724672 Change-Id: I161220c33caa21e9da2dea55fcdccd4585c7706f
This commit is contained in:
commit
c19e62bf7b
8 changed files with 215 additions and 4 deletions
|
@ -19,6 +19,7 @@ cc_library_shared {
|
|||
"A2dpSoftwareAudioProvider.cpp",
|
||||
"HearingAidAudioProvider.cpp",
|
||||
"LeAudioAudioProvider.cpp",
|
||||
"LeAudioOffloadAudioProvider.cpp",
|
||||
],
|
||||
header_libs: ["libhardware_headers"],
|
||||
shared_libs: [
|
||||
|
|
|
@ -41,8 +41,12 @@ HearingAidAudioProvider
|
|||
BluetoothAudioProvidersFactory::hearing_aid_provider_instance_;
|
||||
LeAudioOutputAudioProvider
|
||||
BluetoothAudioProvidersFactory::leaudio_output_provider_instance_;
|
||||
LeAudioOffloadOutputAudioProvider
|
||||
BluetoothAudioProvidersFactory::leaudio_offload_output_provider_instance_;
|
||||
LeAudioInputAudioProvider
|
||||
BluetoothAudioProvidersFactory::leaudio_input_provider_instance_;
|
||||
LeAudioOffloadInputAudioProvider
|
||||
BluetoothAudioProvidersFactory::leaudio_offload_input_provider_instance_;
|
||||
|
||||
Return<void> BluetoothAudioProvidersFactory::openProvider(
|
||||
const V2_0::SessionType sessionType, openProvider_cb _hidl_cb) {
|
||||
|
@ -90,9 +94,15 @@ Return<void> BluetoothAudioProvidersFactory::openProvider_2_1(
|
|||
case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH:
|
||||
provider = &leaudio_output_provider_instance_;
|
||||
break;
|
||||
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
|
||||
provider = &leaudio_offload_output_provider_instance_;
|
||||
break;
|
||||
case SessionType::LE_AUDIO_SOFTWARE_DECODED_DATAPATH:
|
||||
provider = &leaudio_input_provider_instance_;
|
||||
break;
|
||||
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
|
||||
provider = &leaudio_offload_input_provider_instance_;
|
||||
break;
|
||||
default:
|
||||
status = BluetoothAudioStatus::FAILURE;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "BluetoothAudioProvider.h"
|
||||
#include "HearingAidAudioProvider.h"
|
||||
#include "LeAudioAudioProvider.h"
|
||||
#include "LeAudioOffloadAudioProvider.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -55,6 +56,8 @@ class BluetoothAudioProvidersFactory : public IBluetoothAudioProvidersFactory {
|
|||
static HearingAidAudioProvider hearing_aid_provider_instance_;
|
||||
static LeAudioOutputAudioProvider leaudio_output_provider_instance_;
|
||||
static LeAudioInputAudioProvider leaudio_input_provider_instance_;
|
||||
static LeAudioOffloadOutputAudioProvider leaudio_offload_output_provider_instance_;
|
||||
static LeAudioOffloadInputAudioProvider leaudio_offload_input_provider_instance_;
|
||||
};
|
||||
|
||||
extern "C" IBluetoothAudioProvidersFactory*
|
||||
|
|
108
bluetooth/audio/2.1/default/LeAudioOffloadAudioProvider.cpp
Normal file
108
bluetooth/audio/2.1/default/LeAudioOffloadAudioProvider.cpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "BTAudioProviderLeAudioOffload"
|
||||
|
||||
#include "LeAudioOffloadAudioProvider.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "BluetoothAudioSessionReport_2_1.h"
|
||||
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace bluetooth {
|
||||
namespace audio {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::bluetooth::audio::BluetoothAudioSessionReport_2_1;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
|
||||
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
|
||||
using ::android::hardware::bluetooth::audio::V2_1::SampleRate;
|
||||
|
||||
using DataMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
||||
|
||||
LeAudioOffloadOutputAudioProvider::LeAudioOffloadOutputAudioProvider()
|
||||
: LeAudioOffloadAudioProvider() {
|
||||
session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH;
|
||||
}
|
||||
|
||||
LeAudioOffloadInputAudioProvider::LeAudioOffloadInputAudioProvider()
|
||||
: LeAudioOffloadAudioProvider() {
|
||||
session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH;
|
||||
}
|
||||
|
||||
LeAudioOffloadAudioProvider::LeAudioOffloadAudioProvider()
|
||||
: BluetoothAudioProvider() {}
|
||||
|
||||
bool LeAudioOffloadAudioProvider::isValid(const V2_0::SessionType& sessionType) {
|
||||
LOG(ERROR) << __func__ << ", invalid session type for Offloaded Le Audio provider: "
|
||||
<< toString(sessionType);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LeAudioOffloadAudioProvider::isValid(const SessionType& sessionType) {
|
||||
return (sessionType == session_type_);
|
||||
}
|
||||
|
||||
Return<void> LeAudioOffloadAudioProvider::startSession_2_1(
|
||||
const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
|
||||
/**
|
||||
* Initialize the audio platform if audioConfiguration is supported.
|
||||
* Save the IBluetoothAudioPort interface, so that it can be used
|
||||
* later to send stream control commands to the HAL client, based on
|
||||
* interaction with Audio framework.
|
||||
*/
|
||||
if (audioConfig.getDiscriminator() !=
|
||||
AudioConfiguration::hidl_discriminator::leAudioCodecConfig) {
|
||||
LOG(WARNING) << __func__
|
||||
<< " - Invalid Audio Configuration=" << toString(audioConfig);
|
||||
_hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION,
|
||||
DataMQ::Descriptor());
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (!android::bluetooth::audio::IsOffloadLeAudioConfigurationValid(session_type_,
|
||||
audioConfig.leAudioCodecConfig())) {
|
||||
LOG(WARNING) << __func__ << " - Unsupported LC3 Offloaded Configuration="
|
||||
<< toString(audioConfig.leAudioCodecConfig());
|
||||
_hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION,
|
||||
DataMQ::Descriptor());
|
||||
return Void();
|
||||
}
|
||||
|
||||
return BluetoothAudioProvider::startSession_2_1(hostIf, audioConfig,
|
||||
_hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> LeAudioOffloadAudioProvider::onSessionReady(startSession_cb _hidl_cb) {
|
||||
BluetoothAudioSessionReport_2_1::OnSessionStarted(session_type_, stack_iface_,
|
||||
nullptr, audio_config_);
|
||||
_hidl_cb(BluetoothAudioStatus::SUCCESS, DataMQ::Descriptor());
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace audio
|
||||
} // namespace bluetooth
|
||||
} // namespace hardware
|
||||
} // namespace android
|
60
bluetooth/audio/2.1/default/LeAudioOffloadAudioProvider.h
Normal file
60
bluetooth/audio/2.1/default/LeAudioOffloadAudioProvider.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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.1/types.h>
|
||||
|
||||
#include "BluetoothAudioProvider.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace bluetooth {
|
||||
namespace audio {
|
||||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
class LeAudioOffloadAudioProvider : public BluetoothAudioProvider {
|
||||
public:
|
||||
LeAudioOffloadAudioProvider();
|
||||
|
||||
bool isValid(const SessionType& sessionType) override;
|
||||
bool isValid(const V2_0::SessionType& sessionType) override;
|
||||
|
||||
Return<void> startSession_2_1(const sp<V2_0::IBluetoothAudioPort>& hostIf,
|
||||
const AudioConfiguration& audioConfig,
|
||||
startSession_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
Return<void> onSessionReady(startSession_cb _hidl_cb) override;
|
||||
};
|
||||
|
||||
class LeAudioOffloadOutputAudioProvider : public LeAudioOffloadAudioProvider {
|
||||
public:
|
||||
LeAudioOffloadOutputAudioProvider();
|
||||
};
|
||||
|
||||
class LeAudioOffloadInputAudioProvider : public LeAudioOffloadAudioProvider {
|
||||
public:
|
||||
LeAudioOffloadInputAudioProvider();
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_1
|
||||
} // namespace audio
|
||||
} // namespace bluetooth
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -110,20 +110,29 @@ bool BluetoothAudioSession_2_1::UpdateAudioConfig(
|
|||
SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ ==
|
||||
SessionType_2_1::LE_AUDIO_SOFTWARE_DECODED_DATAPATH);
|
||||
bool is_offload_session =
|
||||
bool is_offload_a2dp_session =
|
||||
(session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH);
|
||||
bool is_offload_le_audio_session =
|
||||
(session_type_2_1_ == SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ == SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH);
|
||||
auto audio_config_discriminator = audio_config.getDiscriminator();
|
||||
bool is_software_audio_config =
|
||||
(is_software_session &&
|
||||
audio_config_discriminator ==
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
|
||||
hidl_discriminator::pcmConfig);
|
||||
bool is_offload_audio_config =
|
||||
(is_offload_session &&
|
||||
bool is_a2dp_offload_audio_config =
|
||||
(is_offload_a2dp_session &&
|
||||
audio_config_discriminator ==
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
|
||||
hidl_discriminator::codecConfig);
|
||||
if (!is_software_audio_config && !is_offload_audio_config) {
|
||||
bool is_le_audio_offload_audio_config =
|
||||
(is_offload_le_audio_session &&
|
||||
audio_config_discriminator ==
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
|
||||
hidl_discriminator::leAudioCodecConfig);
|
||||
if (!is_software_audio_config && !is_a2dp_offload_audio_config &&
|
||||
!is_le_audio_offload_audio_config) {
|
||||
return false;
|
||||
}
|
||||
audio_config_2_1_ = audio_config;
|
||||
|
|
|
@ -122,6 +122,21 @@ bool IsOffloadCodecConfigurationValid(
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IsOffloadLeAudioConfigurationValid(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
|
||||
session_type,
|
||||
const ::android::hardware::bluetooth::audio::V2_1::Lc3CodecConfiguration&) {
|
||||
|
||||
if (session_type != SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
|
||||
session_type != SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: perform checks on le_audio_codec_config once we know supported parameters
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace audio
|
||||
} // namespace bluetooth
|
||||
} // namespace android
|
||||
|
|
|
@ -41,6 +41,11 @@ bool IsOffloadCodecConfigurationValid(
|
|||
const ::android::hardware::bluetooth::audio::V2_0::CodecConfiguration&
|
||||
codec_config);
|
||||
|
||||
bool IsOffloadLeAudioConfigurationValid(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
|
||||
session_type,
|
||||
const ::android::hardware::bluetooth::audio::V2_1::Lc3CodecConfiguration&
|
||||
le_audio_codec_config);
|
||||
} // namespace audio
|
||||
} // namespace bluetooth
|
||||
} // namespace android
|
||||
|
|
Loading…
Reference in a new issue