From 18f0d5121af3701decc0b2b306fbe5e8a2db7265 Mon Sep 17 00:00:00 2001 From: Ram Mohan Date: Sat, 1 Jul 2023 00:47:09 +0530 Subject: [PATCH] aosp aidl bluetooth parameter support Bug: 228804498 Test: atest VtsHalAudioCoreTargetTest Change-Id: If1820018d5a6750eed0d0b486e15fc7c717aa11c --- audio/aidl/default/Bluetooth.cpp | 15 +++--- audio/aidl/default/Module.cpp | 9 ++++ audio/aidl/default/Stream.cpp | 5 ++ audio/aidl/default/StreamSwitcher.cpp | 20 +++++++ .../default/bluetooth/DevicePortProxy.cpp | 15 ++++++ .../default/bluetooth/ModuleBluetooth.cpp | 32 +++++++++++- .../default/bluetooth/StreamBluetooth.cpp | 52 ++++++++++++++++--- .../default/include/core-impl/Bluetooth.h | 13 ++++- .../include/core-impl/DevicePortProxy.h | 13 ++++- audio/aidl/default/include/core-impl/Module.h | 7 +++ .../include/core-impl/ModuleBluetooth.h | 8 +++ audio/aidl/default/include/core-impl/Stream.h | 15 ++++++ .../include/core-impl/StreamBluetooth.h | 19 +++++-- .../include/core-impl/StreamSwitcher.h | 2 + 14 files changed, 199 insertions(+), 26 deletions(-) diff --git a/audio/aidl/default/Bluetooth.cpp b/audio/aidl/default/Bluetooth.cpp index c32b538ecc..072b89fefb 100644 --- a/audio/aidl/default/Bluetooth.cpp +++ b/audio/aidl/default/Bluetooth.cpp @@ -82,19 +82,18 @@ ndk::ScopedAStatus Bluetooth::setHfpConfig(const HfpConfig& in_config, HfpConfig ndk::ScopedAStatus BluetoothA2dp::isEnabled(bool* _aidl_return) { *_aidl_return = mEnabled; - LOG(DEBUG) << __func__ << ": returning " << *_aidl_return; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothA2dp::setEnabled(bool in_enabled) { mEnabled = in_enabled; LOG(DEBUG) << __func__ << ": " << mEnabled; + if (mHandler) return mHandler(); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothA2dp::supportsOffloadReconfiguration(bool* _aidl_return) { - *_aidl_return = true; - LOG(DEBUG) << __func__ << ": returning " << *_aidl_return; + *_aidl_return = false; return ndk::ScopedAStatus::ok(); } @@ -102,24 +101,22 @@ ndk::ScopedAStatus BluetoothA2dp::reconfigureOffload( const std::vector<::aidl::android::hardware::audio::core::VendorParameter>& in_parameters __unused) { LOG(DEBUG) << __func__ << ": " << ::android::internal::ToString(in_parameters); - return ndk::ScopedAStatus::ok(); + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } ndk::ScopedAStatus BluetoothLe::isEnabled(bool* _aidl_return) { *_aidl_return = mEnabled; - LOG(DEBUG) << __func__ << ": returning " << *_aidl_return; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothLe::setEnabled(bool in_enabled) { mEnabled = in_enabled; - LOG(DEBUG) << __func__ << ": " << mEnabled; + if (mHandler) return mHandler(); return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothLe::supportsOffloadReconfiguration(bool* _aidl_return) { - *_aidl_return = true; - LOG(DEBUG) << __func__ << ": returning " << *_aidl_return; + *_aidl_return = false; return ndk::ScopedAStatus::ok(); } @@ -127,7 +124,7 @@ ndk::ScopedAStatus BluetoothLe::reconfigureOffload( const std::vector<::aidl::android::hardware::audio::core::VendorParameter>& in_parameters __unused) { LOG(DEBUG) << __func__ << ": " << ::android::internal::ToString(in_parameters); - return ndk::ScopedAStatus::ok(); + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp index 5625a44400..f81095e02c 100644 --- a/audio/aidl/default/Module.cpp +++ b/audio/aidl/default/Module.cpp @@ -1371,4 +1371,13 @@ ndk::ScopedAStatus Module::onMasterVolumeChanged(float volume __unused) { return ndk::ScopedAStatus::ok(); } +Module::BtProfileHandles Module::getBtProfileManagerHandles() { + return std::make_tuple(std::weak_ptr(), std::weak_ptr(), + std::weak_ptr()); +} + +ndk::ScopedAStatus Module::bluetoothParametersUpdated() { + return mStreams.bluetoothParametersUpdated(); +} + } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/Stream.cpp b/audio/aidl/default/Stream.cpp index d2be48c389..c5b25d6047 100644 --- a/audio/aidl/default/Stream.cpp +++ b/audio/aidl/default/Stream.cpp @@ -723,6 +723,11 @@ ndk::ScopedAStatus StreamCommonImpl::setConnectedDevices( return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus StreamCommonImpl::bluetoothParametersUpdated() { + LOG(DEBUG) << __func__; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); +} + namespace { static std::map transformMicrophones( const std::vector& microphones) { diff --git a/audio/aidl/default/StreamSwitcher.cpp b/audio/aidl/default/StreamSwitcher.cpp index e00c34b50f..ed4cc8afb2 100644 --- a/audio/aidl/default/StreamSwitcher.cpp +++ b/audio/aidl/default/StreamSwitcher.cpp @@ -233,8 +233,28 @@ ndk::ScopedAStatus StreamSwitcher::setConnectedDevices(const std::vectorbluetoothParametersUpdated(); !status.isOk()) { + LOG(WARNING) << __func__ + << ": error while updating BT parameters for a new stream: " + << status.getDescription(); + } + } + mBluetoothParametersUpdated = false; } return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus StreamSwitcher::bluetoothParametersUpdated() { + if (mStream == nullptr) { + LOG(ERROR) << __func__ << ": stream was closed"; + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + if (mIsStubStream) { + mBluetoothParametersUpdated = true; + return ndk::ScopedAStatus::ok(); + } + return mStream->bluetoothParametersUpdated(); +} + } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/bluetooth/DevicePortProxy.cpp b/audio/aidl/default/bluetooth/DevicePortProxy.cpp index aabf60fac3..12e204a076 100644 --- a/audio/aidl/default/bluetooth/DevicePortProxy.cpp +++ b/audio/aidl/default/bluetooth/DevicePortProxy.cpp @@ -302,6 +302,21 @@ bool BluetoothAudioPortAidl::loadAudioConfig(PcmConfiguration* audio_cfg) const return true; } +bool BluetoothAudioPortAidl::standby() { + if (!inUse()) { + LOG(ERROR) << __func__ << ": BluetoothAudioPortAidl is not in use"; + return false; + } + std::lock_guard guard(mCvMutex); + LOG(VERBOSE) << __func__ << debugMessage() << ", state=" << getState() << " request"; + if (mState == BluetoothStreamState::DISABLED) { + mState = BluetoothStreamState::STANDBY; + LOG(VERBOSE) << __func__ << debugMessage() << ", state=" << getState() << " done"; + return true; + } + return false; +} + bool BluetoothAudioPortAidl::condWaitState(BluetoothStreamState state) { const auto waitTime = std::chrono::milliseconds(kMaxWaitingTimeMs); std::unique_lock lock(mCvMutex); diff --git a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp index bb11f0ae85..bfe7ca0384 100644 --- a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp +++ b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp @@ -28,6 +28,34 @@ using aidl::android::hardware::audio::common::SourceMetadata; using aidl::android::media::audio::common::AudioOffloadInfo; using aidl::android::media::audio::common::MicrophoneInfo; +ndk::ScopedAStatus ModuleBluetooth::getBluetoothA2dp( + std::shared_ptr* _aidl_return) { + if (!mBluetoothA2dp) { + auto handle = ndk::SharedRefBase::make(); + handle->registerHandler(std::bind(&ModuleBluetooth::bluetoothParametersUpdated, this)); + mBluetoothA2dp = handle; + } + *_aidl_return = mBluetoothA2dp.getInstance(); + LOG(DEBUG) << __func__ << ": returning instance of IBluetoothA2dp: " << _aidl_return->get(); + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus ModuleBluetooth::getBluetoothLe(std::shared_ptr* _aidl_return) { + if (!mBluetoothLe) { + auto handle = ndk::SharedRefBase::make(); + handle->registerHandler(std::bind(&ModuleBluetooth::bluetoothParametersUpdated, this)); + mBluetoothLe = handle; + } + *_aidl_return = mBluetoothLe.getInstance(); + LOG(DEBUG) << __func__ << ": returning instance of IBluetoothLe: " << _aidl_return->get(); + return ndk::ScopedAStatus::ok(); +} + +Module::BtProfileHandles ModuleBluetooth::getBtProfileManagerHandles() { + return std::make_tuple(std::weak_ptr(), mBluetoothA2dp.getInstance(), + mBluetoothLe.getInstance()); +} + ndk::ScopedAStatus ModuleBluetooth::getMicMute(bool* _aidl_return __unused) { LOG(DEBUG) << __func__ << ": is not supported"; return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); @@ -42,14 +70,14 @@ ndk::ScopedAStatus ModuleBluetooth::createInputStream( StreamContext&& context, const SinkMetadata& sinkMetadata, const std::vector& microphones, std::shared_ptr* result) { return createStreamInstance(result, std::move(context), sinkMetadata, - microphones); + microphones, getBtProfileManagerHandles()); } ndk::ScopedAStatus ModuleBluetooth::createOutputStream( StreamContext&& context, const SourceMetadata& sourceMetadata, const std::optional& offloadInfo, std::shared_ptr* result) { return createStreamInstance(result, std::move(context), sourceMetadata, - offloadInfo); + offloadInfo, getBtProfileManagerHandles()); } ndk::ScopedAStatus ModuleBluetooth::onMasterMuteChanged(bool) { diff --git a/audio/aidl/default/bluetooth/StreamBluetooth.cpp b/audio/aidl/default/bluetooth/StreamBluetooth.cpp index dfccb0eec5..8cb93e3cea 100644 --- a/audio/aidl/default/bluetooth/StreamBluetooth.cpp +++ b/audio/aidl/default/bluetooth/StreamBluetooth.cpp @@ -53,13 +53,16 @@ size_t getFrameCount(uint64_t durationUs, uint32_t sampleRate) { } // pcm configuration params are not really used by the module -StreamBluetooth::StreamBluetooth(StreamContext* context, const Metadata& metadata) +StreamBluetooth::StreamBluetooth(StreamContext* context, const Metadata& metadata, + Module::BtProfileHandles&& btHandles) : StreamCommonImpl(context, metadata), mSampleRate(getContext().getSampleRate()), mChannelLayout(getContext().getChannelLayout()), mFormat(getContext().getFormat()), mFrameSizeBytes(getContext().getFrameSize()), - mIsInput(isInput(metadata)) { + mIsInput(isInput(metadata)), + mBluetoothA2dp(std::move(std::get(btHandles))), + mBluetoothLe(std::move(std::get(btHandles))) { mPreferredDataIntervalUs = mIsInput ? kBluetoothDefaultInputBufferMs : kBluetoothDefaultOutputBufferMs; mPreferredFrameCount = getFrameCount(mPreferredDataIntervalUs, mSampleRate); @@ -278,10 +281,46 @@ ndk::ScopedAStatus StreamBluetooth::updateMetadataCommon(const Metadata& metadat : ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } +ndk::ScopedAStatus StreamBluetooth::bluetoothParametersUpdated() { + if (mIsInput) { + LOG(WARNING) << __func__ << ": not handled"; + return ndk::ScopedAStatus::ok(); + } + auto applyParam = [](const std::shared_ptr& proxy, + bool isEnabled) -> bool { + if (!isEnabled) { + if (proxy->suspend()) return proxy->setState(BluetoothStreamState::DISABLED); + return false; + } + return proxy->standby(); + }; + bool hasA2dpParam, enableA2dp; + auto btA2dp = mBluetoothA2dp.lock(); + hasA2dpParam = btA2dp != nullptr && btA2dp->isEnabled(&enableA2dp).isOk(); + bool hasLeParam, enableLe; + auto btLe = mBluetoothLe.lock(); + hasLeParam = btLe != nullptr && btLe->isEnabled(&enableLe).isOk(); + std::unique_lock lock(mLock); + ::android::base::ScopedLockAssertion lock_assertion(mLock); + if (!mIsInitialized) { + LOG(WARNING) << __func__ << ": init not done"; + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); + } + for (auto proxy : mBtDeviceProxies) { + if ((hasA2dpParam && proxy->isA2dp() && !applyParam(proxy, enableA2dp)) || + (hasLeParam && proxy->isLeAudio() && !applyParam(proxy, enableLe))) { + LOG(DEBUG) << __func__ << ": applyParam failed"; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + } + return ndk::ScopedAStatus::ok(); +} + StreamInBluetooth::StreamInBluetooth(StreamContext&& context, const SinkMetadata& sinkMetadata, - const std::vector& microphones) + const std::vector& microphones, + Module::BtProfileHandles&& btProfileHandles) : StreamIn(std::move(context), microphones), - StreamBluetooth(&(StreamIn::mContext), sinkMetadata) {} + StreamBluetooth(&(StreamIn::mContext), sinkMetadata, std::move(btProfileHandles)) {} ndk::ScopedAStatus StreamInBluetooth::getActiveMicrophones( std::vector* _aidl_return __unused) { @@ -291,8 +330,9 @@ ndk::ScopedAStatus StreamInBluetooth::getActiveMicrophones( StreamOutBluetooth::StreamOutBluetooth(StreamContext&& context, const SourceMetadata& sourceMetadata, - const std::optional& offloadInfo) + const std::optional& offloadInfo, + Module::BtProfileHandles&& btProfileHandles) : StreamOut(std::move(context), offloadInfo), - StreamBluetooth(&(StreamOut::mContext), sourceMetadata) {} + StreamBluetooth(&(StreamOut::mContext), sourceMetadata, std::move(btProfileHandles)) {} } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/include/core-impl/Bluetooth.h b/audio/aidl/default/include/core-impl/Bluetooth.h index 10e9045042..44899bcee2 100644 --- a/audio/aidl/default/include/core-impl/Bluetooth.h +++ b/audio/aidl/default/include/core-impl/Bluetooth.h @@ -22,6 +22,15 @@ namespace aidl::android::hardware::audio::core { +class ParamChangeHandler { + public: + ParamChangeHandler() = default; + void registerHandler(std::function handler) { mHandler = handler; } + + protected: + std::function mHandler = nullptr; +}; + class Bluetooth : public BnBluetooth { public: Bluetooth(); @@ -34,7 +43,7 @@ class Bluetooth : public BnBluetooth { HfpConfig mHfpConfig; }; -class BluetoothA2dp : public BnBluetoothA2dp { +class BluetoothA2dp : public BnBluetoothA2dp, public ParamChangeHandler { public: BluetoothA2dp() = default; @@ -49,7 +58,7 @@ class BluetoothA2dp : public BnBluetoothA2dp { bool mEnabled = false; }; -class BluetoothLe : public BnBluetoothLe { +class BluetoothLe : public BnBluetoothLe, public ParamChangeHandler { public: BluetoothLe() = default; diff --git a/audio/aidl/default/include/core-impl/DevicePortProxy.h b/audio/aidl/default/include/core-impl/DevicePortProxy.h index 72ffaadafc..13b8c9136e 100644 --- a/audio/aidl/default/include/core-impl/DevicePortProxy.h +++ b/audio/aidl/default/include/core-impl/DevicePortProxy.h @@ -83,8 +83,16 @@ class BluetoothAudioPort { /** * When the Audio framework / HAL wants to change the stream state, it invokes - * these 3 functions to control the Bluetooth stack (Audio Control Path). - * Note: Both start() and suspend() will return true when there are no errors. + * these 4 functions to control the Bluetooth stack (Audio Control Path). + * Note: standby(), start() and suspend() will return true when there are no errors. + + * Called by Audio framework / HAL to change the state to stand by. When A2DP/LE profile is + * disabled, the port is first set to STANDBY by calling suspend and then mState is set to + * DISABLED. To reset the state back to STANDBY this method is called. + */ + virtual bool standby() = 0; + + /** * Called by Audio framework / HAL to start the stream */ virtual bool start() = 0; @@ -160,6 +168,7 @@ class BluetoothAudioPortAidl : public BluetoothAudioPort { void forcePcmStereoToMono(bool force) override { mIsStereoToMono = force; } + bool standby() override; bool start() override; bool suspend() override; void stop() override; diff --git a/audio/aidl/default/include/core-impl/Module.h b/audio/aidl/default/include/core-impl/Module.h index e52940eeb1..fb3eef214f 100644 --- a/audio/aidl/default/include/core-impl/Module.h +++ b/audio/aidl/default/include/core-impl/Module.h @@ -34,11 +34,16 @@ class Module : public BnModule { // This value is used for all AudioPatches and reported by all streams. static constexpr int32_t kLatencyMs = 10; enum Type : int { DEFAULT, R_SUBMIX, STUB, USB, BLUETOOTH }; + enum BtInterface : int { BTCONF, BTA2DP, BTLE }; static std::shared_ptr createInstance(Type type); explicit Module(Type type) : mType(type) {} + typedef std::tuple, std::weak_ptr, + std::weak_ptr> + BtProfileHandles; + protected: // The vendor extension done via inheritance can override interface methods and augment // a call to the base implementation. @@ -185,6 +190,7 @@ class Module : public BnModule { virtual std::unique_ptr initializeConfig(); // Utility and helper functions accessible to subclasses. + ndk::ScopedAStatus bluetoothParametersUpdated(); void cleanUpPatch(int32_t patchId); ndk::ScopedAStatus createStreamContext( int32_t in_portConfigId, int64_t in_bufferSizeFrames, @@ -196,6 +202,7 @@ class Module : public BnModule { std::set findConnectedPortConfigIds(int32_t portConfigId); ndk::ScopedAStatus findPortIdForNewStream( int32_t in_portConfigId, ::aidl::android::media::audio::common::AudioPort** port); + virtual BtProfileHandles getBtProfileManagerHandles(); internal::Configuration& getConfig(); const ConnectedDevicePorts& getConnectedDevicePorts() const { return mConnectedDevicePorts; } bool getMasterMute() const { return mMasterMute; } diff --git a/audio/aidl/default/include/core-impl/ModuleBluetooth.h b/audio/aidl/default/include/core-impl/ModuleBluetooth.h index e20f7a3d25..68b4e6b058 100644 --- a/audio/aidl/default/include/core-impl/ModuleBluetooth.h +++ b/audio/aidl/default/include/core-impl/ModuleBluetooth.h @@ -16,6 +16,7 @@ #pragma once +#include "core-impl/Bluetooth.h" #include "core-impl/Module.h" namespace aidl::android::hardware::audio::core { @@ -25,6 +26,10 @@ class ModuleBluetooth final : public Module { ModuleBluetooth() : Module(Type::BLUETOOTH) {} private: + BtProfileHandles getBtProfileManagerHandles() override; + + ndk::ScopedAStatus getBluetoothA2dp(std::shared_ptr* _aidl_return) override; + ndk::ScopedAStatus getBluetoothLe(std::shared_ptr* _aidl_return) override; ndk::ScopedAStatus getMicMute(bool* _aidl_return) override; ndk::ScopedAStatus setMicMute(bool in_mute) override; @@ -41,6 +46,9 @@ class ModuleBluetooth final : public Module { std::shared_ptr* result) override; ndk::ScopedAStatus onMasterMuteChanged(bool mute) override; ndk::ScopedAStatus onMasterVolumeChanged(float volume) override; + + ChildInterface mBluetoothA2dp; + ChildInterface mBluetoothLe; }; } // namespace aidl::android::hardware::audio::core \ No newline at end of file diff --git a/audio/aidl/default/include/core-impl/Stream.h b/audio/aidl/default/include/core-impl/Stream.h index fa2b760861..1ba35200d0 100644 --- a/audio/aidl/default/include/core-impl/Stream.h +++ b/audio/aidl/default/include/core-impl/Stream.h @@ -354,6 +354,7 @@ struct StreamCommonInterface { virtual const ConnectedDevices& getConnectedDevices() const = 0; virtual ndk::ScopedAStatus setConnectedDevices( const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) = 0; + virtual ndk::ScopedAStatus bluetoothParametersUpdated() = 0; }; // This is equivalent to automatically generated 'IStreamCommonDelegator' but uses @@ -454,6 +455,7 @@ class StreamCommonImpl : virtual public StreamCommonInterface, virtual public Dr ndk::ScopedAStatus setConnectedDevices( const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) override; + ndk::ScopedAStatus bluetoothParametersUpdated() override; protected: static StreamWorkerInterface::CreateInstance getDefaultInWorkerCreator() { @@ -584,6 +586,11 @@ class StreamWrapper { if (s) return s->setConnectedDevices(devices); return ndk::ScopedAStatus::ok(); } + ndk::ScopedAStatus bluetoothParametersUpdated() { + auto s = mStream.lock(); + if (s) return s->bluetoothParametersUpdated(); + return ndk::ScopedAStatus::ok(); + } private: std::weak_ptr mStream; @@ -612,6 +619,14 @@ class Streams { } return ndk::ScopedAStatus::ok(); } + ndk::ScopedAStatus bluetoothParametersUpdated() { + bool isOk = true; + for (auto& it : mStreams) { + if (!it.second.bluetoothParametersUpdated().isOk()) isOk = false; + } + return isOk ? ndk::ScopedAStatus::ok() + : ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } private: // Maps port ids and port config ids to streams. Multimap because a port diff --git a/audio/aidl/default/include/core-impl/StreamBluetooth.h b/audio/aidl/default/include/core-impl/StreamBluetooth.h index b9c5ea9bbd..c2f8c1d75b 100644 --- a/audio/aidl/default/include/core-impl/StreamBluetooth.h +++ b/audio/aidl/default/include/core-impl/StreamBluetooth.h @@ -19,15 +19,20 @@ #include #include +#include +#include +#include + #include "core-impl/DevicePortProxy.h" +#include "core-impl/Module.h" #include "core-impl/Stream.h" namespace aidl::android::hardware::audio::core { class StreamBluetooth : public StreamCommonImpl { public: - StreamBluetooth(StreamContext* context, const Metadata& metadata); - + StreamBluetooth(StreamContext* context, const Metadata& metadata, + Module::BtProfileHandles&& btHandles); // Methods of 'DriverInterface'. ::android::status_t init() override; ::android::status_t drain(StreamDescriptor::DrainMode) override; @@ -44,6 +49,7 @@ class StreamBluetooth : public StreamCommonImpl { ndk::ScopedAStatus prepareToClose() override; const ConnectedDevices& getConnectedDevices() const override; ndk::ScopedAStatus setConnectedDevices(const ConnectedDevices& devices) override; + ndk::ScopedAStatus bluetoothParametersUpdated() override; private: // Audio Pcm Config @@ -52,7 +58,8 @@ class StreamBluetooth : public StreamCommonImpl { const ::aidl::android::media::audio::common::AudioFormatDescription mFormat; const size_t mFrameSizeBytes; const bool mIsInput; - + const std::weak_ptr mBluetoothA2dp; + const std::weak_ptr mBluetoothLe; size_t mPreferredDataIntervalUs; size_t mPreferredFrameCount; @@ -72,7 +79,8 @@ class StreamInBluetooth final : public StreamIn, public StreamBluetooth { StreamInBluetooth( StreamContext&& context, const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata, - const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones); + const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones, + Module::BtProfileHandles&& btHandles); private: void onClose(StreamDescriptor::State) override { defaultOnClose(); } @@ -88,7 +96,8 @@ class StreamOutBluetooth final : public StreamOut, public StreamBluetooth { StreamContext&& context, const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata, const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>& - offloadInfo); + offloadInfo, + Module::BtProfileHandles&& btHandles); private: void onClose(StreamDescriptor::State) override { defaultOnClose(); } diff --git a/audio/aidl/default/include/core-impl/StreamSwitcher.h b/audio/aidl/default/include/core-impl/StreamSwitcher.h index 2cb847080c..3086ef98ae 100644 --- a/audio/aidl/default/include/core-impl/StreamSwitcher.h +++ b/audio/aidl/default/include/core-impl/StreamSwitcher.h @@ -129,6 +129,7 @@ class StreamSwitcher : virtual public StreamCommonInterface { ndk::ScopedAStatus setConnectedDevices( const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) override; + ndk::ScopedAStatus bluetoothParametersUpdated() override; protected: // Since switching a stream requires closing down the current stream, StreamSwitcher @@ -187,6 +188,7 @@ class StreamSwitcher : virtual public StreamCommonInterface { std::optional mHwAvSyncId; std::vector mMissedParameters; std::vector> mEffects; + bool mBluetoothParametersUpdated = false; }; } // namespace aidl::android::hardware::audio::core