Commit graph

28 commits

Author SHA1 Message Date
Mikhail Naganov
69d60aa02c audio: Fix some VTS issues on real devices
1. Skip testing of stream I/O on certain types of mix ports.

2. Skip testing of connection of BT SCO device.

Bug: 300735639
Bug: 326888356
Bug: 328010709
Bug: 331516432
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I9b8bbf2014e223375c8f8400ff2af32268803706
2024-03-28 17:02:27 -07:00
Aditya Choudhary
c5c6c62995 [DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I3322344f595f974f730dc824af0110388076d838
2024-01-31 11:06:17 +00:00
Michael Chan
76f06f2c6a frameCountFromDurationUs: Avoid integer overflow
Change-Id: Ifbeab2724172f0adc113d6f8852a6f8ae7870817
2023-11-13 16:53:36 +11:00
Shunkai Yao
195d3d6915 Add defaults for audio AIDL interfaces
- with defaults user don't have to change their Android.bp when there is
  a update
- update AIDL audio interfaces with android.media.audio.common.types
- update Spatialization and HeadTracking AIDL usage

Bug: 273373363
Bug: 293370815
Test: m
Test: lunch panther-trunk_staging-userdebug; m; test Bluetooth Audio
Change-Id: Ic9d8afc1d4e19e4243c66065b0a5d29156632851
Merged-In: Ic9d8afc1d4e19e4243c66065b0a5d29156632851
2023-11-06 19:14:32 +00:00
Mikhail Naganov
55045b5fce audio: Clean up and fix the bluetooth HAL module
Fix the issue with retrieving BluetoothA2dp and BluetoothLe
instances access.

In 'Module::connectExternalDevice', always call
'populateConnectedDevicePort' to allow the module implementation
to cancel device connection.

Move frame count calculation into Utils.
Clean up includes and 'using' directives.

Bug: 302132812
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I22f65b8bcdcdd9bcd67a8290520eb4a465d4c720
2023-11-03 13:57:20 -07:00
Mikhail Naganov
4bf6899cc7 audio: Ensure proper priority and scheduler for service threads
Change audio worker threads priority to ..._URGENT_AUDIO to match
the coupled thread in the audio flinger.

Set SCHED_FIFO scheduler for FAST threads (also to match AF fast
mixer/capture threads). In order to enable that, grand SYS_NICE
capability to the HAL service process and provide "getTid"
function in the StreamWorker class. For testing, add a "FAST"
output to the "stub" module in the HAL configuration.

Bug: 286914845
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Test: adb shell ps -A -T -o PID,TID,NI,PCY,PRI,RTPRIO,SCHED,CMD
      for the HAL service process during VTS test. For regular
      "reader"/"writer" threads should see 'NI 19, PRI 38',
      for FAST "writer" should see 'NI -19, PRI 43, RTPRIO 3, SCH 1'
Change-Id: Iab7e21ebc139ff11cf9b7f4a1645960db8dadd43
2023-08-07 18:15:19 -07:00
Mikhail Naganov
26dc9add8d audio: Enable use of 'expected_utils' for ScopedAStatus
Add necessary helper functions and use
RETURN_STATUS_IF_ERROR where possible.

Bug: 282568751
Test: atest VtsHalAudioCoreTargetTest
Change-Id: If68c995da0e5e0cb2e9c142ba40af6503ff628b2
2023-06-26 17:32:01 -07:00
Lorena Torres-Huerta
aa8f76af92 audio: Provide code for parsing surround sound config from XML
The main change is to convert the result of parsing from XSDC
types to AIDL, and add a VTS test for IConfig.getSurroundSoundConfig.

Extra changes:
  - add 'Unchecked' suffix to conversion functions that do not
    wrap the result into ConversionResult;
  - enable more compile-time checks for the default AIDL service,
    fix issues found.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Icf578b8d28647e6355ed5328599c77d2ca1234f9
2023-05-16 18:00:14 -07:00
Mikhail Naganov
64fd6bd779 audio: Use the canonical direction port direction in ModuleUsb
Instead of relying on the device type, use the 'AudioPort.flags'
field to determine the device direction.

Remove 'isUsbInputDeviceType' and 'isUsbOutputtDeviceType'
as they are too specific to particular device type and just
add a maintenance burden.

Bug: 266216550
Test: m
Change-Id: Ia1b9330c2b419a1a4048ed78d914d05c1caf523f
2023-05-01 13:34:51 -07:00
Mikhail Naganov
d5536d9ac6 audio: Add some utility methods, improve logging
Add 'isDefaultAudioFormat' to Utils.h.

Print the module type in 'setModuleDebug'.

Align 'suggestDeviceAddressTag' with framework code.

Bug: 273252382
Test: m
Change-Id: I0248d2e866522a63a745d4af6132b7d2b6a01564
Merged-In: I0248d2e866522a63a745d4af6132b7d2b6a01564
2023-03-30 20:32:00 -07:00
Ram Mohan
9c47719bf7 Add utils for checking range limits of effect config params
Bug: 272195502
Test: Build

Change-Id: I1ff5af7d25e9410c58f323b6d12dbe6764e40073
2023-03-28 20:28:04 +05:30
Mikhail Naganov
872d4a6518 audio: Put audio/aidl/common/include/Utils.h into 'aidl' NS
These utilities are for types generated from AIDL. Since
the types end up in the 'aidl' namespace (NDK backend), it makes
sense to keep the utilities in the same namespace.

While changing the namespace, I've found numerous useless
includes of 'Utils.h' and removing them, also reorganizing
lists of includes along the way to match the style guide.

Bug: 205884982
Test: m
Test: atest --test-mapping hardware/interfaces/audio/aidl/TEST_MAPPING
Change-Id: Ib23b47092364046f632f9503b92b9baff5b902f5
2023-03-10 11:34:31 -08:00
Mikhail Naganov
817da7d0be audio: Add vendor tags handling for AIDL
Vendor tags are used in audio attributes and in
source/sink metadata. The definition for vendor tag
syntax is the same as it used to be in HIDL.

Bug: 205884982
Bug: 272188499
Test: m
Change-Id: Iffab15edaec10f0dfccff2512bbff9dff557725a
2023-03-08 17:40:35 -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
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
Shraddha Basantwani
ae7dde5d10 Audio AIDL : Add libeffects haptic generator implementation uuid
Bug: 258124419
Test: atest VtsHalHapticGeneratorTargetTest

Change-Id: I09abbc7a74d1e75f18bd1fbb4f1c2276a420eb20
2022-12-22 01:01:18 +05:30
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
Mikhail Naganov
e467e01379 audio: Fix handling of quick worker completion in StreamWorker
In tests, it is possible that the worker exits quickly,
prior to the moment when the thread controller begins
waiting for it to start. Improper handling of this case
was causing intermittent lock-ups of VTS tests.

Bug: 205884982
Test: atest libaudioaidlcommon_test
Change-Id: I13a83113b32b859e212f1a517ad61bf5b8d43365
2022-12-03 05:00:33 +00:00
Mikhail Naganov
cce8e5f39d audio: Add pause, resume, and standby stream operations
Clarify and verify in VTS that the data FMQ of StreamDescriptor
is a transient buffer. The consumer must always read its entire
contents. This is the same behavior as in the HIDL HAL.

Define the state machine for streams and the set of commands for
transferring between states.

Clarify and verify in VTS that the frame counter of the
observable position must never be reset.

Implement commands for the synchronous I/O case.

Refactor stream test logic to simplify testing of state
transitions.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ibed7f4c3e77852863714f1910112f664b32d5897
2022-10-28 20:58:10 +00:00
Mikhail Naganov
705297317b audio: Add 'join' method to StreamWorker
This is intended for use in tests where the worker
just executes some actions and then exits by itself.
Use of 'join' instead of 'stop' ensures that the
worker goes through all actions.

Bug: 205884982
Test: atest libaudioaidlcommon_test
Change-Id: I8a9f4f0bb786ee606e3b63a9847f414119716a7d
2022-10-20 01:21:01 +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
a2c714129e audio: Add StreamDescriptor.frameSizeBytes
This field indicates the frame size and is filled by
the HAL module, so that the client does not have
to calculate it.

As a side effect, in the VTS code, a StreamContext can
now be created solely from a StreamDescriptor.

Added unit tests for the functions from Utils.

Bug: 205884982
Test: atest libaudioaidlcommon_test
Test: atest VtsHalAudioCoreTargetTest
Merged-In: Ief836b8b2d35bacb1f9778e2462d540554149d7f
Change-Id: Ief836b8b2d35bacb1f9778e2462d540554149d7f
(cherry picked from commit 5862c1e3bc)
2022-08-30 03:54:07 +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
0b9c5feed1 audio: Fix the lifetime of the StreamWorker's logic part
Fix the mistake of making StreamWorker to inherit
from the part which provides actual thread logic (Impl).
The lifetime of the logic object must be longer
than the lifetime of the StreamWorker's thread.
Otherwise, the thread could still have running while
the logic has already been destroyed (consider
the order of destructors in C++ class inheritance).

With this fix, the StreamWorker class does not have
to be a template anymore, thus reorganize the code
to move big methods into a .cpp file.

Bug: 205884982
Test: atest libaudioaidlcommon_test --iterations
Merged-In: I5bc2c8fd9d78a0fbc9fddab67456cc5214584045
Change-Id: I5bc2c8fd9d78a0fbc9fddab67456cc5214584045
(cherry picked from commmit 84024eccee)

Change-Id: I70958f437657b574cda6480c3216a0b1ea252433
2022-08-30 01:36:31 +00:00
Mikhail Naganov
48d3115614 audio: Allow stopping a StreamWorker from the looping thread
Enhance the return type of the 'workerCycle' to allow it
exiting without inducing an error on the controller side.

Also, put StreamWorker into a namespace.

Bug: 205884982
Test: atest libaudioaidlcommon_test --iterations
Merged-In: I3b27028b10f80f27985040cae8f8b0e6ab63ddad
Change-Id: I3b27028b10f80f27985040cae8f8b0e6ab63ddad
(cherry picked from commit 5021df71c7)
2022-08-30 01:30:19 +00:00
Mikhail Naganov
48e2e8fe49 audio: Implement setting name and priority in StreamWorker
Audio threads need to be able to set their priority.
Also, traditionally these worker threads set a custom
thread name. Implement this functionality in StreamWorker.

Since initialization steps can fail, implement simple
error reporting via a string field `mError`. The state
of the string field replaces the dedicated `ERROR` worker
state.

Bug: 205884982
Test: atest libaudioaidlcommon_test --iterations
Merged-In: Ie9ab94922d47f277a4993a90b478a2fa76657923
Change-Id: Ie9ab94922d47f277a4993a90b478a2fa76657923
(cherry picked from commit e9e0f7c0f5)
2022-08-26 02:43:37 +00:00
Mikhail Naganov
0c174e9133 audio: Prevent priority inversions in aidl StreamWorker
Avoid taking a lock in high priority worker threads
without a real need.

Bug: 205884982
Test: atest libaudioaidlcommon_test --iterations
Merged-In: I8cc0f5cb58752b7b7d413a9f4e46093c39445892
Change-Id: I8cc0f5cb58752b7b7d413a9f4e46093c39445892
(cherry picked from commit d989a4b669)
2022-08-26 02:42:46 +00:00
Mikhail Naganov
614e4b5f16 audio: Add StreamWorker to aidl/common
This utility class has been copied from HIDL VTS.
It will be used both for the default implementation
and AIDL VTS, and might need modifications.

Bug: 205884982
Test: atest libaudioaidlcommon_test
Merged-In: I43b35b0c23ae45305dca66e15b60820cad19635e
Change-Id: I43b35b0c23ae45305dca66e15b60820cad19635e
(cherry picked from commit c17f0484bc)
2022-08-26 02:41:58 +00:00