summaryrefslogtreecommitdiff
path: root/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'bluetooth')
-rw-r--r--bluetooth/audio/2.2/default/OWNERS4
-rw-r--r--bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl5
-rw-r--r--bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl7
-rw-r--r--bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl1
-rw-r--r--bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl5
-rw-r--r--bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl7
-rw-r--r--bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl1
-rw-r--r--bluetooth/audio/aidl/default/A2dpSoftwareAudioProvider.cpp3
-rw-r--r--bluetooth/audio/aidl/default/Android.bp2
-rw-r--r--bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp2
-rw-r--r--bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h7
-rw-r--r--bluetooth/audio/aidl/default/HearingAidAudioProvider.cpp2
-rw-r--r--bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp2
-rw-r--r--bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp15
-rw-r--r--bluetooth/audio/aidl/default/OWNERS4
-rw-r--r--bluetooth/audio/aidl/vts/OWNERS4
-rw-r--r--bluetooth/audio/utils/OWNERS3
-rw-r--r--bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp13
-rw-r--r--bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h8
-rw-r--r--bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp47
-rw-r--r--bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h10
-rw-r--r--bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h14
-rw-r--r--bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp124
-rw-r--r--bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_0.h3
-rw-r--r--bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_2.h4
-rw-r--r--bluetooth/audio/utils/session/BluetoothAudioSession.cpp3
-rw-r--r--bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h2
-rw-r--r--bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp51
-rw-r--r--bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h1
29 files changed, 216 insertions, 138 deletions
diff --git a/bluetooth/audio/2.2/default/OWNERS b/bluetooth/audio/2.2/default/OWNERS
new file mode 100644
index 0000000000..17ea46424f
--- /dev/null
+++ b/bluetooth/audio/2.2/default/OWNERS
@@ -0,0 +1,4 @@
+include platform/packages/modules/Bluetooth:/OWNERS
+
+cheneyni@google.com
+aliceypkuo@google.com \ No newline at end of file
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
index e2a08a0e6d..948c04a513 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
@@ -37,11 +37,16 @@ parcelable CodecCapabilities {
android.hardware.bluetooth.audio.CodecType codecType;
android.hardware.bluetooth.audio.CodecCapabilities.Capabilities capabilities;
@VintfStability
+ parcelable VendorCapabilities {
+ ParcelableHolder extension;
+ }
+ @VintfStability
union Capabilities {
android.hardware.bluetooth.audio.SbcCapabilities sbcCapabilities;
android.hardware.bluetooth.audio.AacCapabilities aacCapabilities;
android.hardware.bluetooth.audio.LdacCapabilities ldacCapabilities;
android.hardware.bluetooth.audio.AptxCapabilities aptxCapabilities;
android.hardware.bluetooth.audio.Lc3Capabilities lc3Capabilities;
+ android.hardware.bluetooth.audio.CodecCapabilities.VendorCapabilities vendorCapabilities;
}
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
index 34ebd60530..32bccd8501 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
@@ -40,11 +40,18 @@ parcelable CodecConfiguration {
boolean isScmstEnabled;
android.hardware.bluetooth.audio.CodecConfiguration.CodecSpecific config;
@VintfStability
+ parcelable VendorConfiguration {
+ int vendorId;
+ char codecId;
+ ParcelableHolder codecConfig;
+ }
+ @VintfStability
union CodecSpecific {
android.hardware.bluetooth.audio.SbcConfiguration sbcConfig;
android.hardware.bluetooth.audio.AacConfiguration aacConfig;
android.hardware.bluetooth.audio.LdacConfiguration ldacConfig;
android.hardware.bluetooth.audio.AptxConfiguration aptxConfig;
android.hardware.bluetooth.audio.Lc3Configuration lc3Config;
+ android.hardware.bluetooth.audio.CodecConfiguration.VendorConfiguration vendorConfig;
}
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
index 44b434bbd7..3a5f951005 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
@@ -41,4 +41,5 @@ enum CodecType {
APTX_HD = 4,
LDAC = 5,
LC3 = 6,
+ VENDOR = 7,
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl
index 5bf0252bf8..41e243168c 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl
@@ -30,12 +30,17 @@ import android.hardware.bluetooth.audio.SbcCapabilities;
@VintfStability
parcelable CodecCapabilities {
@VintfStability
+ parcelable VendorCapabilities {
+ ParcelableHolder extension;
+ }
+ @VintfStability
union Capabilities {
SbcCapabilities sbcCapabilities;
AacCapabilities aacCapabilities;
LdacCapabilities ldacCapabilities;
AptxCapabilities aptxCapabilities;
Lc3Capabilities lc3Capabilities;
+ VendorCapabilities vendorCapabilities;
}
CodecType codecType;
Capabilities capabilities;
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl
index 9e43f2244a..3679537af7 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl
@@ -30,12 +30,19 @@ import android.hardware.bluetooth.audio.SbcConfiguration;
@VintfStability
parcelable CodecConfiguration {
@VintfStability
+ parcelable VendorConfiguration {
+ int vendorId;
+ char codecId;
+ ParcelableHolder codecConfig;
+ }
+ @VintfStability
union CodecSpecific {
SbcConfiguration sbcConfig;
AacConfiguration aacConfig;
LdacConfiguration ldacConfig;
AptxConfiguration aptxConfig;
Lc3Configuration lc3Config;
+ VendorConfiguration vendorConfig;
}
CodecType codecType;
/**
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
index 68c60f548e..9c3308194e 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
@@ -26,4 +26,5 @@ enum CodecType {
APTX_HD,
LDAC,
LC3,
+ VENDOR,
}
diff --git a/bluetooth/audio/aidl/default/A2dpSoftwareAudioProvider.cpp b/bluetooth/audio/aidl/default/A2dpSoftwareAudioProvider.cpp
index 7e4907409e..5a413e07a8 100644
--- a/bluetooth/audio/aidl/default/A2dpSoftwareAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/A2dpSoftwareAudioProvider.cpp
@@ -88,8 +88,9 @@ ndk::ScopedAStatus A2dpSoftwareAudioProvider::onSessionReady(
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
*_aidl_return = data_mq_->dupeDesc();
+ auto desc = data_mq_->dupeDesc();
BluetoothAudioSessionReport::OnSessionStarted(session_type_, stack_iface_,
- _aidl_return, *audio_config_);
+ &desc, *audio_config_);
return ndk::ScopedAStatus::ok();
}
diff --git a/bluetooth/audio/aidl/default/Android.bp b/bluetooth/audio/aidl/default/Android.bp
index 846702fa0e..fc882d4cef 100644
--- a/bluetooth/audio/aidl/default/Android.bp
+++ b/bluetooth/audio/aidl/default/Android.bp
@@ -8,7 +8,7 @@ package {
}
cc_library_shared {
- name: "android.hardware.bluetooth.audio-V1-impl",
+ name: "android.hardware.bluetooth.audio-impl",
vendor: true,
vintf_fragments: ["bluetooth_audio.xml"],
srcs: [
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
index 8e6cee7b2f..1e55a0bf7c 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "BTAudioProvidersFactory"
+#define LOG_TAG "BTAudioProviderFactoryAIDL"
#include "BluetoothAudioProviderFactory.h"
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
index 96d888c166..b38cfd2520 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
@@ -18,13 +18,6 @@
#include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioProviderFactory.h>
-#include "A2dpOffloadAudioProvider.h"
-#include "A2dpSoftwareAudioProvider.h"
-#include "BluetoothAudioProvider.h"
-#include "HearingAidAudioProvider.h"
-#include "LeAudioOffloadAudioProvider.h"
-#include "LeAudioSoftwareAudioProvider.h"
-
namespace aidl {
namespace android {
namespace hardware {
diff --git a/bluetooth/audio/aidl/default/HearingAidAudioProvider.cpp b/bluetooth/audio/aidl/default/HearingAidAudioProvider.cpp
index a993059b65..66ce93bd35 100644
--- a/bluetooth/audio/aidl/default/HearingAidAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/HearingAidAudioProvider.cpp
@@ -81,10 +81,10 @@ ndk::ScopedAStatus HearingAidAudioProvider::onSessionReady(
*_aidl_return = DataMQDesc();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
+ *_aidl_return = data_mq_->dupeDesc();
auto desc = data_mq_->dupeDesc();
BluetoothAudioSessionReport::OnSessionStarted(session_type_, stack_iface_,
&desc, *audio_config_);
- *_aidl_return = data_mq_->dupeDesc();
return ndk::ScopedAStatus::ok();
}
diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
index 4078783c99..72ac9bdede 100644
--- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "BTAudioProviderLeAudioSW"
+#define LOG_TAG "BTAudioProviderLeAudioHW"
#include "LeAudioOffloadAudioProvider.h"
diff --git a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
index f9962fd9d9..67b7d60c0c 100644
--- a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "BTAudioProviderLeAudioHW"
+#define LOG_TAG "BTAudioProviderLeAudioSW"
#include "LeAudioSoftwareAudioProvider.h"
@@ -88,6 +88,16 @@ ndk::ScopedAStatus LeAudioSoftwareAudioProvider::startSession(
channel_mode_to_channel_count(pcm_config.channelMode) *
(pcm_config.bitsPerSample / 8) * (pcm_config.dataIntervalUs / 1000) *
buffer_modifier;
+ if (data_mq_size <= 0) {
+ LOG(ERROR) << __func__ << "Unexpected audio buffer size: " << data_mq_size
+ << ", SampleRateHz: " << pcm_config.sampleRateHz
+ << ", ChannelMode: " << toString(pcm_config.channelMode)
+ << ", BitsPerSample: "
+ << static_cast<int>(pcm_config.bitsPerSample)
+ << ", DataIntervalUs: " << pcm_config.dataIntervalUs
+ << ", SessionType: " << toString(session_type_);
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
LOG(INFO) << __func__ << " - size of audio buffer " << data_mq_size
<< " byte(s)";
@@ -113,8 +123,9 @@ ndk::ScopedAStatus LeAudioSoftwareAudioProvider::onSessionReady(
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
*_aidl_return = data_mq_->dupeDesc();
+ auto desc = data_mq_->dupeDesc();
BluetoothAudioSessionReport::OnSessionStarted(session_type_, stack_iface_,
- _aidl_return, *audio_config_);
+ &desc, *audio_config_);
return ndk::ScopedAStatus::ok();
}
diff --git a/bluetooth/audio/aidl/default/OWNERS b/bluetooth/audio/aidl/default/OWNERS
new file mode 100644
index 0000000000..17ea46424f
--- /dev/null
+++ b/bluetooth/audio/aidl/default/OWNERS
@@ -0,0 +1,4 @@
+include platform/packages/modules/Bluetooth:/OWNERS
+
+cheneyni@google.com
+aliceypkuo@google.com \ No newline at end of file
diff --git a/bluetooth/audio/aidl/vts/OWNERS b/bluetooth/audio/aidl/vts/OWNERS
new file mode 100644
index 0000000000..17ea46424f
--- /dev/null
+++ b/bluetooth/audio/aidl/vts/OWNERS
@@ -0,0 +1,4 @@
+include platform/packages/modules/Bluetooth:/OWNERS
+
+cheneyni@google.com
+aliceypkuo@google.com \ No newline at end of file
diff --git a/bluetooth/audio/utils/OWNERS b/bluetooth/audio/utils/OWNERS
index ed9284766b..17ea46424f 100644
--- a/bluetooth/audio/utils/OWNERS
+++ b/bluetooth/audio/utils/OWNERS
@@ -1,3 +1,4 @@
include platform/packages/modules/Bluetooth:/OWNERS
-cheneyni@google.com \ No newline at end of file
+cheneyni@google.com
+aliceypkuo@google.com \ No newline at end of file
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index 92cd0f5b14..516ebe8d7a 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -78,7 +78,7 @@ static const AptxCapabilities kDefaultOffloadAptxHdCapability = {
.bitsPerSample = {24},
};
-static const Lc3Capabilities kDefaultOffloadLc3Capability = {
+static const Lc3Capabilities kDefaultA2dpOffloadLc3Capability = {
.samplingFrequencyHz = {44100, 48000},
.frameDurationUs = {7500, 10000},
.channelMode = {ChannelMode::MONO, ChannelMode::STEREO},
@@ -285,11 +285,11 @@ bool BluetoothAudioCodecs::IsOffloadLc3ConfigurationValid(
const Lc3Configuration lc3_data =
codec_specific.get<CodecConfiguration::CodecSpecific::lc3Config>();
- if (ContainedInVector(kDefaultOffloadLc3Capability.samplingFrequencyHz,
+ if (ContainedInVector(kDefaultA2dpOffloadLc3Capability.samplingFrequencyHz,
lc3_data.samplingFrequencyHz) &&
- ContainedInVector(kDefaultOffloadLc3Capability.frameDurationUs,
+ ContainedInVector(kDefaultA2dpOffloadLc3Capability.frameDurationUs,
lc3_data.frameDurationUs) &&
- ContainedInVector(kDefaultOffloadLc3Capability.channelMode,
+ ContainedInVector(kDefaultA2dpOffloadLc3Capability.channelMode,
lc3_data.channelMode)) {
return true;
}
@@ -352,10 +352,10 @@ BluetoothAudioCodecs::GetA2dpOffloadCodecCapabilities(
case CodecType::LC3:
codec_capability.capabilities
.set<CodecCapabilities::Capabilities::lc3Capabilities>(
- kDefaultOffloadLc3Capability);
+ kDefaultA2dpOffloadLc3Capability);
break;
case CodecType::UNKNOWN:
- codec_capability = {};
+ case CodecType::VENDOR:
break;
}
}
@@ -420,6 +420,7 @@ bool BluetoothAudioCodecs::IsOffloadCodecConfigurationValid(
}
break;
case CodecType::UNKNOWN:
+ case CodecType::VENDOR:
break;
}
return false;
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
index c542ce5be7..0259a7e770 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
@@ -45,11 +45,7 @@ class BluetoothAudioCodecs {
const SessionType& session_type, const CodecConfiguration& codec_config);
static bool IsOffloadLeAudioConfigurationValid(
- const SessionType& session_type, const Lc3Configuration& codec_config);
-
- static bool IsOffloadLeAudioConfigurationValid(
- const SessionType& session_type,
- const LeAudioConfiguration& codec_config);
+ const SessionType& session_type, const LeAudioConfiguration&);
static std::vector<LeAudioCodecCapabilitiesSetting>
GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
@@ -77,8 +73,6 @@ class BluetoothAudioCodecs {
const CodecConfiguration::CodecSpecific& codec_specific);
static bool IsOffloadLc3ConfigurationValid(
const CodecConfiguration::CodecSpecific& codec_specific);
- static bool IsOffloadLeAudioConfigurationValid(
- const SessionType& session_type, const LeAudioCodecConfiguration&);
};
} // namespace audio
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
index 95e473e5b9..f626db83bd 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
@@ -35,22 +35,8 @@ static constexpr int kFmqReceiveTimeoutMs =
static constexpr int kWritePollMs = 1; // polled non-blocking interval
static constexpr int kReadPollMs = 1; // polled non-blocking interval
-const CodecConfiguration BluetoothAudioSession::kInvalidCodecConfiguration = {};
-const LeAudioConfiguration kInvalidLeAudioConfiguration = {};
-AudioConfiguration BluetoothAudioSession::invalidSoftwareAudioConfiguration =
- {};
-AudioConfiguration BluetoothAudioSession::invalidOffloadAudioConfiguration = {};
-AudioConfiguration BluetoothAudioSession::invalidLeOffloadAudioConfig = {};
-
BluetoothAudioSession::BluetoothAudioSession(const SessionType& session_type)
- : session_type_(session_type), stack_iface_(nullptr), data_mq_(nullptr) {
- invalidSoftwareAudioConfiguration.set<AudioConfiguration::pcmConfig>(
- kInvalidPcmConfiguration);
- invalidOffloadAudioConfiguration.set<AudioConfiguration::a2dpConfig>(
- kInvalidCodecConfiguration);
- invalidLeOffloadAudioConfig.set<AudioConfiguration::leAudioConfig>(
- kInvalidLeAudioConfiguration);
-}
+ : session_type_(session_type), stack_iface_(nullptr), data_mq_(nullptr) {}
/***
*
@@ -72,13 +58,7 @@ void BluetoothAudioSession::OnSessionStarted(
} else if (!UpdateDataPath(mq_desc)) {
LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_)
<< " MqDescriptor Invalid";
- if (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- audio_config_ = std::make_unique<AudioConfiguration>(
- invalidOffloadAudioConfiguration);
- } else {
- audio_config_ = std::make_unique<AudioConfiguration>(
- invalidSoftwareAudioConfiguration);
- }
+ audio_config_ = nullptr;
} else {
stack_iface_ = stack_iface;
LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
@@ -91,13 +71,7 @@ void BluetoothAudioSession::OnSessionEnded() {
std::lock_guard<std::recursive_mutex> guard(mutex_);
bool toggled = IsSessionReady();
LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_);
- if (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- audio_config_ =
- std::make_unique<AudioConfiguration>(invalidOffloadAudioConfiguration);
- } else {
- audio_config_ =
- std::make_unique<AudioConfiguration>(invalidSoftwareAudioConfiguration);
- }
+ audio_config_ = nullptr;
stack_iface_ = nullptr;
UpdateDataPath(nullptr);
if (toggled) {
@@ -111,22 +85,17 @@ void BluetoothAudioSession::OnSessionEnded() {
*
***/
-const AudioConfiguration& BluetoothAudioSession::GetAudioConfig() {
+const AudioConfiguration BluetoothAudioSession::GetAudioConfig() {
std::lock_guard<std::recursive_mutex> guard(mutex_);
if (!IsSessionReady()) {
- if (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- return invalidOffloadAudioConfiguration;
- } else {
- return invalidSoftwareAudioConfiguration;
- }
switch (session_type_) {
case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
- return invalidOffloadAudioConfiguration;
+ return AudioConfiguration(CodecConfiguration{});
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
- return invalidLeOffloadAudioConfig;
+ return AudioConfiguration(LeAudioConfiguration{});
default:
- return invalidSoftwareAudioConfiguration;
+ return AudioConfiguration(PcmConfiguration{});
}
}
return *audio_config_;
@@ -169,7 +138,7 @@ bool BluetoothAudioSession::IsSessionReady() {
session_type_ ==
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH ||
(data_mq_ != nullptr && data_mq_->isValid()));
- return stack_iface_ != nullptr && is_mq_valid;
+ return stack_iface_ != nullptr && is_mq_valid && audio_config_ != nullptr;
}
/***
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h
index 85fd571f28..73bc0f8b4e 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h
@@ -144,7 +144,7 @@ class BluetoothAudioSession {
* The control function is for the bluetooth_audio module to get the current
* AudioConfiguration
***/
- const AudioConfiguration& GetAudioConfig();
+ const AudioConfiguration GetAudioConfig();
/***
* The report function is used to report that the Bluetooth stack has notified
@@ -173,14 +173,6 @@ class BluetoothAudioSession {
// Return if IBluetoothAudioProviderFactory implementation existed
static bool IsAidlAvailable();
- static constexpr PcmConfiguration kInvalidPcmConfiguration = {};
- // can't be constexpr because of non-literal type
- static const CodecConfiguration kInvalidCodecConfiguration;
-
- static AudioConfiguration invalidSoftwareAudioConfiguration;
- static AudioConfiguration invalidOffloadAudioConfiguration;
- static AudioConfiguration invalidLeOffloadAudioConfig;
-
private:
// using recursive_mutex to allow hwbinder to re-enter again.
std::recursive_mutex mutex_;
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
index a3ed42894c..aff01e5a26 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
@@ -79,11 +79,15 @@ class BluetoothAudioSessionControl {
BluetoothAudioSessionInstance::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
return session_ptr->GetAudioConfig();
- } else if (session_type ==
- SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- return BluetoothAudioSession::invalidOffloadAudioConfiguration;
- } else {
- return BluetoothAudioSession::invalidSoftwareAudioConfiguration;
+ }
+ switch (session_type) {
+ case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
+ return AudioConfiguration(CodecConfiguration{});
+ case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
+ case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
+ return AudioConfiguration(LeAudioConfiguration{});
+ default:
+ return AudioConfiguration(PcmConfiguration{});
}
}
diff --git a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
index 91e0238783..632a389d8c 100644
--- a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
+++ b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
@@ -93,16 +93,6 @@ std::unordered_map<
std::unordered_map<uint16_t, std::shared_ptr<PortStatusCallbacks_2_2>>>
legacy_callback_table;
-const static std::unordered_map<SessionType_2_0, SessionType>
- session_type_2_0_to_aidl_map{
- {SessionType_2_0::A2DP_SOFTWARE_ENCODING_DATAPATH,
- SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH},
- {SessionType_2_0::A2DP_HARDWARE_OFFLOAD_DATAPATH,
- SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH},
- {SessionType_2_0::HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
- SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH},
- };
-
const static std::unordered_map<SessionType_2_1, SessionType>
session_type_2_1_to_aidl_map{
{SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH,
@@ -121,18 +111,6 @@ const static std::unordered_map<SessionType_2_1, SessionType>
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH},
};
-const static std::unordered_map<int32_t, SampleRate_2_0>
- sample_rate_to_hidl_2_0_map{
- {44100, SampleRate_2_0::RATE_44100},
- {48000, SampleRate_2_0::RATE_48000},
- {88200, SampleRate_2_0::RATE_88200},
- {96000, SampleRate_2_0::RATE_96000},
- {176400, SampleRate_2_0::RATE_176400},
- {192000, SampleRate_2_0::RATE_192000},
- {16000, SampleRate_2_0::RATE_16000},
- {24000, SampleRate_2_0::RATE_24000},
- };
-
const static std::unordered_map<int32_t, SampleRate_2_1>
sample_rate_to_hidl_2_1_map{
{44100, SampleRate_2_1::RATE_44100},
@@ -211,20 +189,6 @@ const static std::unordered_map<LdacQualityIndex, LdacQualityIndex_2_0>
{LdacQualityIndex::ABR, LdacQualityIndex_2_0::QUALITY_ABR},
};
-const static std::unordered_map<LeAudioMode, LeAudioMode_2_2>
- leaudio_mode_to_hidl_map{
- {LeAudioMode::UNKNOWN, LeAudioMode_2_2::UNKNOWN},
- {LeAudioMode::UNICAST, LeAudioMode_2_2::UNICAST},
- {LeAudioMode::BROADCAST, LeAudioMode_2_2::BROADCAST},
- };
-
-inline SessionType from_session_type_2_0(
- const SessionType_2_0& session_type_hidl) {
- auto it = session_type_2_0_to_aidl_map.find(session_type_hidl);
- if (it != session_type_2_0_to_aidl_map.end()) return it->second;
- return SessionType::UNKNOWN;
-}
-
inline SessionType from_session_type_2_1(
const SessionType_2_1& session_type_hidl) {
auto it = session_type_2_1_to_aidl_map.find(session_type_hidl);
@@ -232,6 +196,11 @@ inline SessionType from_session_type_2_1(
return SessionType::UNKNOWN;
}
+inline SessionType from_session_type_2_0(
+ const SessionType_2_0& session_type_hidl) {
+ return from_session_type_2_1(static_cast<SessionType_2_1>(session_type_hidl));
+}
+
inline HidlStatus to_hidl_status(const BluetoothAudioStatus& status) {
switch (status) {
case BluetoothAudioStatus::SUCCESS:
@@ -243,18 +212,19 @@ inline HidlStatus to_hidl_status(const BluetoothAudioStatus& status) {
}
}
-inline SampleRate_2_0 to_hidl_sample_rate_2_0(const int32_t sample_rate_hz) {
- auto it = sample_rate_to_hidl_2_0_map.find(sample_rate_hz);
- if (it != sample_rate_to_hidl_2_0_map.end()) return it->second;
- return SampleRate_2_0::RATE_UNKNOWN;
-}
-
inline SampleRate_2_1 to_hidl_sample_rate_2_1(const int32_t sample_rate_hz) {
auto it = sample_rate_to_hidl_2_1_map.find(sample_rate_hz);
if (it != sample_rate_to_hidl_2_1_map.end()) return it->second;
return SampleRate_2_1::RATE_UNKNOWN;
}
+inline SampleRate_2_0 to_hidl_sample_rate_2_0(const int32_t sample_rate_hz) {
+ auto it = sample_rate_to_hidl_2_1_map.find(sample_rate_hz);
+ if (it != sample_rate_to_hidl_2_1_map.end())
+ return static_cast<SampleRate_2_0>(it->second);
+ return SampleRate_2_0::RATE_UNKNOWN;
+}
+
inline BitsPerSample_2_0 to_hidl_bits_per_sample(const int8_t bit_per_sample) {
switch (bit_per_sample) {
case 16:
@@ -449,18 +419,49 @@ inline Lc3Config_2_1 to_hidl_lc3_config_2_1(
inline Lc3CodecConfig_2_1 to_hidl_leaudio_config_2_1(
const LeAudioConfiguration& leaudio_config) {
- auto& unicast_config =
- leaudio_config.modeConfig
- .get<LeAudioConfiguration::LeAudioModeConfig::unicastConfig>();
-
- auto& le_codec_config = unicast_config.leAudioCodecConfig
- .get<LeAudioCodecConfiguration::lc3Config>();
+ Lc3CodecConfig_2_1 hidl_lc3_codec_config = {
+ .audioChannelAllocation = 0,
+ };
+ if (leaudio_config.modeConfig.getTag() ==
+ LeAudioConfiguration::LeAudioModeConfig::unicastConfig) {
+ auto& unicast_config =
+ leaudio_config.modeConfig
+ .get<LeAudioConfiguration::LeAudioModeConfig::unicastConfig>();
+ if (unicast_config.leAudioCodecConfig.getTag() ==
+ LeAudioCodecConfiguration::lc3Config) {
+ LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)";
+ }
+ auto& le_codec_config = unicast_config.leAudioCodecConfig
+ .get<LeAudioCodecConfiguration::lc3Config>();
- Lc3CodecConfig_2_1 hidl_lc3_codec_config;
- hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config);
+ hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config);
- hidl_lc3_codec_config.audioChannelAllocation =
- unicast_config.streamMap.size();
+ for (const auto& map : unicast_config.streamMap) {
+ hidl_lc3_codec_config.audioChannelAllocation |=
+ map.audioChannelAllocation;
+ }
+ } else {
+ // NOTE: Broadcast is not officially supported in HIDL
+ auto& bcast_config =
+ leaudio_config.modeConfig
+ .get<LeAudioConfiguration::LeAudioModeConfig::broadcastConfig>();
+ if (bcast_config.streamMap.empty()) {
+ return hidl_lc3_codec_config;
+ }
+ if (bcast_config.streamMap[0].leAudioCodecConfig.getTag() !=
+ LeAudioCodecConfiguration::lc3Config) {
+ LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)";
+ }
+ auto& le_codec_config =
+ bcast_config.streamMap[0]
+ .leAudioCodecConfig.get<LeAudioCodecConfiguration::lc3Config>();
+ hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config);
+
+ for (const auto& map : bcast_config.streamMap) {
+ hidl_lc3_codec_config.audioChannelAllocation |=
+ map.audioChannelAllocation;
+ }
+ }
return hidl_lc3_codec_config;
}
@@ -468,13 +469,10 @@ inline Lc3CodecConfig_2_1 to_hidl_leaudio_config_2_1(
inline LeAudioConfig_2_2 to_hidl_leaudio_config_2_2(
const LeAudioConfiguration& leaudio_config) {
LeAudioConfig_2_2 hidl_leaudio_config;
- if (leaudio_mode_to_hidl_map.find(leaudio_config.mode) !=
- leaudio_mode_to_hidl_map.end()) {
- hidl_leaudio_config.mode = leaudio_mode_to_hidl_map.at(leaudio_config.mode);
- }
if (leaudio_config.modeConfig.getTag() ==
LeAudioConfiguration::LeAudioModeConfig::unicastConfig) {
+ hidl_leaudio_config.mode = LeAudioMode_2_2::UNICAST;
auto& unicast_config =
leaudio_config.modeConfig
.get<LeAudioConfiguration::LeAudioModeConfig::unicastConfig>();
@@ -497,6 +495,7 @@ inline LeAudioConfig_2_2 to_hidl_leaudio_config_2_2(
}
} else if (leaudio_config.modeConfig.getTag() ==
LeAudioConfiguration::LeAudioModeConfig::broadcastConfig) {
+ hidl_leaudio_config.mode = LeAudioMode_2_2::BROADCAST;
auto bcast_config =
leaudio_config.modeConfig
.get<LeAudioConfiguration::LeAudioModeConfig::broadcastConfig>();
@@ -641,6 +640,12 @@ size_t HidlToAidlMiddleware_2_0::OutWritePcmData(
from_session_type_2_0(session_type), buffer, bytes);
}
+size_t HidlToAidlMiddleware_2_0::InReadPcmData(
+ const SessionType_2_0& session_type, void* buffer, size_t bytes) {
+ return BluetoothAudioSessionControl::InReadPcmData(
+ from_session_type_2_0(session_type), buffer, bytes);
+}
+
bool HidlToAidlMiddleware_2_0::IsAidlAvailable() {
return BluetoothAudioSession::IsAidlAvailable();
}
@@ -761,6 +766,13 @@ void HidlToAidlMiddleware_2_2::StopStream(const SessionType_2_1& session_type) {
from_session_type_2_1(session_type));
}
+void HidlToAidlMiddleware_2_2::UpdateTracksMetadata(
+ const SessionType_2_1& session_type,
+ const struct source_metadata* source_metadata) {
+ return BluetoothAudioSessionControl::UpdateSourceMetadata(
+ from_session_type_2_1(session_type), *source_metadata);
+}
+
void HidlToAidlMiddleware_2_2::UpdateSinkMetadata(
const SessionType_2_1& session_type,
const struct sink_metadata* sink_metadata) {
diff --git a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_0.h b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_0.h
index d10ee3759a..b124d8ff0b 100644
--- a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_0.h
+++ b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_0.h
@@ -64,6 +64,9 @@ class HidlToAidlMiddleware_2_0 {
static size_t OutWritePcmData(const SessionType_2_0& session_type,
const void* buffer, size_t bytes);
+
+ static size_t InReadPcmData(const SessionType_2_0& session_type, void* buffer,
+ size_t bytes);
};
} // namespace audio
diff --git a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_2.h b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_2.h
index 149e4042d1..f6c3e5c731 100644
--- a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_2.h
+++ b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware_2_2.h
@@ -54,6 +54,10 @@ class HidlToAidlMiddleware_2_2 {
static void StopStream(const SessionType_2_1& session_type);
+ static void UpdateTracksMetadata(
+ const SessionType_2_1& session_type,
+ const struct source_metadata* source_metadata);
+
static void UpdateSinkMetadata(const SessionType_2_1& session_type,
const struct sink_metadata* sink_metadata);
};
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession.cpp
index 6d5608b0a4..283952e52c 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession.cpp
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession.cpp
@@ -437,6 +437,9 @@ size_t BluetoothAudioSession::OutWritePcmData(const void* buffer,
// The control function reads stream from FMQ
size_t BluetoothAudioSession::InReadPcmData(void* buffer, size_t bytes) {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_0::InReadPcmData(session_type_, buffer,
+ bytes);
if (buffer == nullptr || !bytes) return 0;
size_t totalRead = 0;
int ms_timeout = kFmqReceiveTimeoutMs;
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
index 368939e6f8..c270ef0d6b 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
@@ -152,7 +152,7 @@ class BluetoothAudioSessionControl_2_2 {
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
- session_ptr->GetAudioSession()->UpdateTracksMetadata(source_metadata);
+ session_ptr->UpdateTracksMetadata(source_metadata);
}
}
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
index 4613ddc05a..ceb0662b0a 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
@@ -31,9 +31,13 @@ namespace audio {
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_0;
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_2;
+using ::android::hardware::audio::common::V5_0::AudioContentType;
using ::android::hardware::audio::common::V5_0::AudioSource;
+using ::android::hardware::audio::common::V5_0::AudioUsage;
+using ::android::hardware::audio::common::V5_0::PlaybackTrackMetadata;
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
using ::android::hardware::audio::common::V5_0::SinkMetadata;
+using ::android::hardware::audio::common::V5_0::SourceMetadata;
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration;
@@ -128,6 +132,53 @@ BluetoothAudioSession_2_2::GetAudioSession_2_1() {
return audio_session_2_1;
}
+void BluetoothAudioSession_2_2::UpdateTracksMetadata(
+ const struct source_metadata* source_metadata) {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::UpdateTracksMetadata(raw_session_type_,
+ source_metadata);
+ std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
+ if (!IsSessionReady()) {
+ LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
+ << " has NO session";
+ return;
+ }
+
+ ssize_t track_count = source_metadata->track_count;
+ LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
+ << ", " << track_count << " track(s)";
+
+ if (session_type_2_1_ == SessionType_2_1::UNKNOWN) {
+ audio_session->UpdateTracksMetadata(source_metadata);
+ return;
+ }
+
+ struct playback_track_metadata* track = source_metadata->tracks;
+ SourceMetadata sourceMetadata;
+ PlaybackTrackMetadata* halMetadata;
+
+ sourceMetadata.tracks.resize(track_count);
+ halMetadata = sourceMetadata.tracks.data();
+ while (track_count && track) {
+ halMetadata->usage = static_cast<AudioUsage>(track->usage);
+ halMetadata->contentType =
+ static_cast<AudioContentType>(track->content_type);
+ halMetadata->gain = track->gain;
+ LOG(VERBOSE) << __func__ << " - SessionType=" << toString(session_type_2_1_)
+ << ", usage=" << toString(halMetadata->usage)
+ << ", content=" << toString(halMetadata->contentType)
+ << ", gain=" << halMetadata->gain;
+ --track_count;
+ ++track;
+ ++halMetadata;
+ }
+ auto hal_retval = audio_session->stack_iface_->updateMetadata(sourceMetadata);
+ if (!hal_retval.isOk()) {
+ LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
+ << toString(session_type_2_1_) << " failed";
+ }
+}
+
void BluetoothAudioSession_2_2::UpdateSinkMetadata(
const struct sink_metadata* sink_metadata) {
if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
index b6f96ab25c..e04ad80ffa 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
@@ -152,6 +152,7 @@ class BluetoothAudioSession_2_2 {
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
GetAudioConfig();
+ void UpdateTracksMetadata(const struct source_metadata* source_metadata);
void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);
static constexpr ::android::hardware::bluetooth::audio::V2_2::