Commit Graph

34 Commits

Author SHA1 Message Date
Mikhail Naganov
248e950798 audio: Accept I/O handle for mix ports from the client
The client can pass the I/O handle to the HAL as part of
the requested audio port config. The HAL can store that handle
and use it as a cookie to match the port config with other HALs
(for example, SoundTrigger).

Updated behavior of IModule.setAudioPortConfig to copy
the handle for mix ports, and pass it back with the applied
config. Enforced this behavior in VTS.

Bug: 269551518
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ibc3f9eea4169610f1680937c764de42b4fe5194a
2023-02-21 16:39:58 -08:00
Mikhail Naganov
6725ef536b audio: Move Microphone[Dynamic]Info structs from core
These parcelables are also used by the framework.

Bug: 263964254
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ib30b69c325040e474fb58a8e7e515912fccab4c7
Merged-In: Ib30b69c325040e474fb58a8e7e515912fccab4c7
2023-02-15 10:15:42 -08:00
jiabin
253bd32b04 AOSP AIDL USB audio HAL implementation.
Bug: 266216550
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I82e053d3f6a918cafe0d43b030f724f63a99eb2a
2023-02-02 18:39:26 +00:00
Pawan Wagh
6f57cd9778 Fixing null deference crash in audio service
Bug: 267517128
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I8949270b456d65e516946ffd294a5328da9de14b
2023-02-01 21:14:34 +00:00
jiabin
b309d8dd36 Stub implementation for USB audio HAL.
Bug: 266216550
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ida4b3dbdb684dfc880a907651ae0fc398addbffc
2023-01-20 21:43:52 +00:00
jiabin
b76981e2a7 Add interfaces to query aaudio hardware information.
Add interfaces to query aaudio hardware information. The new interfaces
are supposed to replace the system properties. The information includes
aaudio mixer burst count and aaudio hardware burst minimum usec.

Bug: 193275465
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id3442dae15937baba84f053f2e244bc294f4d718
2023-01-19 18:06:22 +00:00
Eric Laurent
e2432ea1a7 audio: Add supportsBluetoothVariableLatency API to IModule
Add API to query if the Module supports control of variable latency over
playback paths.

Bug: 197823000
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I3a08d682a1a639d8373869725e12702fff962d53
2023-01-16 11:32:02 +01:00
jiabin
9a8e686628 Add API to query mmap policy information.
Bug: 193275465
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I8374a6e7942d68259d820b5de1f4ec597f1b6473
2023-01-13 22:57:34 +00:00
Mikhail Naganov
04ae822302 audio: Remove android.hardware.audio.core.AudioMode type
I missed that there is already android.media.audio.common.AudioMode.
However, due to use by the framework, it contains more values
(all of them are SYS_RESERVED), thus the implementation and VTS
have to be updated as well.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: If260413b1f774a69514de978792d5ad2eb46481a
Merged-In: If260413b1f774a69514de978792d5ad2eb46481a
2023-01-12 17:42:02 +00:00
Mikhail Naganov
f429c03d49 audio: Generalize stream implementations
This allows for more code reuse and composability when
implementing streams for a particular audio "backend."

The existing "stub" code has been moved to StreamStub* files.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I97fd41f87eb6d01e1d57f0d70a86d3b2b3555837
2023-01-10 19:18:42 +00:00
Mikhail Naganov
8651b364b8 audio: Plumb IStreamOutEventCallback to the stream
The plumbing was missing from the CL which has added
the callback (aosp/2256190).

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Iab3c970b3efd0281e34e07f98864531acc4c519e
2023-01-09 19:53:06 +00:00
Mikhail Naganov
194daaac57 audio: Allow going to 'IDLE' for synchronous drain
For small buffers, the driver can perform draining
synhronously, returning control to the HAL only after
the buffer is empty. This makes going through
the 'DRAINING' state artificial. Thus, we allow going
to the 'IDLE' state directly.

In order to make sure that VTS handles both transitions:
to 'DRAINING' and to 'IDLE', correctly, add an "AOSP as
vendor" parameter "aosp.forceSynchronousDrain" to induce
this behavior in the default implementation.

Bug: 262402957
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ic8eaee53cb4596afb5317b4b905e004af3f112aa
2023-01-06 19:43:14 +00:00
Mikhail Naganov
20047bc1d9 audio: Improve test coverage
Add a vendor-specific parameter "aosp.forceTransientBurst"
which helps to cover the case of non-full async writes.
This parameter is specific to the "AOSP as vendor" implementation,
other vendors are not required to have it—that's why it's
not in AIDL.

Fix minor issues in VTS found after revisiting the code, and by
looking at logs during testing.

Bug: 262402957
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ide961d91a8d9da24392561654f04eb8207b7b781
2023-01-06 19:43:13 +00:00
Mikhail Naganov
10c6fe2b8f audio: Add IBluetooth core interface
This interface corresponds to BT-specific functions
of the IPrimaryDevice in the HIDL HAL.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I5f52d65e06f42e1a5fb2e51d27b79e94fe423eaa
2023-01-03 18:23:33 +00:00
Vlad Popa
2afbd1e549 Refactor the ISoundDose.aidl interface
This refactoring is fixing the hal_implementation_test workaround from
aosp/2363076. Adjusted the package name to match the aidl_interface and
declared the ISoundDose interface types only.

Test: VtsHalSoundDoseFactoryTargetTest, VtsHalAudioCoreTargetTest,
hal_implementation_test
Bug: 263388737

Change-Id: Ibce4cd95aaf600de2096179f137243939114ba6a
Merged-In: Ibce4cd95aaf600de2096179f137243939114ba6a
2022-12-28 18:01:01 +01:00
Mikhail Naganov
7492720e49 audio: Add presentation and latency control to IStreamOut
Add the following methods to IStreamOut:
  - get/setAudioDescriptionMixLevel;
  - get/setDualMonoMode;
  - getRecommendedLatencyModes/setLatencyMode;
  - get/setPlaybackRateParameters;
  - selectPresentation.

Add IStreamOutEventCallback interface for async notifications
of the client about playback-related events. This callback
can be provided to IModule.openOutputStream.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I8974102d232cdd121a53edccbf26c33778a94e5e
2022-12-23 02:22:38 +00:00
Mikhail Naganov
fb1acdec67 audio: Add effect attachment to devices and streams
Add the following methods:
  - IModule.{add|remove}DeviceEffect;
  - IStream.{add|remove}Effect.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I4066e2d10a8e08d634010cfe9eb8f832157e725f
2022-12-19 17:23:30 +00:00
Mikhail Naganov
e9f10fc9dc audio: Provide operations common to input and output streams
Introduce IStreamCommon which contains methods that apply
both to input and output streams. Move the 'close' method
to it. Add 'IStreamIn/Out.getStreamCommon' method to retrieve
the common interface.

Add methods for dealing with HW AV Sync and vendor parameters.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ie1a7b32e28425f5398afc95192fcbc5403b5c332
2022-12-16 16:40:28 +00:00
Mikhail Naganov
df5feba141 audio: Retain IBinder for instances with MinSchedulerPolicy
The binder passed to AIBinder_setMinSchedulerPolicy must also be
returned to the client, otherwise setting the policy for it does
not make any sense. However, server side interface instance
classes only hold a weak binder reference. It's the caller of the
'asBinder' method who must retain a strong reference. This
reference must be retained past exiting from the method which
returns the instance to the client.

To solve this issue, add storing of binders along with server
object references. These binders get released after the client
calls a 'close'/'destroy'-type method to release instance
resources.

Bug: 205884982
Test: run `atest VtsHalAudioCoreTargetTest` and effect VTS,
      and grep logcat for
     'destroyed after setMinSchedulerPolicy before being parceled'
Change-Id: I8b905b85cb8263c85edae8839a126ffe4e4d1e69
2022-12-16 15:27:10 +00:00
Vlad Popa
943b7e2b91 Add default implementation and VTS for ISoundDose
The ISoundDose HAL interface is used for reporting the sound dose
relevant information from/to the HAL. This is necessary for all devices
that certify with the IEC62368-1 3rd edition and EN50332-3 standard
for safe hearing.

Bug: 248567177
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ib89e09243a01cebc2f7996b6b572384a1471867a
Merged-In: Ib89e09243a01cebc2f7996b6b572384a1471867a
(cherry picked from commit 83a2146546)
2022-12-15 19:41:32 +00:00
Vlad Popa
83a6d82793 Add HAL interface definition for sound dose
The interface is used to configure the sound dose parameters and
retrieve new changes that can affect the dose. Used for the
certification with IEC62368-1 3rd edition.

Test: TODO
Bug: 257937004
Change-Id: Id2816580fdbfbf09c2278720b4d78d0b3604fbf4
Merged-In: Id2816580fdbfbf09c2278720b4d78d0b3604fbf4
(cherry picked from commit 10905ef92e)
2022-12-15 19:41:03 +00:00
Mikhail Naganov
c8e4312da8 audio: Bring default HAL configuration closer to cuttlefish
This is to simplify switching of cuttlefish to
the AIDL implementation. Split out 'r_submix' module.

Add all IModule instance names to the compatibility
matrix.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I424db14257281671eea87aa743deb778ca75f388
2022-12-13 01:17:55 +00:00
Shunkai Yao
39bf2c3146 Audio AIDL HAL priority update
Enable RT priority inheritance.
Set minimum Audio AIDL HAL Binder access priority to ANDROID_PRIORITY_AUDIO.

Bug: 261496726
Test: atest VtsHalAudioEffectTargetTest
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I584d80f4fe344e4bfae5765cac2afb92313b6a39
2022-12-09 02:39:42 +00:00
Mikhail Naganov
ef6bc74fc4 audio: Add microphone settings to IModule, IStreamIn
Add 'MicrophoneInfo' and 'MicrophoneDynamicInfo' parcelables.
Add IModule.getMicrophones method.
Add following methods to IStreamIn:
  - getActiveMicrophonesIds;
  - get/setMicrophoneDirection;
  - get/setMicrophoneFieldDimension.

Provide trivial implementations and VTS.

Also slightly refactor port retrieval from ModuleConfig
to unify common queries.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I472c7733e2a331a67cea613cd9218889eff06a43
2022-12-07 18:36:31 +00:00
Mikhail Naganov
30301a42c7 audio: Add non-blocking I/O stream operations
Introduce IStreamCallback interface for non-blocking I/O. Add 2
new stream states: TRANSFERRING and TRANSFER_PAUSED, and define
state machines for the async case. Add DrainMode as in previous
HAL versions.

Note that non-blocking input is not fully implemented because it
did not exist in previous HAL versions, and the corresponding
AudioInputFlag does not exist yet.

Enhance VTS state machine tests to allow waiting for an async
event.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I0a18a6d930dee5941f769e08083817d41ff941e6
2022-12-05 19:57:43 +00:00
Mikhail Naganov
bd483c03b2 audio: Implement transient state testing
Add ModuleDebug.streamTransientStateDelayMs parameter to ensure
that streams stay in transient states for the specified amount of
time. This enabled sending commands from VTS while the stream is
still in a transient state.

Add 'getStatus' stream command to retrieve current positions,
counters, and stream state. Previously we were planning to use a
zero-sized burst command for that, however, after the
introduction of stream state machines, the 'burst' command is
not handled in every stream state, and may even affect the
current state, thus it's no more usable for this purpose.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I8717acace8d95d76bef2ec9fd6561796d7544992
2022-11-23 01:58:19 +00:00
Mikhail Naganov
3b125b76aa audio: Add volume/mute, audio mode, and screen state to IModule
Add the following methods to IModule:
 - getTelephony;
 - get/setMasterMute;
 - get/setMasterVolume;
 - get/setMicMute;
 - updateAudioMode;
 - updateScreenRotation;
 - updateScreenState;
The "update..." methods are "informational," the HAL may ignore
them and must not raise any errors.

ITelephony currently contains 2 methods:
 - getSupportedAudioModes;
 - switchAudioMode.
This "switchAudioMode" must validate the argument, and must
switch the HAL to the new mode synchronously.

Implement and add VTS tests.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I9174c81fe7d16f7068257051ae5e129b15e82648
2022-11-09 18:55:07 +00:00
Mikhail Naganov
a2c5ddf993 audio: Cleanups and refactorings
Added utility functions for operating on positional
bit flags.

Moved retrieval of offload mix ports to ModuleConfig
utility class.

Clarify the names of read/write tests.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id20881c2e62bc1b95d8fc3c268f99e36337dce7a
2022-09-12 23:00:42 +00:00
Mikhail Naganov
4f5d3f12f5 audio: Implementation of audio I/O, part II
This patch implements audio I/O for the synchronous, non-MMAP
case.

Updated the StreamDescriptor structure to make it usable.
Clarified comments on the expectations for the client and
the HAL module.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Merged-In: I09651c6e80a397c80870622ac19234b4d4a38cbb
Change-Id: I09651c6e80a397c80870622ac19234b4d4a38cbb
(cherry picked from commit 01803d454a)
2022-08-30 01:39:24 +00:00
Mikhail Naganov
6a4872dff0 audio: Implementation of audio I/O, part I
This patch adds necessary structures and prepares for implementing
data flow for audio I/O.

Also in this patch we clarify the relationship between audio patches
and buffer size for audio I/O, and between buffer size and latency.

Bug: 205884982
Bug: 233816848
Test: atest VtsHalAudioCoreTargetTest
Merged-In: I8522632607d4cf50a112225c19b5dd5ad8848591
Change-Id: I8522632607d4cf50a112225c19b5dd5ad8848591
(cherry picked from commit 68bee70442)
2022-08-26 02:44:15 +00:00
Mikhail Naganov
111e0ceab5 audio: Add support for compressed offload
- Add compressed offload mix port into default implementation.
- Require AudioOffloadInfo to be passed to IModule.openOutputStream
  for compressed offload port configs.
- Update VTS to handle compressed offload.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Merged-In: I118b2c04bff12b64a7cac4dc2c88217a6a270046
Change-Id: I118b2c04bff12b64a7cac4dc2c88217a6a270046
(cherry picked from commit 975ea3ae89)
2022-08-25 00:25:55 +00:00
Mikhail Naganov
16db9b7c97 audio: Improve debug logging in the AIDL version, fix bugs
- Make sure the AIDL default implementation has debug output enabled.
- Log additional info in the AIDL VTS to facilitate debugging.
- Make resource handler classes move-only types.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Merged-In: I111b72aaf12962f00b4d31b8ac87186bca5eb853
Change-Id: I111b72aaf12962f00b4d31b8ac87186bca5eb853
(cherry picked from commit f82fc6476d)
2022-08-25 00:25:25 +00:00
Mikhail Naganov
00603d14b3 audio HAL: Support for external device connections
Add methods 'IModule.connect/disconnectExternalDevice' which inform
audio HAL about connection / disconnection of an external
non-attached device. Add method 'getAudioRoutesForPort' to
retrieve only routes that include the specified port.

Update the behavior of 'getAudioPorts' and 'getAudioRoutes'
indicating that the result may change due to instantiation
of new device ports for connected external devices.

Clarify behavior of 'IModule.setAudioPortConfig' that it can not
work with device ports with no profiles.

Add debug flags structure 'ModuleDebug' and method
'IModule.setModuleDebug' to control the debugging aspects. VTS
tests use these flags to test HAL behavior which would otherwise
require human intervention.

Update the default implementation and VTS for the AIDL changes.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Merged-In: Iad5f7009e283729206f88b6278c8992f7f8a92a2
Change-Id: Iad5f7009e283729206f88b6278c8992f7f8a92a2
2022-08-23 22:40:20 +00:00
Mikhail Naganov
df5adfde15 audio HAL: Minimal example implementation
Implements basic functionality for enumerating
capabilities of an audio module, audio patches
creation, and opening of I/O streams.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Merged-In: Ie5d67e9192a598260e762ae9368f99592c8ad97e
Change-Id: Ie5d67e9192a598260e762ae9368f99592c8ad97e
(cherry picked from commit ecdc6ca8e8)
2022-08-20 00:14:53 +00:00