diff options
author | Alice Kuo <aliceypkuo@google.com> | 2022-02-22 11:14:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-02-22 11:14:35 +0000 |
commit | daa7c0ef033c2cb11a96996fa150feb79157bf8b (patch) | |
tree | 92c3494aa22a212c99920851700f1028a596962f | |
parent | d9452788bbb66732751a6d3f12e706ee170e307e (diff) | |
parent | ca2105dbf9fdc1f3de8563e3e269f5ae97f1e96d (diff) |
Merge "Remove HIDL 2.2 client integration"
24 files changed, 36 insertions, 728 deletions
diff --git a/system/audio_hal_interface/Android.bp b/system/audio_hal_interface/Android.bp index ac8b4105d4..49175192d3 100644 --- a/system/audio_hal_interface/Android.bp +++ b/system/audio_hal_interface/Android.bp @@ -23,7 +23,6 @@ cc_library_static { shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "libhidlbase", ], static_libs: [ @@ -85,7 +84,6 @@ cc_test { shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.hardware.bluetooth.audio-V1-ndk", "libbinder_ndk", "libcutils", diff --git a/system/audio_hal_interface/a2dp_encoding.cc b/system/audio_hal_interface/a2dp_encoding.cc index b2cead3320..d0028e1ef9 100644 --- a/system/audio_hal_interface/a2dp_encoding.cc +++ b/system/audio_hal_interface/a2dp_encoding.cc @@ -140,11 +140,9 @@ void set_remote_delay(uint16_t delay_report) { // Set low latency buffer mode allowed or disallowed void set_audio_low_latency_mode_allowed(bool allowed) { if (HalVersionManager::GetHalTransport() == - BluetoothAudioHalTransport::HIDL) { - hidl::a2dp::set_low_latency_mode_allowed(allowed); - return; + BluetoothAudioHalTransport::AIDL) { + aidl::a2dp::set_low_latency_mode_allowed(allowed); } - aidl::a2dp::set_low_latency_mode_allowed(allowed); } } // namespace a2dp diff --git a/system/audio_hal_interface/fuzzer/Android.bp b/system/audio_hal_interface/fuzzer/Android.bp index 5e8238f65f..f1724af3d4 100644 --- a/system/audio_hal_interface/fuzzer/Android.bp +++ b/system/audio_hal_interface/fuzzer/Android.bp @@ -43,7 +43,6 @@ cc_defaults { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.system.suspend.control-V1-ndk", "android.system.suspend-V1-ndk", ], diff --git a/system/audio_hal_interface/fuzzer/libbt_audio_hal_client_interface_fuzzer.cpp b/system/audio_hal_interface/fuzzer/libbt_audio_hal_client_interface_fuzzer.cpp index e32ff3684f..9f43485ed7 100644 --- a/system/audio_hal_interface/fuzzer/libbt_audio_hal_client_interface_fuzzer.cpp +++ b/system/audio_hal_interface/fuzzer/libbt_audio_hal_client_interface_fuzzer.cpp @@ -169,8 +169,6 @@ class TestSinkTransport void ResetPresentationPosition() override{}; void LogBytesRead(size_t) override{}; - - void SinkMetadataChanged(const sink_metadata_t&) override{}; }; class TestSourceTransport @@ -204,8 +202,6 @@ class TestSourceTransport void ResetPresentationPosition() override{}; void LogBytesWritten(size_t) override{}; - - void SinkMetadataChanged(const sink_metadata_t&) override{}; }; class ClientInterfaceFuzzer { diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc index d46f6a6640..a2c192f37d 100644 --- a/system/audio_hal_interface/hal_version_manager.cc +++ b/system/audio_hal_interface/hal_version_manager.cc @@ -48,30 +48,12 @@ BluetoothAudioHalTransport HalVersionManager::GetHalTransport() { return BluetoothAudioHalTransport::AIDL; case BluetoothAudioHalVersion::VERSION_2_0: case BluetoothAudioHalVersion::VERSION_2_1: - case BluetoothAudioHalVersion::VERSION_2_2: return BluetoothAudioHalTransport::HIDL; default: return BluetoothAudioHalTransport::UNKNOWN; } } -android::sp<IBluetoothAudioProvidersFactory_2_2> -HalVersionManager::GetProvidersFactory_2_2() { - std::lock_guard<std::mutex> guard(instance_ptr->mutex_); - if (instance_ptr->hal_version_ != BluetoothAudioHalVersion::VERSION_2_2) { - return nullptr; - } - android::sp<IBluetoothAudioProvidersFactory_2_2> providers_factory = - IBluetoothAudioProvidersFactory_2_2::getService(); - CHECK(providers_factory) - << "V2_2::IBluetoothAudioProvidersFactory::getService() failed"; - - LOG(INFO) << "V2_2::IBluetoothAudioProvidersFactory::getService() returned " - << providers_factory.get() - << (providers_factory->isRemote() ? " (remote)" : " (local)"); - return providers_factory; -} - android::sp<IBluetoothAudioProvidersFactory_2_1> HalVersionManager::GetProvidersFactory_2_1() { std::lock_guard<std::mutex> guard(instance_ptr->mutex_); @@ -124,19 +106,6 @@ HalVersionManager::HalVersionManager() { instance_count = instanceNames.size(); }; auto hidl_retval = service_manager->listManifestByInterface( - kFullyQualifiedInterfaceName_2_2, listManifestByInterface_cb); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ << ": IServiceManager::listByInterface failure: " - << hidl_retval.description(); - return; - } - - if (instance_count > 0) { - hal_version_ = BluetoothAudioHalVersion::VERSION_2_2; - return; - } - - hidl_retval = service_manager->listManifestByInterface( kFullyQualifiedInterfaceName_2_1, listManifestByInterface_cb); if (!hidl_retval.isOk()) { LOG(FATAL) << __func__ << ": IServiceManager::listByInterface failure: " diff --git a/system/audio_hal_interface/hal_version_manager.h b/system/audio_hal_interface/hal_version_manager.h index 12a2ecacfe..99dc0e9311 100644 --- a/system/audio_hal_interface/hal_version_manager.h +++ b/system/audio_hal_interface/hal_version_manager.h @@ -16,8 +16,8 @@ #pragma once -#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioProvidersFactory.h> -#include <android/hardware/bluetooth/audio/2.2/types.h> +#include <android/hardware/bluetooth/audio/2.1/IBluetoothAudioProvidersFactory.h> +#include <android/hardware/bluetooth/audio/2.1/types.h> namespace bluetooth { namespace audio { @@ -28,22 +28,17 @@ using IBluetoothAudioProvidersFactory_2_0 = ::android::hardware::bluetooth:: audio::V2_0::IBluetoothAudioProvidersFactory; using IBluetoothAudioProvidersFactory_2_1 = ::android::hardware::bluetooth:: audio::V2_1::IBluetoothAudioProvidersFactory; -using IBluetoothAudioProvidersFactory_2_2 = ::android::hardware::bluetooth:: - audio::V2_2::IBluetoothAudioProvidersFactory; constexpr char kFullyQualifiedInterfaceName_2_0[] = "android.hardware.bluetooth.audio@2.0::IBluetoothAudioProvidersFactory"; constexpr char kFullyQualifiedInterfaceName_2_1[] = "android.hardware.bluetooth.audio@2.1::IBluetoothAudioProvidersFactory"; -constexpr char kFullyQualifiedInterfaceName_2_2[] = - "android.hardware.bluetooth.audio@2.2::IBluetoothAudioProvidersFactory"; enum class BluetoothAudioHalVersion : uint8_t { - VERSION_2_0 = 0, + VERSION_UNAVAILABLE = 0, + VERSION_2_0, VERSION_2_1, - VERSION_2_2, VERSION_AIDL_V1, - VERSION_UNAVAILABLE, }; enum class BluetoothAudioHalTransport : uint8_t { @@ -61,9 +56,6 @@ class HalVersionManager { static BluetoothAudioHalTransport GetHalTransport(); - static android::sp<IBluetoothAudioProvidersFactory_2_2> - GetProvidersFactory_2_2(); - static android::sp<IBluetoothAudioProvidersFactory_2_1> GetProvidersFactory_2_1(); diff --git a/system/audio_hal_interface/hal_version_manager_host.cc b/system/audio_hal_interface/hal_version_manager_host.cc index 8b1c781d2f..b680ce06ff 100644 --- a/system/audio_hal_interface/hal_version_manager_host.cc +++ b/system/audio_hal_interface/hal_version_manager_host.cc @@ -29,11 +29,6 @@ BluetoothAudioHalTransport HalVersionManager::GetHalTransport() { return BluetoothAudioHalTransport::UNKNOWN; } -android::sp<IBluetoothAudioProvidersFactory_2_2> -HalVersionManager::GetProvidersFactory_2_2() { - return nullptr; -} - android::sp<IBluetoothAudioProvidersFactory_2_1> HalVersionManager::GetProvidersFactory_2_1() { return nullptr; diff --git a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc index 6372aef40f..beeb823518 100644 --- a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc +++ b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.cc @@ -163,8 +163,6 @@ class A2dpTransport } } - void SinkMetadataChanged(const sink_metadata_t&) override {} - tA2DP_CTRL_CMD GetPendingCmd() const { return a2dp_pending_cmd_; } void ResetPendingCmd() { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; } @@ -553,15 +551,6 @@ void set_remote_delay(uint16_t delay_report) { ->SetRemoteDelay(delay_report); } -// Set low latency buffer mode allowed or disallowed -void set_low_latency_mode_allowed(bool allowed) { - if (!is_hal_2_0_enabled()) { - LOG(ERROR) << __func__ << ": BluetoothAudio HAL is not enabled"; - return; - } - active_hal_interface->SetLowLatencyModeAllowed(allowed); -} - } // namespace a2dp } // namespace hidl } // namespace audio diff --git a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.h b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.h index d8689b29fa..98a8f68632 100644 --- a/system/audio_hal_interface/hidl/a2dp_encoding_hidl.h +++ b/system/audio_hal_interface/hidl/a2dp_encoding_hidl.h @@ -57,9 +57,6 @@ size_t read(uint8_t* p_buf, uint32_t len); // Update A2DP delay report to BluetoothAudio HAL void set_remote_delay(uint16_t delay_report); -// Set low latency buffer mode allowed or disallowed -void set_low_latency_mode_allowed(bool allowed); - } // namespace a2dp } // namespace hidl } // namespace audio diff --git a/system/audio_hal_interface/hidl/client_interface_hidl.cc b/system/audio_hal_interface/hidl/client_interface_hidl.cc index 95efe6d42d..056ca04b75 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl.cc +++ b/system/audio_hal_interface/hidl/client_interface_hidl.cc @@ -18,7 +18,7 @@ #include "client_interface_hidl.h" -#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioPort.h> +#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioPort.h> #include <base/logging.h> #include <hidl/MQDescriptor.h> @@ -35,9 +35,8 @@ namespace hidl { 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_2::IBluetoothAudioPort; +using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort; using ::bluetooth::common::StopWatchLegacy; using DataMQ = ::android::hardware::MessageQueue< @@ -156,24 +155,6 @@ 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)"; - // refer to StreamIn.impl.h within Audio HAL (AUDIO_HAL_VERSION_5_0) - std::vector<record_track_metadata> metadata_vec; - metadata_vec.reserve(sinkMetadata.tracks.size()); - for (const auto& metadata : sinkMetadata.tracks) { - metadata_vec.push_back({ - .source = static_cast<audio_source_t>(metadata.source), - .gain = metadata.gain, - }); - } - const sink_metadata_t sink_metadata = {.track_count = metadata_vec.size(), - .tracks = metadata_vec.data()}; - transport_instance_->SinkMetadataChanged(sink_metadata); - return Void(); - } - private: IBluetoothTransportInstance* transport_instance_; const android::sp<IBluetoothAudioProvider> provider_; @@ -220,7 +201,6 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface( IBluetoothTransportInstance* instance) : provider_(nullptr), provider_2_1_(nullptr), - provider_2_2_(nullptr), session_started_(false), mDataMQ(nullptr), transport_(instance) { @@ -300,37 +280,6 @@ BluetoothAudioClientInterface::GetAudioCapabilities_2_1( return capabilities_2_1; } -std::vector<AudioCapabilities_2_2> -BluetoothAudioClientInterface::GetAudioCapabilities_2_2( - SessionType_2_1 session_type_2_1) { - std::vector<AudioCapabilities_2_2> capabilities_2_2(0); - if (HalVersionManager::GetHalVersion() != - BluetoothAudioHalVersion::VERSION_2_2) { - LOG(ERROR) << __func__ << ", can't get capability for HAL 2.2"; - return capabilities_2_2; - } - - android::sp<IBluetoothAudioProvidersFactory_2_2> providersFactory = - HalVersionManager::GetProvidersFactory_2_2(); - CHECK(providersFactory != nullptr) - << "IBluetoothAudioProvidersFactory::getService() failed"; - auto getProviderCapabilities_cb = - [&capabilities_2_2]( - const hidl_vec<AudioCapabilities_2_2>& audioCapabilities_2_2) { - for (auto capability_2_2 : audioCapabilities_2_2) { - capabilities_2_2.push_back(capability_2_2); - } - }; - auto hidl_retval = providersFactory->getProviderCapabilities_2_2( - session_type_2_1, getProviderCapabilities_cb); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ - << ": BluetoothAudioHal::getProviderCapabilities failure: " - << hidl_retval.description(); - } - return capabilities_2_2; -} - void BluetoothAudioClientInterface::FetchAudioProvider() { if (provider_ != nullptr) { LOG(WARNING) << __func__ << ": reflash"; @@ -467,74 +416,6 @@ void BluetoothAudioClientInterface::FetchAudioProvider_2_1() { << (provider_2_1_->isRemote() ? " (remote)" : " (local)"); } -void BluetoothAudioClientInterface::FetchAudioProvider_2_2() { - if (provider_2_2_ != nullptr) { - LOG(WARNING) << __func__ << ": reflash"; - } - - android::sp<IBluetoothAudioProvidersFactory_2_2> providersFactory = - HalVersionManager::GetProvidersFactory_2_2(); - CHECK(providersFactory != nullptr) - << "IBluetoothAudioProvidersFactory_2_1::getService() failed"; - - auto getProviderCapabilities_cb = - [&capabilities_2_1 = this->capabilities_2_1_]( - const hidl_vec<AudioCapabilities_2_1>& audioCapabilities_2_1) { - capabilities_2_1.clear(); - for (auto capability_2_1 : audioCapabilities_2_1) { - capabilities_2_1.push_back(capability_2_1); - } - }; - auto hidl_retval = providersFactory->getProviderCapabilities_2_1( - transport_->GetSessionType_2_1(), getProviderCapabilities_cb); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ - << ": BluetoothAudioHal::getProviderCapabilities failure: " - << hidl_retval.description(); - return; - } - if (capabilities_2_1_.empty()) { - LOG(WARNING) << __func__ << ": SessionType=" - << toString(transport_->GetSessionType_2_1()) - << " Not supported by BluetoothAudioHal"; - return; - } - LOG(INFO) << __func__ << ": BluetoothAudioHal SessionType=" - << toString(transport_->GetSessionType_2_1()) << " has " - << capabilities_2_1_.size() << " AudioCapabilities"; - - std::promise<void> openProvider_promise; - auto openProvider_future = openProvider_promise.get_future(); - auto openProvider_cb = - [&provider_2_2_ = this->provider_2_2_, &openProvider_promise]( - BluetoothAudioStatus status, - const android::sp<IBluetoothAudioProvider_2_2>& provider_2_2) { - LOG(INFO) << "openProvider_cb(" << toString(status) << ")"; - if (status == BluetoothAudioStatus::SUCCESS) { - provider_2_2_ = provider_2_2; - } - ALOGE_IF(!provider_2_2_, "Failed to open BluetoothAudio provider_2_2"); - openProvider_promise.set_value(); - }; - hidl_retval = providersFactory->openProvider_2_2( - transport_->GetSessionType_2_1(), openProvider_cb); - openProvider_future.get(); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ << ": BluetoothAudioHal::openProvider failure: " - << hidl_retval.description(); - } - CHECK(provider_2_2_ != nullptr); - - if (!provider_2_2_->linkToDeath(death_recipient_, 0).isOk()) { - LOG(FATAL) << __func__ << ": BluetoothAudioDeathRecipient failure: " - << hidl_retval.description(); - } - - LOG(INFO) << "IBluetoothAudioProvidersFactory::openProvider() returned " - << provider_2_2_.get() - << (provider_2_2_->isRemote() ? " (remote)" : " (local)"); -} - BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface( IBluetoothSinkTransportInstance* sink, bluetooth::common::MessageLoopThread* message_loop) @@ -548,13 +429,6 @@ BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface( } if ((HalVersionManager::GetHalVersion() == - BluetoothAudioHalVersion::VERSION_2_2) && - (sink_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { - FetchAudioProvider_2_2(); - return; - } - - if ((HalVersionManager::GetHalVersion() == BluetoothAudioHalVersion::VERSION_2_1) && (sink_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { FetchAudioProvider_2_1(); @@ -578,13 +452,6 @@ BluetoothAudioSinkClientInterface::~BluetoothAudioSinkClientInterface() { << hidl_retval.description(); } } - if (provider_2_2_ != nullptr) { - auto hidl_retval = provider_2_2_->unlinkToDeath(death_recipient_); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ << ": BluetoothAudioDeathRecipient failure: " - << hidl_retval.description(); - } - } } BluetoothAudioSourceClientInterface::BluetoothAudioSourceClientInterface( @@ -600,12 +467,6 @@ BluetoothAudioSourceClientInterface::BluetoothAudioSourceClientInterface( } if ((HalVersionManager::GetHalVersion() == - BluetoothAudioHalVersion::VERSION_2_2) && - (source_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { - FetchAudioProvider_2_2(); - return; - } - if ((HalVersionManager::GetHalVersion() == BluetoothAudioHalVersion::VERSION_2_1) && (source_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { FetchAudioProvider_2_1(); @@ -629,13 +490,6 @@ BluetoothAudioSourceClientInterface::~BluetoothAudioSourceClientInterface() { << hidl_retval.description(); } } - if (provider_2_2_ != nullptr) { - auto hidl_retval = provider_2_2_->unlinkToDeath(death_recipient_); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ << ": BluetoothAudioDeathRecipient failure: " - << hidl_retval.description(); - } - } } bool BluetoothAudioClientInterface::UpdateAudioConfig( @@ -692,61 +546,6 @@ bool BluetoothAudioClientInterface::UpdateAudioConfig_2_1( return true; } -bool BluetoothAudioClientInterface::UpdateAudioConfig_2_2( - const AudioConfiguration_2_2& audio_config_2_2) { - bool is_software_session = - (transport_->GetSessionType_2_1() == - SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::HEARING_AID_SOFTWARE_ENCODING_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_SOFTWARE_DECODED_DATAPATH); - bool is_a2dp_offload_session = - (transport_->GetSessionType_2_1() == - SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH); - bool is_leaudio_offload_session = - (transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH); - auto audio_config_discriminator = audio_config_2_2.getDiscriminator(); - bool is_software_audio_config = - (is_software_session && - audio_config_discriminator == - AudioConfiguration_2_2::hidl_discriminator::pcmConfig); - bool is_a2dp_offload_audio_config = - (is_a2dp_offload_session && - audio_config_discriminator == - AudioConfiguration_2_2::hidl_discriminator::codecConfig); - bool is_leaudio_offload_audio_config = - (is_leaudio_offload_session && - audio_config_discriminator == - AudioConfiguration_2_2::hidl_discriminator::leAudioConfig); - if (!is_software_audio_config && !is_a2dp_offload_audio_config && - !is_leaudio_offload_audio_config) { - return false; - } - - transport_->UpdateAudioConfiguration_2_2(audio_config_2_2); - - if (provider_2_2_ == nullptr) { - LOG(INFO) << __func__ - << ": BluetoothAudioHal nullptr, update it as session started"; - return true; - } - - ::android::hardware::Return<void> hidl_retval; - hidl_retval = provider_2_2_->updateAudioConfiguration(audio_config_2_2); - - if (!hidl_retval.isOk()) { - LOG(ERROR) << __func__ - << ": BluetoothAudioHal failure: " << hidl_retval.description(); - } - return true; -} - int BluetoothAudioClientInterface::StartSession() { std::lock_guard<std::mutex> guard(internal_mutex_); if (provider_ == nullptr) { @@ -867,71 +666,6 @@ int BluetoothAudioClientInterface::StartSession_2_1() { } } -int BluetoothAudioClientInterface::StartSession_2_2() { - std::lock_guard<std::mutex> guard(internal_mutex_); - if (provider_2_2_ == nullptr) { - LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr"; - session_started_ = false; - return -EINVAL; - } - if (session_started_) { - LOG(ERROR) << __func__ << ": session started already"; - return -EBUSY; - } - - android::sp<IBluetoothAudioPort> stack_if = - new BluetoothAudioPortImpl(transport_, provider_2_2_); - - std::unique_ptr<DataMQ> tempDataMQ; - BluetoothAudioStatus session_status; - - std::promise<void> hidl_startSession_promise; - auto hidl_startSession_future = hidl_startSession_promise.get_future(); - auto hidl_cb = [&session_status, &tempDataMQ, &hidl_startSession_promise]( - BluetoothAudioStatus status, - const DataMQ::Descriptor& dataMQ) { - LOG(INFO) << "startSession_cb(" << toString(status) << ")"; - session_status = status; - if (status == BluetoothAudioStatus::SUCCESS && dataMQ.isHandleValid()) { - tempDataMQ.reset(new DataMQ(dataMQ)); - } - hidl_startSession_promise.set_value(); - }; - auto hidl_retval = provider_2_2_->startSession_2_2( - stack_if, transport_->GetAudioConfiguration_2_2(), hidl_cb); - hidl_startSession_future.get(); - if (!hidl_retval.isOk()) { - LOG(FATAL) << __func__ - << ": BluetoothAudioHal failure: " << hidl_retval.description(); - return -EPROTO; - } - - if (tempDataMQ && tempDataMQ->isValid()) { - mDataMQ = std::move(tempDataMQ); - } else if ( - (transport_->GetSessionType_2_1() == - SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || - transport_->GetSessionType_2_1() == - SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) && - session_status == BluetoothAudioStatus::SUCCESS) { - transport_->ResetPresentationPosition(); - session_started_ = true; - return 0; - } - if (mDataMQ && mDataMQ->isValid()) { - transport_->ResetPresentationPosition(); - session_started_ = true; - return 0; - } else { - ALOGE_IF(!mDataMQ, "Failed to obtain audio data path"); - ALOGE_IF(mDataMQ && !mDataMQ->isValid(), "Audio data path is invalid"); - session_started_ = false; - return -EIO; - } -} - void BluetoothAudioClientInterface::StreamStarted( const BluetoothAudioCtrlAck& ack) { if (ack == BluetoothAudioCtrlAck::PENDING) { @@ -941,9 +675,7 @@ void BluetoothAudioClientInterface::StreamStarted( BluetoothAudioStatus status = BluetoothAudioCtrlAckToHalStatus(ack); ::android::hardware::Return<void> hidl_retval; - if (provider_2_2_ != nullptr) { - hidl_retval = provider_2_2_->streamStarted(status); - } else if (provider_2_1_ != nullptr) { + if (provider_2_1_ != nullptr) { hidl_retval = provider_2_1_->streamStarted(status); } else if (provider_ != nullptr) { hidl_retval = provider_->streamStarted(status); @@ -967,9 +699,7 @@ void BluetoothAudioClientInterface::StreamSuspended( BluetoothAudioStatus status = BluetoothAudioCtrlAckToHalStatus(ack); ::android::hardware::Return<void> hidl_retval; - if (provider_2_2_ != nullptr) { - hidl_retval = provider_2_2_->streamSuspended(status); - } else if (provider_2_1_ != nullptr) { + if (provider_2_1_ != nullptr) { hidl_retval = provider_2_1_->streamSuspended(status); } else if (provider_ != nullptr) { hidl_retval = provider_->streamSuspended(status); @@ -995,9 +725,7 @@ int BluetoothAudioClientInterface::EndSession() { mDataMQ = nullptr; ::android::hardware::Return<void> hidl_retval; - if (provider_2_2_ != nullptr) { - hidl_retval = provider_2_2_->endSession(); - } else if (provider_2_1_ != nullptr) { + if (provider_2_1_ != nullptr) { hidl_retval = provider_2_1_->endSession(); } else if (provider_ != nullptr) { hidl_retval = provider_->endSession(); @@ -1088,11 +816,8 @@ void BluetoothAudioClientInterface::RenewAudioProviderAndSession() { // NOTE: must be invoked on the same thread where this // BluetoothAudioClientInterface is running auto hal_version = HalVersionManager::GetHalVersion(); - if ((hal_version == BluetoothAudioHalVersion::VERSION_2_2) && + if ((hal_version == BluetoothAudioHalVersion::VERSION_2_1) && (transport_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { - FetchAudioProvider_2_2(); - } else if ((hal_version == BluetoothAudioHalVersion::VERSION_2_1) && - (transport_->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) { FetchAudioProvider_2_1(); } else if (transport_->GetSessionType() != SessionType::UNKNOWN) { FetchAudioProvider(); @@ -1105,9 +830,7 @@ void BluetoothAudioClientInterface::RenewAudioProviderAndSession() { LOG(INFO) << __func__ << ": Restart the session while audio HAL recovering"; session_started_ = false; - if (provider_2_2_ != nullptr) - StartSession_2_2(); - else if (provider_2_1_ != nullptr) + if (provider_2_1_ != nullptr) StartSession_2_1(); else StartSession(); @@ -1166,14 +889,6 @@ size_t BluetoothAudioSourceClientInterface::WriteAudioData(const uint8_t* p_buf, return total_written; } -void BluetoothAudioClientInterface::SetLowLatencyModeAllowed(bool allowed) { - if (!IsValid()) { - LOG(ERROR) << __func__ << ": BluetoothAudioHal is not valid"; - return; - } - provider_2_2_->setLowLatencyModeAllowed(allowed); -} - } // namespace hidl } // namespace audio } // namespace bluetooth diff --git a/system/audio_hal_interface/hidl/client_interface_hidl.h b/system/audio_hal_interface/hidl/client_interface_hidl.h index cb36613bbb..2ca53e2a6e 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl.h +++ b/system/audio_hal_interface/hidl/client_interface_hidl.h @@ -16,8 +16,8 @@ #pragma once -#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioProvider.h> -#include <android/hardware/bluetooth/audio/2.2/types.h> +#include <android/hardware/bluetooth/audio/2.1/IBluetoothAudioProvider.h> +#include <android/hardware/bluetooth/audio/2.1/types.h> #include <fmq/MessageQueue.h> #include <hardware/audio.h> #include <time.h> @@ -34,27 +34,20 @@ namespace bluetooth { namespace audio { namespace hidl { -using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort; using AudioCapabilities = ::android::hardware::bluetooth::audio::V2_0::AudioCapabilities; using AudioCapabilities_2_1 = ::android::hardware::bluetooth::audio::V2_1::AudioCapabilities; -using AudioCapabilities_2_2 = - ::android::hardware::bluetooth::audio::V2_2::AudioCapabilities; using AudioConfiguration = ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration; using AudioConfiguration_2_1 = ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration; -using AudioConfiguration_2_2 = - ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration; using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample; using ::android::hardware::bluetooth::audio::V2_0::ChannelMode; using IBluetoothAudioProvider = ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioProvider; using IBluetoothAudioProvider_2_1 = ::android::hardware::bluetooth::audio::V2_1::IBluetoothAudioProvider; -using IBluetoothAudioProvider_2_2 = - ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioProvider; using PcmParameters = ::android::hardware::bluetooth::audio::V2_0::PcmParameters; using PcmParameters_2_1 = @@ -107,22 +100,13 @@ class IBluetoothTransportInstance { : session_type_(sessionType), session_type_2_1_(SessionType_2_1::UNKNOWN), audio_config_(std::move(audioConfig)), - audio_config_2_1_({}), - audio_config_2_2_({}){}; + audio_config_2_1_({}){}; IBluetoothTransportInstance(SessionType_2_1 sessionType_2_1, AudioConfiguration_2_1 audioConfig_2_1) : session_type_(SessionType::UNKNOWN), session_type_2_1_(sessionType_2_1), audio_config_({}), - audio_config_2_1_(std::move(audioConfig_2_1)), - audio_config_2_2_({}){}; - IBluetoothTransportInstance(SessionType_2_1 sessionType_2_1, - AudioConfiguration_2_2 audioConfig_2_2) - : session_type_(SessionType::UNKNOWN), - session_type_2_1_(sessionType_2_1), - audio_config_({}), - audio_config_2_1_({}), - audio_config_2_2_(std::move(audioConfig_2_2)){}; + audio_config_2_1_(std::move(audioConfig_2_1)){}; virtual ~IBluetoothTransportInstance() = default; SessionType GetSessionType() const { return session_type_; } @@ -132,9 +116,6 @@ class IBluetoothTransportInstance { AudioConfiguration_2_1 GetAudioConfiguration_2_1() const { return audio_config_2_1_; } - AudioConfiguration_2_2 GetAudioConfiguration_2_2() const { - return audio_config_2_2_; - } void UpdateAudioConfiguration(const AudioConfiguration& audio_config) { audio_config_ = audio_config; @@ -143,10 +124,6 @@ class IBluetoothTransportInstance { const AudioConfiguration_2_1& audio_config_2_1) { audio_config_2_1_ = audio_config_2_1; } - void UpdateAudioConfiguration_2_2( - const AudioConfiguration_2_2& audio_config_2_2) { - audio_config_2_2_ = audio_config_2_2; - } virtual BluetoothAudioCtrlAck StartRequest() = 0; @@ -159,7 +136,6 @@ class IBluetoothTransportInstance { timespec* data_position) = 0; virtual void MetadataChanged(const source_metadata_t& source_metadata) = 0; - virtual void SinkMetadataChanged(const sink_metadata_t& sink_metadata) = 0; // Invoked when the transport is requested to reset presentation position virtual void ResetPresentationPosition() = 0; @@ -169,7 +145,6 @@ class IBluetoothTransportInstance { const SessionType_2_1 session_type_2_1_; AudioConfiguration audio_config_; AudioConfiguration_2_1 audio_config_2_1_; - AudioConfiguration_2_2 audio_config_2_2_; }; // An IBluetoothSinkTransportInstance needs to be implemented by a Bluetooth @@ -177,15 +152,12 @@ class IBluetoothTransportInstance { // from Audio HAL. class IBluetoothSinkTransportInstance : public IBluetoothTransportInstance { public: - IBluetoothSinkTransportInstance(SessionType_2_1 sessionType_2_1, - AudioConfiguration_2_2 audioConfig_2_2) - : IBluetoothTransportInstance{sessionType_2_1, audioConfig_2_2} {} - IBluetoothSinkTransportInstance(SessionType_2_1 sessionType_2_1, - AudioConfiguration_2_1 audioConfig_2_1) - : IBluetoothTransportInstance{sessionType_2_1, audioConfig_2_1} {} IBluetoothSinkTransportInstance(SessionType sessionType, AudioConfiguration audioConfig) : IBluetoothTransportInstance{sessionType, audioConfig} {} + IBluetoothSinkTransportInstance(SessionType_2_1 sessionType_2_1, + AudioConfiguration_2_1 audioConfig_2_1) + : IBluetoothTransportInstance{sessionType_2_1, audioConfig_2_1} {} virtual ~IBluetoothSinkTransportInstance() = default; // Invoked when the transport is requested to log bytes read @@ -200,9 +172,6 @@ class IBluetoothSourceTransportInstance : public IBluetoothTransportInstance { IBluetoothSourceTransportInstance(SessionType_2_1 sessionType_2_1, AudioConfiguration_2_1 audioConfig_2_1) : IBluetoothTransportInstance{sessionType_2_1, audioConfig_2_1} {} - IBluetoothSourceTransportInstance(SessionType_2_1 sessionType_2_1, - AudioConfiguration_2_2 audioConfig_2_2) - : IBluetoothTransportInstance{sessionType_2_1, audioConfig_2_2} {} virtual ~IBluetoothSourceTransportInstance() = default; // Invoked when the transport is requested to log bytes written @@ -223,8 +192,7 @@ class BluetoothAudioClientInterface { virtual ~BluetoothAudioClientInterface() = default; bool IsValid() const { - return provider_ != nullptr || provider_2_1_ != nullptr || - provider_2_2_ != nullptr; + return provider_ != nullptr || provider_2_1_ != nullptr; } std::vector<AudioCapabilities> GetAudioCapabilities() const; @@ -233,8 +201,6 @@ class BluetoothAudioClientInterface { SessionType session_type); static std::vector<AudioCapabilities_2_1> GetAudioCapabilities_2_1( SessionType_2_1 session_type_2_1); - static std::vector<AudioCapabilities_2_2> GetAudioCapabilities_2_2( - SessionType_2_1 session_type_2_1); void StreamStarted(const BluetoothAudioCtrlAck& ack); @@ -242,7 +208,6 @@ class BluetoothAudioClientInterface { int StartSession(); int StartSession_2_1(); - int StartSession_2_2(); // Renew the connection and usually is used when HIDL restarted void RenewAudioProviderAndSession(); @@ -251,12 +216,9 @@ class BluetoothAudioClientInterface { bool UpdateAudioConfig(const AudioConfiguration& audioConfig); bool UpdateAudioConfig_2_1(const AudioConfiguration_2_1& audioConfig_2_1); - bool UpdateAudioConfig_2_2(const AudioConfiguration_2_2& audioConfig_2_2); void FlushAudioData(); - void SetLowLatencyModeAllowed(bool allowed); - static constexpr PcmParameters kInvalidPcmConfiguration = { .sampleRate = SampleRate::RATE_UNKNOWN, .channelMode = ChannelMode::UNKNOWN, @@ -268,12 +230,9 @@ class BluetoothAudioClientInterface { void FetchAudioProvider(); // Helper function to connect to an IBluetoothAudioProvider 2.1 void FetchAudioProvider_2_1(); - // Helper function to connect to an IBluetoothAudioProvider 2.2 - void FetchAudioProvider_2_2(); android::sp<IBluetoothAudioProvider> provider_; android::sp<IBluetoothAudioProvider_2_1> provider_2_1_; - android::sp<IBluetoothAudioProvider_2_2> provider_2_2_; bool session_started_; std::unique_ptr<::android::hardware::MessageQueue< uint8_t, ::android::hardware::kSynchronizedReadWrite>> @@ -284,7 +243,6 @@ class BluetoothAudioClientInterface { IBluetoothTransportInstance* transport_; std::vector<AudioCapabilities> capabilities_; std::vector<AudioCapabilities_2_1> capabilities_2_1_; - std::vector<AudioCapabilities_2_2> capabilities_2_2_; }; // The client interface connects an IBluetoothTransportInstance to diff --git a/system/audio_hal_interface/hidl/client_interface_hidl_unittest.cc b/system/audio_hal_interface/hidl/client_interface_hidl_unittest.cc index 7defcdfbb4..7f45cb050e 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl_unittest.cc +++ b/system/audio_hal_interface/hidl/client_interface_hidl_unittest.cc @@ -164,8 +164,6 @@ class TestSinkTransport } void MetadataChanged( const source_metadata_t& source_metadata __unused) override {} - void SinkMetadataChanged( - const sink_metadata_t& sink_metadata __unused) override {} void ResetPresentationPosition() override{}; void LogBytesRead(size_t bytes_readed __unused) override{}; }; @@ -205,8 +203,6 @@ class TestSourceTransport } void MetadataChanged( const source_metadata_t& source_metadata __unused) override {} - void SinkMetadataChanged( - const sink_metadata_t& sink_metadata __unused) override {} void ResetPresentationPosition() override{}; void LogBytesWritten(size_t bytes_written __unused) override{}; }; diff --git a/system/audio_hal_interface/hidl/codec_status_hidl.h b/system/audio_hal_interface/hidl/codec_status_hidl.h index 7f010b8d15..8ed431c80e 100644 --- a/system/audio_hal_interface/hidl/codec_status_hidl.h +++ b/system/audio_hal_interface/hidl/codec_status_hidl.h @@ -16,7 +16,7 @@ #pragma once -#include <android/hardware/bluetooth/audio/2.2/types.h> +#include <android/hardware/bluetooth/audio/2.1/types.h> #include <vector> diff --git a/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc b/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc index 3bb48b6949..ed2f963dcf 100644 --- a/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc +++ b/system/audio_hal_interface/hidl/hearing_aid_software_encoding_hidl.cc @@ -106,8 +106,6 @@ class HearingAidTransport } } - void SinkMetadataChanged(const sink_metadata_t&) override {} - void ResetPresentationPosition() override { VLOG(2) << __func__ << ": called."; remote_delay_report_ms_ = 0; diff --git a/system/audio_hal_interface/hidl/le_audio_software_hidl.cc b/system/audio_hal_interface/hidl/le_audio_software_hidl.cc index 9336a0c53b..a87b5c26bc 100644 --- a/system/audio_hal_interface/hidl/le_audio_software_hidl.cc +++ b/system/audio_hal_interface/hidl/le_audio_software_hidl.cc @@ -19,12 +19,6 @@ #include "le_audio_software_hidl.h" -#include <unordered_map> -#include <vector> - -#include "codec_status_hidl.h" -#include "hal_version_manager.h" - namespace bluetooth { namespace audio { namespace hidl { @@ -32,20 +26,10 @@ namespace le_audio { using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample; using ::android::hardware::bluetooth::audio::V2_0::ChannelMode; -using ::android::hardware::bluetooth::audio::V2_1::CodecType; -using ::android::hardware::bluetooth::audio::V2_1::Lc3FrameDuration; -using ::android::hardware::bluetooth::audio::V2_1::Lc3Parameters; -using ::android::hardware::bluetooth::audio::V2_2::AudioLocation; +using ::android::hardware::bluetooth::audio::V2_0::CodecType; using ::bluetooth::audio::hidl::SampleRate_2_1; using ::bluetooth::audio::hidl::SessionType; using ::bluetooth::audio::hidl::SessionType_2_1; -using AudioCapabilities_2_2 = - ::android::hardware::bluetooth::audio::V2_2::AudioCapabilities; -using ::android::hardware::bluetooth::audio::V2_2::LeAudioMode; -using ::android::hardware::bluetooth::audio::V2_2::UnicastConfig; -using ::android::hardware::bluetooth::audio::V2_2::UnicastStreamMap; -using ::le_audio::set_configurations::SetConfiguration; -using ::le_audio::types::LeAudioLc3Config; using ::bluetooth::audio::le_audio::LeAudioClientInterface; @@ -102,46 +86,6 @@ static ChannelMode le_audio_channel_mode2audio_hal(uint8_t channels_count) { return ChannelMode::UNKNOWN; } -static Lc3FrameDuration le_audio_frame_duration2audio_hal( - uint8_t frame_duration) { - switch (frame_duration) { - case 10000: - return Lc3FrameDuration::DURATION_10000US; - case 7500: - return Lc3FrameDuration::DURATION_7500US; - } - // TODO: handle error in the aidl version - return Lc3FrameDuration::DURATION_10000US; -} - -AudioConfiguration_2_2 offload_config_to_hal_audio_config( - const ::le_audio::offload_config& offload_config) { - AudioConfiguration_2_2 audio_config; - std::vector<UnicastStreamMap> unicast_map; - for (auto& [handle, location] : offload_config.stream_map) { - UnicastStreamMap stream = {.streamHandle = handle, - .audioChannelAllocation = location}; - unicast_map.emplace_back(stream); - } - hidl_vec<UnicastStreamMap> hal_map; - hal_map.setToExternal(unicast_map.data(), unicast_map.size()); - LeAudioConfiguration le_audio_config; - le_audio_config.mode = LeAudioMode::UNICAST; - le_audio_config.config.unicastConfig() = { - .streamMap = std::move(hal_map), - .peerDelay = offload_config.peer_delay_ms, - .lc3Config = {.pcmBitDepth = le_audio_bits_per_sample2audio_hal( - offload_config.bits_per_sample), - .samplingFrequency = le_audio_sample_rate2audio_hal( - offload_config.sampling_rate), - .frameDuration = le_audio_frame_duration2audio_hal( - offload_config.frame_duration), - .octetsPerFrame = offload_config.octets_per_frame, - .blocksPerSdu = offload_config.blocks_per_sdu}}; - audio_config.leAudioConfig(le_audio_config); - return audio_config; -} - bool is_source_hal_enabled() { return LeAudioSourceTransport::interface != nullptr; } @@ -218,19 +162,6 @@ void LeAudioTransport::MetadataChanged( stream_cb_.on_metadata_update_(source_metadata); } -void LeAudioTransport::SinkMetadataChanged( - const sink_metadata_t& sink_metadata) { - auto track_count = sink_metadata.track_count; - - if (track_count == 0) { - LOG(WARNING) << ", invalid number of metadata changed tracks"; - return; - } - - if (stream_cb_.on_sink_metadata_update_) - stream_cb_.on_sink_metadata_update_(sink_metadata); -} - void LeAudioTransport::ResetPresentationPosition() { VLOG(2) << __func__ << ": called."; remote_delay_report_ms_ = 0; @@ -279,8 +210,7 @@ void flush_sink() { LeAudioSinkTransport::LeAudioSinkTransport(SessionType_2_1 session_type, StreamCallbacks stream_cb) - : IBluetoothSinkTransportInstance(session_type, - (AudioConfiguration_2_2){}) { + : IBluetoothSinkTransportInstance(session_type, {}) { transport_ = new LeAudioTransport(flush_sink, std::move(stream_cb), {SampleRate_2_1::RATE_16000, ChannelMode::STEREO, @@ -311,11 +241,6 @@ void LeAudioSinkTransport::MetadataChanged( transport_->MetadataChanged(source_metadata); } -void LeAudioSinkTransport::SinkMetadataChanged( - const sink_metadata_t& sink_metadata) { - transport_->SinkMetadataChanged(sink_metadata); -} - void LeAudioSinkTransport::ResetPresentationPosition() { transport_->ResetPresentationPosition(); } @@ -354,8 +279,7 @@ void flush_source() { LeAudioSourceTransport::LeAudioSourceTransport(SessionType_2_1 session_type, StreamCallbacks stream_cb) - : IBluetoothSourceTransportInstance(session_type, - (AudioConfiguration_2_2){}) { + : IBluetoothSourceTransportInstance(session_type, {}) { transport_ = new LeAudioTransport(flush_source, std::move(stream_cb), {SampleRate_2_1::RATE_16000, ChannelMode::MONO, @@ -386,11 +310,6 @@ void LeAudioSourceTransport::MetadataChanged( transport_->MetadataChanged(source_metadata); } -void LeAudioSourceTransport::SinkMetadataChanged( - const sink_metadata_t& sink_metadata) { - transport_->SinkMetadataChanged(sink_metadata); -} - void LeAudioSourceTransport::ResetPresentationPosition() { transport_->ResetPresentationPosition(); } @@ -421,139 +340,6 @@ void LeAudioSourceTransport::ClearPendingStartStream(void) { transport_->ClearPendingStartStream(); } -std::unordered_map<SampleRate_2_1, uint8_t> sampling_freq_map{ - {SampleRate_2_1::RATE_8000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq8000Hz}, - {SampleRate_2_1::RATE_16000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq16000Hz}, - {SampleRate_2_1::RATE_24000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq24000Hz}, - {SampleRate_2_1::RATE_32000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq32000Hz}, - {SampleRate_2_1::RATE_44100, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq44100Hz}, - {SampleRate_2_1::RATE_48000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq48000Hz}, - {SampleRate_2_1::RATE_88200, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq88200Hz}, - {SampleRate_2_1::RATE_96000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq96000Hz}, - {SampleRate_2_1::RATE_176400, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq176400Hz}, - {SampleRate_2_1::RATE_192000, - ::le_audio::codec_spec_conf::kLeAudioSamplingFreq192000Hz}}; - -std::unordered_map<Lc3FrameDuration, uint8_t> frame_duration_map{ - {Lc3FrameDuration::DURATION_7500US, - ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameDur7500us}, - {Lc3FrameDuration::DURATION_10000US, - ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameDur10000us}}; - -std::unordered_map<uint32_t, uint16_t> octets_per_frame_map{ - {30, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen30}, - {40, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen40}, - {120, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen120}}; - -std::unordered_map<AudioLocation, uint32_t> audio_location_map{ - {AudioLocation::UNKNOWN, - ::le_audio::codec_spec_conf::kLeAudioLocationMonoUnspecified}, - {AudioLocation::FRONT_LEFT, - ::le_audio::codec_spec_conf::kLeAudioLocationFrontLeft}, - {AudioLocation::FRONT_RIGHT, - ::le_audio::codec_spec_conf::kLeAudioLocationFrontRight}, - {static_cast<AudioLocation>(AudioLocation::FRONT_LEFT | - AudioLocation::FRONT_RIGHT), - ::le_audio::codec_spec_conf::kLeAudioLocationFrontLeft | - ::le_audio::codec_spec_conf::kLeAudioLocationFrontRight}}; - -bool halConfigToCodecCapabilitySetting( - UnicastCapability halConfig, CodecCapabilitySetting& codecCapability) { - if (halConfig.codecType != CodecType::LC3) { - LOG(WARNING) << "Unsupported codecType: " << toString(halConfig.codecType); - return false; - } - - Lc3Parameters halLc3Config = halConfig.capabilities; - AudioLocation supportedChannel = halConfig.supportedChannel; - - if (sampling_freq_map.find(halLc3Config.samplingFrequency) == - sampling_freq_map.end() || - frame_duration_map.find(halLc3Config.frameDuration) == - frame_duration_map.end() || - octets_per_frame_map.find(halLc3Config.octetsPerFrame) == - octets_per_frame_map.end() || - audio_location_map.find(supportedChannel) == audio_location_map.end()) { - LOG(ERROR) << __func__ << ": Failed to convert HAL format to stack format" - << "\nsample rate = " << (uint8_t)halLc3Config.samplingFrequency - << "\nframe duration = " << (uint8_t)halLc3Config.frameDuration - << "\noctets per frame= " << halLc3Config.octetsPerFrame - << "\naudio location = " << (uint8_t)supportedChannel; - - return false; - } - - codecCapability = { - .id = ::le_audio::set_configurations::LeAudioCodecIdLc3, - .config = LeAudioLc3Config( - {.sampling_frequency = - sampling_freq_map[halLc3Config.samplingFrequency], - .frame_duration = frame_duration_map[halLc3Config.frameDuration], - .octets_per_codec_frame = - octets_per_frame_map[halLc3Config.octetsPerFrame], - .audio_channel_allocation = audio_location_map[supportedChannel]})}; - - return true; -} - -std::vector<AudioSetConfiguration> get_offload_capabilities() { - LOG(INFO) << __func__; - std::vector<AudioSetConfiguration> offload_capabilities; - std::vector<AudioCapabilities_2_2> le_audio_hal_capabilities = - BluetoothAudioSinkClientInterface::GetAudioCapabilities_2_2( - SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH); - std::string strCapabilityLog; - - for (auto halCapability : le_audio_hal_capabilities) { - CodecCapabilitySetting encodeCapability; - CodecCapabilitySetting decodeCapability; - UnicastCapability halEncodeConfig = - halCapability.leAudioCapabilities().unicastEncodeCapability; - UnicastCapability halDecodeConfig = - halCapability.leAudioCapabilities().unicastDecodeCapability; - AudioSetConfiguration audioSetConfig = {.name = "offload capability"}; - strCapabilityLog.clear(); - - if (halConfigToCodecCapabilitySetting(halEncodeConfig, encodeCapability)) { - audioSetConfig.confs.push_back(SetConfiguration( - ::le_audio::types::kLeAudioDirectionSink, halEncodeConfig.deviceCount, - halEncodeConfig.deviceCount * halEncodeConfig.channelCountPerDevice, - encodeCapability)); - strCapabilityLog = " Encode Capability: " + toString(halEncodeConfig); - } - - if (halConfigToCodecCapabilitySetting(halDecodeConfig, decodeCapability)) { - audioSetConfig.confs.push_back(SetConfiguration( - ::le_audio::types::kLeAudioDirectionSource, - halDecodeConfig.deviceCount, - halDecodeConfig.deviceCount * halDecodeConfig.channelCountPerDevice, - decodeCapability)); - strCapabilityLog += " Decode Capability: " + toString(halDecodeConfig); - } - - if (!audioSetConfig.confs.empty()) { - offload_capabilities.push_back(audioSetConfig); - LOG(INFO) << __func__ - << ": Supported codec capability =" << strCapabilityLog; - - } else { - LOG(INFO) << __func__ - << ": Unknown codec capability =" << toString(halCapability); - } - } - - return offload_capabilities; -} - } // namespace le_audio } // namespace hidl } // namespace audio diff --git a/system/audio_hal_interface/hidl/le_audio_software_hidl.h b/system/audio_hal_interface/hidl/le_audio_software_hidl.h index 3a161a619a..3b63c07b3c 100644 --- a/system/audio_hal_interface/hidl/le_audio_software_hidl.h +++ b/system/audio_hal_interface/hidl/le_audio_software_hidl.h @@ -26,9 +26,6 @@ namespace hidl { namespace le_audio { using ::android::hardware::bluetooth::audio::V2_1::PcmParameters; -using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration; -using ::android::hardware::bluetooth::audio::V2_2::UnicastCapability; -using ::bluetooth::audio::hidl::AudioConfiguration_2_2; using ::bluetooth::audio::hidl::BluetoothAudioCtrlAck; using ::le_audio::set_configurations::AudioSetConfiguration; using ::le_audio::set_configurations::CodecCapabilitySetting; @@ -51,15 +48,9 @@ using ::bluetooth::audio::le_audio::StreamCallbacks; void flush_sink(); void flush_source(); -bool halConfigToCodecCapabilitySetting(UnicastCapability halConfig, - CodecCapabilitySetting& codecCapability); bool is_source_hal_enabled(); bool is_sink_hal_enabled(); -AudioConfiguration_2_2 offload_config_to_hal_audio_config( - const ::le_audio::offload_config& offload_config); - -std::vector<AudioSetConfiguration> get_offload_capabilities(); class LeAudioTransport { public: @@ -78,8 +69,6 @@ class LeAudioTransport { void MetadataChanged(const source_metadata_t& source_metadata); - void SinkMetadataChanged(const sink_metadata_t& sink_metadata); - void ResetPresentationPosition(); void LogBytesProcessed(size_t bytes_processed); @@ -125,8 +114,6 @@ class LeAudioSinkTransport void MetadataChanged(const source_metadata_t& source_metadata) override; - void SinkMetadataChanged(const sink_metadata_t& sink_metadata) override; - void ResetPresentationPosition() override; void LogBytesRead(size_t bytes_read) override; @@ -169,8 +156,6 @@ class LeAudioSourceTransport void MetadataChanged(const source_metadata_t& source_metadata) override; - void SinkMetadataChanged(const sink_metadata_t& sink_metadata) override; - void ResetPresentationPosition() override; void LogBytesWritten(size_t bytes_written) override; diff --git a/system/audio_hal_interface/le_audio_software.cc b/system/audio_hal_interface/le_audio_software.cc index c6a5cc65f9..112ad8f9e7 100644 --- a/system/audio_hal_interface/le_audio_software.cc +++ b/system/audio_hal_interface/le_audio_software.cc @@ -38,8 +38,6 @@ namespace { using ::android::hardware::bluetooth::audio::V2_1::PcmParameters; using AudioConfiguration_2_1 = ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration; -using AudioConfiguration_2_2 = - ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration; using AudioConfigurationAIDL = ::aidl::android::hardware::bluetooth::audio::AudioConfiguration; @@ -51,7 +49,7 @@ using ::le_audio::types::CodecLocation; std::vector<AudioSetConfiguration> get_offload_capabilities() { if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) { - return hidl::le_audio::get_offload_capabilities(); + return std::vector<AudioSetConfiguration>(0); } return aidl::le_audio::get_offload_capabilities(); } @@ -133,25 +131,6 @@ void LeAudioClientInterface::Sink::StartSession() { hidl::le_audio::LeAudioSinkTransport::interface->StartSession_2_1(); return; } else if (HalVersionManager::GetHalVersion() == - BluetoothAudioHalVersion::VERSION_2_2) { - AudioConfiguration_2_2 audio_config; - if (hidl::le_audio::LeAudioSinkTransport::interface->GetTransportInstance() - ->GetSessionType_2_1() == - hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { - hidl::le_audio::LeAudioConfiguration le_audio_config = {}; - audio_config.leAudioConfig(le_audio_config); - } else { - audio_config.pcmConfig(hidl::le_audio::LeAudioSinkTransport::instance - ->LeAudioGetSelectedHalPcmConfig()); - } - if (!hidl::le_audio::LeAudioSinkTransport::interface->UpdateAudioConfig_2_2( - audio_config)) { - LOG(ERROR) << __func__ << ": cannot update audio config to HAL"; - return; - } - hidl::le_audio::LeAudioSinkTransport::interface->StartSession_2_2(); - return; - } else if (HalVersionManager::GetHalVersion() == BluetoothAudioHalVersion::VERSION_AIDL_V1) { AudioConfigurationAIDL audio_config; if (aidl::le_audio::LeAudioSinkTransport::interface->GetTransportInstance() @@ -236,13 +215,6 @@ void LeAudioClientInterface::Sink::UpdateAudioConfigToHal( const ::le_audio::offload_config& offload_config) { if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) { - if (hidl::le_audio::LeAudioSinkTransport::interface->GetTransportInstance() - ->GetSessionType_2_1() != - hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { - return; - } - hidl::le_audio::LeAudioSinkTransport::interface->UpdateAudioConfig_2_2( - hidl::le_audio::offload_config_to_hal_audio_config(offload_config)); return; } if (aidl::le_audio::LeAudioSinkTransport::interface->GetTransportInstance() @@ -330,27 +302,6 @@ void LeAudioClientInterface::Source::StartSession() { hidl::le_audio::LeAudioSourceTransport::interface->StartSession_2_1(); return; } else if (HalVersionManager::GetHalVersion() == - BluetoothAudioHalVersion::VERSION_2_2) { - AudioConfiguration_2_2 audio_config; - if (hidl::le_audio::LeAudioSourceTransport:: - interface->GetTransportInstance() - ->GetSessionType_2_1() == - hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) { - hidl::le_audio::LeAudioConfiguration le_audio_config = {}; - audio_config.leAudioConfig(le_audio_config); - } else { - audio_config.pcmConfig(hidl::le_audio::LeAudioSourceTransport::instance - ->LeAudioGetSelectedHalPcmConfig()); - } - - if (!hidl::le_audio::LeAudioSourceTransport:: - interface->UpdateAudioConfig_2_2(audio_config)) { - LOG(ERROR) << __func__ << ": cannot update audio config to HAL"; - return; - } - hidl::le_audio::LeAudioSourceTransport::interface->StartSession_2_2(); - return; - } else if (HalVersionManager::GetHalVersion() == BluetoothAudioHalVersion::VERSION_AIDL_V1) { AudioConfigurationAIDL audio_config; if (aidl::le_audio::LeAudioSourceTransport:: @@ -439,16 +390,16 @@ void LeAudioClientInterface::Source::UpdateAudioConfigToHal( const ::le_audio::offload_config& offload_config) { if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) { - if (hidl::le_audio::LeAudioSourceTransport:: - interface->GetTransportInstance() - ->GetSessionType_2_1() != - hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) { - return; - } - hidl::le_audio::LeAudioSourceTransport::interface->UpdateAudioConfig_2_2( - hidl::le_audio::offload_config_to_hal_audio_config(offload_config)); return; } + + if (aidl::le_audio::LeAudioSourceTransport::interface->GetTransportInstance() + ->GetSessionType() != + aidl::SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) { + return; + } + aidl::le_audio::LeAudioSourceTransport::interface->UpdateAudioConfig( + aidl::le_audio::offload_config_to_hal_audio_config(offload_config)); } size_t LeAudioClientInterface::Source::Write(const uint8_t* p_buf, @@ -478,11 +429,6 @@ LeAudioClientInterface::Sink* LeAudioClientInterface::GetSink( BluetoothAudioHalTransport::HIDL) { hidl::SessionType_2_1 session_type = hidl::SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH; - if (CodecManager::GetInstance()->GetCodecLocation() != - CodecLocation::HOST) { - session_type = - hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH; - } hidl::le_audio::LeAudioSinkTransport::instance = new hidl::le_audio::LeAudioSinkTransport(session_type, diff --git a/system/bta/Android.bp b/system/bta/Android.bp index 2fa0b7d49d..03a35f9489 100644 --- a/system/bta/Android.bp +++ b/system/bta/Android.bp @@ -149,7 +149,6 @@ cc_library_static { shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", ], target: { android: { @@ -632,7 +631,6 @@ cc_test { shared_libs: [ "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "libprotobuf-cpp-lite", "libcrypto", "liblog", diff --git a/system/bta/le_audio/hal_verifier.cc b/system/bta/le_audio/hal_verifier.cc index 1e4287e846..2367593a45 100644 --- a/system/bta/le_audio/hal_verifier.cc +++ b/system/bta/le_audio/hal_verifier.cc @@ -23,8 +23,8 @@ bool LeAudioHalVerifier::SupportsLeAudio() { } bool LeAudioHalVerifier::SupportsLeAudioHardwareOffload() { - return bluetooth::audio::HalVersionManager::GetHalVersion() > - bluetooth::audio::BluetoothAudioHalVersion::VERSION_2_1; + return bluetooth::audio::HalVersionManager::GetHalTransport() == + bluetooth::audio::BluetoothAudioHalTransport::AIDL; } bool LeAudioHalVerifier::SupportsLeAudioBroadcast() { diff --git a/system/btif/Android.bp b/system/btif/Android.bp index d46119fe8e..c31250d800 100644 --- a/system/btif/Android.bp +++ b/system/btif/Android.bp @@ -164,7 +164,6 @@ cc_defaults { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "libcrypto", "libflatbuffers-cpp", "libhidlbase", @@ -228,7 +227,6 @@ cc_test { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.system.suspend.control-V1-ndk", "libbinder_ndk", "libfmq", @@ -469,7 +467,6 @@ cc_test { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "libcrypto", "libcutils", "libflatbuffers-cpp", diff --git a/system/main/Android.bp b/system/main/Android.bp index c1cc24f7e9..812340d79b 100644 --- a/system/main/Android.bp +++ b/system/main/Android.bp @@ -124,7 +124,6 @@ cc_library_shared { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.hardware.bluetooth.audio-V1-ndk", "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", diff --git a/system/stack/Android.bp b/system/stack/Android.bp index ac21f97767..8678e6204f 100644 --- a/system/stack/Android.bp +++ b/system/stack/Android.bp @@ -240,7 +240,6 @@ cc_test { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.hardware.bluetooth.audio-V1-ndk", "android.system.suspend.control-V1-ndk", "libaaudio", diff --git a/system/stack/test/fuzzers/Android.bp b/system/stack/test/fuzzers/Android.bp index fc26b01c4d..ca3c6a3afc 100644 --- a/system/stack/test/fuzzers/Android.bp +++ b/system/stack/test/fuzzers/Android.bp @@ -51,7 +51,6 @@ cc_defaults { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.hardware.bluetooth.audio-V1-ndk", "android.system.suspend.control-V1-ndk", "libaaudio", diff --git a/system/test/headless/Android.bp b/system/test/headless/Android.bp index eb8e2da30b..b0f6c343e2 100644 --- a/system/test/headless/Android.bp +++ b/system/test/headless/Android.bp @@ -60,7 +60,6 @@ cc_test { "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", - "android.hardware.bluetooth.audio@2.2", "android.hardware.bluetooth.audio-V1-ndk", "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", |