mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Stub implementation for USB audio HAL.
Bug: 266216550 Test: atest VtsHalAudioCoreTargetTest Change-Id: Ida4b3dbdb684dfc880a907651ae0fc398addbffc
This commit is contained in:
@@ -393,4 +393,73 @@ std::unique_ptr<Configuration> getRSubmixConfiguration() {
|
||||
return std::make_unique<Configuration>(configuration);
|
||||
}
|
||||
|
||||
// Usb configuration:
|
||||
//
|
||||
// Device ports:
|
||||
// * "USB Headset Out", OUT_HEADSET, CONNECTION_USB
|
||||
// - no profiles specified
|
||||
// * "USB Headset In", IN_HEADSET, CONNECTION_USB
|
||||
// - no profiles specified
|
||||
//
|
||||
// Mix ports:
|
||||
// * "usb_headset output", 1 max open, 1 max active stream
|
||||
// - no profiles specified
|
||||
// * "usb_headset input", 1 max open, 1 max active stream
|
||||
// - no profiles specified
|
||||
//
|
||||
// Profiles for device port connected state:
|
||||
// * USB Headset Out":
|
||||
// - profile PCM 16-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
||||
// - profile PCM 24-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
||||
// * USB Headset In":
|
||||
// - profile PCM 16-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
||||
// - profile PCM 24-bit; MONO, STEREO, INDEX_MASK_1, INDEX_MASK_2; 44100, 48000
|
||||
//
|
||||
std::unique_ptr<Configuration> getUsbConfiguration() {
|
||||
static const Configuration configuration = []() {
|
||||
const std::vector<AudioProfile> standardPcmAudioProfiles = {
|
||||
createProfile(PcmType::INT_16_BIT,
|
||||
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
||||
AudioChannelLayout::INDEX_MASK_1, AudioChannelLayout::INDEX_MASK_2},
|
||||
{44100, 48000}),
|
||||
createProfile(PcmType::INT_24_BIT,
|
||||
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
|
||||
AudioChannelLayout::INDEX_MASK_1, AudioChannelLayout::INDEX_MASK_2},
|
||||
{44100, 48000})};
|
||||
Configuration c;
|
||||
|
||||
// Device ports
|
||||
|
||||
AudioPort usbOutHeadset =
|
||||
createPort(c.nextPortId++, "USB Headset Out", 0, false,
|
||||
createDeviceExt(AudioDeviceType::OUT_HEADSET, 0,
|
||||
AudioDeviceDescription::CONNECTION_USB));
|
||||
c.ports.push_back(usbOutHeadset);
|
||||
c.connectedProfiles[usbOutHeadset.id] = standardPcmAudioProfiles;
|
||||
|
||||
AudioPort usbInHeadset =
|
||||
createPort(c.nextPortId++, "USB Headset In", 0, true,
|
||||
createDeviceExt(AudioDeviceType::IN_HEADSET, 0,
|
||||
AudioDeviceDescription::CONNECTION_USB));
|
||||
c.ports.push_back(usbInHeadset);
|
||||
c.connectedProfiles[usbInHeadset.id] = standardPcmAudioProfiles;
|
||||
|
||||
// Mix ports
|
||||
|
||||
AudioPort usbHeadsetOutMix =
|
||||
createPort(c.nextPortId++, "usb_headset output", 0, false, createPortMixExt(1, 1));
|
||||
c.ports.push_back(usbHeadsetOutMix);
|
||||
|
||||
AudioPort usbHeadsetInMix =
|
||||
createPort(c.nextPortId++, "usb_headset input", 0, true, createPortMixExt(1, 1));
|
||||
c.ports.push_back(usbHeadsetInMix);
|
||||
|
||||
c.routes.push_back(createRoute({usbHeadsetOutMix}, usbOutHeadset));
|
||||
c.routes.push_back(createRoute({usbInHeadset}, usbHeadsetInMix));
|
||||
|
||||
return c;
|
||||
}();
|
||||
return std::make_unique<Configuration>(configuration);
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core::internal
|
||||
|
||||
@@ -259,6 +259,8 @@ internal::Configuration& Module::getConfig() {
|
||||
case Type::R_SUBMIX:
|
||||
mConfig = std::move(internal::getRSubmixConfiguration());
|
||||
break;
|
||||
case Type::USB:
|
||||
mConfig = std::move(internal::getUsbConfiguration());
|
||||
}
|
||||
}
|
||||
return *mConfig;
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
<version>1</version>
|
||||
<fqname>IModule/r_submix</fqname>
|
||||
</hal>
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.audio.core</name>
|
||||
<version>1</version>
|
||||
<fqname>IModule/usb</fqname>
|
||||
</hal>
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.audio.core</name>
|
||||
<version>1</version>
|
||||
|
||||
@@ -44,5 +44,6 @@ struct Configuration {
|
||||
|
||||
std::unique_ptr<Configuration> getPrimaryConfiguration();
|
||||
std::unique_ptr<Configuration> getRSubmixConfiguration();
|
||||
std::unique_ptr<Configuration> getUsbConfiguration();
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core::internal
|
||||
|
||||
@@ -31,7 +31,7 @@ class Module : public BnModule {
|
||||
public:
|
||||
// This value is used for all AudioPatches and reported by all streams.
|
||||
static constexpr int32_t kLatencyMs = 10;
|
||||
enum Type : int { DEFAULT, R_SUBMIX };
|
||||
enum Type : int { DEFAULT, R_SUBMIX, USB };
|
||||
|
||||
explicit Module(Type type) : mType(type) {}
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ int main() {
|
||||
return std::make_pair(module, moduleBinder);
|
||||
};
|
||||
auto modules = {createModule(Module::Type::DEFAULT, "default"),
|
||||
createModule(Module::Type::R_SUBMIX, "r_submix")};
|
||||
createModule(Module::Type::R_SUBMIX, "r_submix"),
|
||||
createModule(Module::Type::USB, "usb")};
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
|
||||
Reference in New Issue
Block a user