Commit Graph

100 Commits

Author SHA1 Message Date
Ajender Reddy
3d248fd550 audio: fetch devices from the deviceportconfigs
As part of IModule::setAudioPatch, streams might have device
change. The new device portconfigs have the device information.

They should be same as devices fetched
mix port config id -> connected device port config ids [from mPatches]
-> associated AudioPorts [from ports] -> associated AudioDevices.

Bug: 370242708
Test: atest VtsHalAudioCoreTargetTest

Change-Id: I5765a1e5ea9f586add1c3ab50cbaef4641a32e1a
2024-10-31 15:44:37 +00:00
Weilin Xu
a33bb5eaf5 Implement volume control on default audio HAL
Implemented volume control based on setting audio port config.

Bug: 336370745
Test: atest VtsHalAudioCoreTargetTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:122597a5e96c873239540a53523caf67fe806d90)
Merged-In: Ia590974e61aa3a1c3f70afdb54ce87c85e9a1b3c
Change-Id: Ia590974e61aa3a1c3f70afdb54ce87c85e9a1b3c
2024-10-02 17:16:42 +00:00
Yi Kong
e62f97fb5b audio: Remove unnecessary std::move
Moving a temporary object prevents copy elision, and could reduce
performance.

This fixes -Wpessimizing-move compiler warning.

Test: presubmit
Bug: 154270751
Change-Id: Idb1a4abf4da9eb6dbe1e9a8fd66461d60985c8e1
2024-08-14 01:52:25 +08:00
Kuowei Li
53a8d4d62e audio: fix mmap output
1. add createMmapBuffer() for vendor to override and create mmap fd.
2. add refineMmapPosition() for vendor to override and update
latency in mmap case.
3. fix testcases position check in mmap case.

Bug: 274456992
Bug: 345591089
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ie63fdd47c0ddc563d84699dfdf6d4e9b72b5af43
2024-06-26 16:51:31 -07:00
Mikhail Naganov
efb45bc792 audio: Allow to inherit Binder RT priority in AIDL
This option is on by default for HIDL interfaces, however
in AIDL it needs to be enabled explicitly.

Bug: 331469541
Test: m
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d975a9e6ec0b6f0eeac99673b9b06e11146874ba)
Merged-In: I971185a46da4222160fb04b8b77f805ef0396562
Change-Id: I971185a46da4222160fb04b8b77f805ef0396562
2024-03-27 16:20:33 +00:00
Treehugger Robot
1d9bf983a3 Merge "audio:aidl: Use module type in log prints" into main 2024-03-11 17:21:23 +00:00
Jaideep Sharma
559a491dc1 audio:aidl: Use module type in log prints
Module base class can be used by multiple module,
to identify the module in use from logs, use mType in the logs as well.

Change log type for getVendorParameter and setVendorParameters,
as all parameters might not be supported by each module and unsupported parameter does not mean an error.

Change-Id: I0f46f8a9be733edd11186140bc9c3f51ea8d0969
2024-03-08 10:21:31 +05:30
Xin Li
c4b2f5b564 Merge "Merge Android 14 QPR2 to AOSP main" into main 2024-03-07 06:41:02 +00:00
Mikhail Naganov
b06a492bd9 audio: Preserve 'usecase' for in IModule::setAudioPortConfig
The field AudioPortConfig.ext.mix.usecase is provided by
the client, thus is needs to be treated the same way as
'.handle'.

Bug: 302736184
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I45050e8530cd236f5e582585f583df477fc7ae8a
2024-03-06 16:39:50 -08:00
Xin Li
763c473c3d Merge Android 24Q1 Release (ab/11220357)
Bug: 319669529
Merged-In: I976f80006aeb88bde2ae34ca4f9be72cea727d9e
Change-Id: Id94b25af52bd2e2847b6858697ab21cc6ce27aa3
2024-01-30 10:36:50 -08:00
Mikhail Naganov
a92039ac48 audio: Refactor configuration population
In 'Module::setAudioPortConfig' allow subclasses to provide
their own suggested configuration.

In 'Module::populateConnectedDevicePort' provide the ID of
the device port instance that will be created as a result
of connecting an external device.

Also, expose 'ModuleDebug' flags to subclasses so that they
can know when device connections are simulated.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Iceb2bdeb61c3470554b592fe197efa54d3b9e578
2023-12-20 14:31:47 -08:00
jiabin
dd23b0e58e AHAL: add API to notify the HAL module about disconnecting device.
When external device is about to disconnect, the audio framework will
notify the HAL module about the coming device disconnection so that the
HAL module could abort any active read/write operations on drivers to
avoid problems with the HW interfaces.

Bug: 279824103
Test: atest VtsHalAudioCoreModuleTargetTest
Change-Id: I9f960b8ae5df11a764e70bd63f98c0f8b8386c34
Merged-In: I9f960b8ae5df11a764e70bd63f98c0f8b8386c34
2023-12-13 01:02:21 +00:00
jiabin
bc79ff19e8 AHAL: add API to notify the HAL module about disconnecting device.
When external device is about to disconnect, the audio framework will
notify the HAL module about the coming device disconnection so that the
HAL module could abort any active read/write operations on drivers to
avoid problems with the HW interfaces.

Bug: 279824103
Test: atest VtsHalAudioCoreModuleTargetTest
Change-Id: I9f960b8ae5df11a764e70bd63f98c0f8b8386c34
2023-12-12 17:44:28 +00:00
Mikhail Naganov
6bb8fc76b2 Merge changes Ic51d603d,Ia50def0d,I22f65b8b,I8ce9f230,Id8455eb1, ... into main am: 3143e6930b am: 1afd920ac6 am: 5fde3c5693
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2811595

Change-Id: I02b9286f7b4d1702f3474094fdfbfdd8486a4e3a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-06 18:51:45 +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
1350187c6b audio: Provide a way for Module to specify nominal latency
The latency figure depends on the module implementation.
Instead of using a hardcoded value, each module should be
able to specify its own value. This value is then used
for calculating the minimum buffer size.

Set the nominal latency of the primary (CF) module to a high
value since the virtual device implementation fails CTS tests
if it attempts to pretend that it provides low latency.

Bug: 302132812
Test: atest CtsMediaAudioTestCases --test-filter=".*AudioTrackTest.*"
Test: atest CtsMediaAudioTestCases --test-filter=".*AudioRecordTest.*"
Change-Id: I8ce9f230378eea787c9b3c7ce3660c1e4e7bc895
2023-11-03 13:50:07 -07:00
Mikhail Naganov
3c8b6ce171 CSD: Add default AIDL HAL implementation
** Partial upstream of ag/24854732. Only the interface part is
** included.

This should enable the sound dose gts on cuttlefish devices. The sound
dose HAL uses the internal MelProcessor to compute the MELs which are
reported to the framework.

Test: atest GtsAudioTestCases:SoundDoseTest
Bug: 301527435
Change-Id: Ifc505a0171bc8b4d3f5cf65d950fa5c0f812087f
Merged-In: Ifc505a0171bc8b4d3f5cf65d950fa5c0f812087f
2023-10-31 11:38:43 -07:00
Lorena Torres-Huerta
9bee81e56b audio: Set connectedProfiles for non-attached device ports. am: f7492518c7 am: 6788dcd1f8 am: abcc5cd2c8
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2794108

Change-Id: Ia00d4ea2e89d6fcb2ab4436d0daca57957ce673c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 19:16:40 +00:00
Lorena Torres-Huerta
e6f63b2d4e audio: Populate MicrophoneInfo with vendor data am: 533cc78aab am: 3c0bd942f5 am: 87fe5c6ffa
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2794107

Change-Id: Ic91c67d2bfea0aa39caec0fb68c507a09a5338b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 19:16:35 +00:00
Lorena Torres-Huerta
dc40dfd675 audio: Parse module configurations from the APM XML files am: 394e2527b5 am: 55acd0beaf am: e67e7a04f4
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2794105

Change-Id: I81ba6bf19cf60d1c5360ef6b84abefe29b95fc2d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 19:16:24 +00:00
Lorena Torres-Huerta
f7492518c7 audio: Set connectedProfiles for non-attached device ports.
For external (non-attached) device ports that have dynamic
profiles, 'connectedProfiles' must be provided. They are
used when 'ModuleDebug.simulateDeviceConnections' is enabled.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
(cherry picked from commit a29393db39)
Change-Id: I69707d610c34f8f1eae9ef81768b76c40e985c0f
2023-10-17 19:54:29 -07:00
Lorena Torres-Huerta
533cc78aab audio: Populate MicrophoneInfo with vendor data
Added a virtual method Module::getMicrophoneInfos
so that vendor implementations can provide actual
data about device microphones. This information
is not part of the APM config file.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTestTest
(cherry picked from commit dc9d1a4b42)
Change-Id: I3ea9ba8da79fd29f8d69c5a575a57851d73df7b8
2023-10-17 19:54:13 -07:00
Lorena Torres-Huerta
394e2527b5 audio: Parse module configurations from the APM XML files
The default implementation now loads the HAL configuration
from the legacy XML configuration file which was previously
consumed by the framework directly.

Note that errors in the config file will lead to crash
of the XML parser, pointing out to the source of the problem.

IMPORTANT NOTES:
  - Never use untested legacy config files with production
    devices.
  - Make sure that all possible configurations (for example,
    BT offload on/off) are tested.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
(cherry picked from commit 00a7307862)
Change-Id: Id1002cb065e7cc19bdd520aca15b3fe5d39e5853
2023-10-17 19:48:24 -07:00
Mikhail Naganov
1261ff4f9b Merge changes from topic "revert-2770886-AidlAudioHalModuleConfig-FQCMWOWMCH" into main am: 03a2fbc6a3 am: fb1d459f09 am: 9868600b48 am: 9ed9a05578 am: 0cfcc0f2f9
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2786757

Change-Id: I6b5a7c2db6ee69a63abc9897bb9c1716157f641e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-14 01:35:36 +00:00
Mikhail Naganov
4f8a121dd7 Revert "audio: Populate MicrophoneInfo with vendor data" am: 5eea7fb0d7 am: ca9d26dc44 am: ab0818f638 am: 96baf7e609 am: 40d47b9456
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2786756

Change-Id: I3ed92f5ac5acc7bc9a7d33dfc313f30bc81d2a1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-14 01:35:32 +00:00
Mikhail Naganov
791a5d19b9 Revert "audio: Set connectedProfiles for non-attached device ports." am: 006a136ea7 am: bfe40ea2b0 am: 238ac10089 am: 21da9979f0 am: 3d8be4767a
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2786755

Change-Id: I4c2c62270787f883b86424c9c80d65fb03783b85
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-14 01:35:29 +00:00
Mikhail Naganov
5eea7fb0d7 Revert "audio: Populate MicrophoneInfo with vendor data"
Revert submission 2770886-AidlAudioHalModuleConfig

Reason for revert: Breaks BluetoothInstrumentationTests on main downstream

Reverted changes: /q/submissionid:2770886-AidlAudioHalModuleConfig

Bug: 305291602
Change-Id: I01a4d22056507f9047c4fead21c9a75bfa153a46
2023-10-13 23:38:25 +00:00
Mikhail Naganov
006a136ea7 Revert "audio: Set connectedProfiles for non-attached device ports."
Revert submission 2770886-AidlAudioHalModuleConfig

Reason for revert: Breaks BluetoothInstrumentationTests on main downstream

Reverted changes: /q/submissionid:2770886-AidlAudioHalModuleConfig

Bug: 305291602
Change-Id: Id325171baeabd61d244e5f15c37f7d14402bd426
2023-10-13 23:38:25 +00:00
Mikhail Naganov
af75a679c9 Revert "audio: Parse module configurations from the APM XML files"
Revert submission 2770886-AidlAudioHalModuleConfig

Reason for revert: Breaks BluetoothInstrumentationTests on main downstream

Reverted changes: /q/submissionid:2770886-AidlAudioHalModuleConfig

Bug: 305291602
Change-Id: I0076c88877943d9498f90c477e78a2be5d390150
2023-10-13 23:38:25 +00:00
Lorena Torres-Huerta
2e13df2cc7 audio: Set connectedProfiles for non-attached device ports. am: a29393db39 am: bc48f1dadd am: 14c5da7b45 am: b9457d840a am: 43fc2a8ee3
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2389654

Change-Id: Ibb797ee9a78ea8422c7c2fb9ba67e104d50d38ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 19:12:38 +00:00
Lorena Torres-Huerta
620db6886a audio: Populate MicrophoneInfo with vendor data am: dc9d1a4b42 am: 719170e066 am: ace5c10a4d am: 46d923debf am: 6b7c01e791
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2389656

Change-Id: I4234d8b63c55b5d70bd6f08ef235ff6e1d2bfc29
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 19:12:33 +00:00
Lorena Torres-Huerta
feba04d900 audio: Parse module configurations from the APM XML files am: 00a7307862 am: 8c04b54e05 am: e8f7b43dc6 am: 395beaa6e1 am: 99addf244e
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2363149

Change-Id: I52ddf8fcec0930f465171fd134addac4f5d6c472
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 19:12:27 +00:00
Vlad Popa
66465ca3e6 Merge "CSD: Add default AIDL HAL implementation" into main 2023-10-12 21:42:31 +00:00
Lorena Torres-Huerta
a29393db39 audio: Set connectedProfiles for non-attached device ports.
For external (non-attached) device ports that have dynamic
profiles, 'connectedProfiles' must be provided. They are
used when 'ModuleDebug.simulateDeviceConnections' is enabled.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ic82e47abc50e2958ed93f5d4d18082b569ecb67b
2023-10-11 19:38:12 -07:00
Lorena Torres-Huerta
dc9d1a4b42 audio: Populate MicrophoneInfo with vendor data
Added a virtual method Module::getMicrophoneInfos
so that vendor implementations can provide actual
data about device microphones. This information
is not part of the APM config file.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTestTest
Change-Id: I4b650ae221ba866421bbf8500ad8c17f04bc4aa7
2023-10-11 19:36:38 -07:00
Lorena Torres-Huerta
00a7307862 audio: Parse module configurations from the APM XML files
The default implementation now loads the HAL configuration
from the legacy XML configuration file which was previously
consumed by the framework directly.

Note that errors in the config file will lead to crash
of the XML parser, pointing out to the source of the problem.

IMPORTANT NOTES:
  - Never use untested legacy config files with production
    devices.
  - Make sure that all possible configurations (for example,
    BT offload on/off) are tested.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I01e4cd77a284d7df64ecb0c0b21cb16abfa0f6c5
2023-10-11 18:31:25 -07:00
Mikhail Naganov
84bcc049e6 audio: Allow "dynamic" profiles for device ports
Some device ports are connected via ADSP which takes care
of the actual audio configuration (format, channels, SR),
for example the built-in speaker and mic ports, as well
as some external devices like analog headsets.

In the legacy implementation, such device ports did not have
any profiles specified. Allow the same behavior in the AIDL
implementation. To ensure correctness, device ports with no
profiles must be routable to mix ports that have profiles
specified. This requirement is fulfilled in legacy configs.

Bug: 266124463
Test: atest VtsHalAudioCoreTargetTest
Test: atest audiosystem_tests audiorouting_tests
Test: atest CtsMediaAudioTestCases
Change-Id: Iaccd1e8ef2a5af9a5f8bae453905d01c6b7fdc28
2023-10-10 15:15:50 -07:00
Vlad Popa
ce33864049 CSD: Add default AIDL HAL implementation
This should enable the sound dose gts on cuttlefish devices. The sound
dose HAL uses the internal MelProcessor to compute the MELs which are
reported to the framework.

Test: atest GtsAudioTestCases:SoundDoseTest
Bug: 301527435
Change-Id: Ifc505a0171bc8b4d3f5cf65d950fa5c0f812087f
2023-10-05 11:25:09 -07:00
Mikhail Naganov
0da62dd023 Merge changes I7df6e323,I0e3412b9 into main
* changes:
  audio: Fix notification of streams of the device change
  audio: Fix update of an existing patch
2023-10-02 18:06:44 +00:00
Mikhail Naganov
89a8ea964d audio: Fix notification of streams of the device change
Replace the incorrect logic which was considering each
port individually with the correct logic which considers
a connection of a mix port to device ports.

Bug: 302573756
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I7df6e32315945897d88923ea4d9744e590e85dfd
2023-09-29 17:05:23 -07:00
Mikhail Naganov
dc41773ba3 audio: Fix update of an existing patch
The code for updating the existing patch did not modify
the patch stored in the module's list of patches.

Added a test which switches the patch to another port
config and validates that 'Module.getAudioPatches' returns
the updated patch.

Bug: 302573756
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I0e3412b9387cd451436a48af116dc5a940d868cf
2023-09-29 17:05:13 -07:00
Mikhail Naganov
8506491475 audio: Align Module::getMmapPolicyInfos behavior with legacy
When there are no device ports supporting MMAP,
Module::getMmapPolicyInfos have to return 'Policy::NEVER'
so that the AAudio code does not attempt to use
the AAudio service. This aligns with the use of sysprops
by the HIDL implementation.

Update AudioCoreModule#GetMmapPolicyInfos test to use
the same logic for determining MMAP support as the framework
uses.

This makes CtsNativeMediaAAudioTest cases passing with
the AIDL HAL on Cuttlefish.

Bug: 302049825
Test: atest VtsHalAudioCoreTargetTest
Test: atest CtsNativeMediaAAudioTest [w/AIDL enabled on CF]
Change-Id: Ie58c408f6f648a8a03b6a5d92118b90061389c50
2023-09-26 17:20:58 -07:00
Mikhail Naganov
0e128dd3fe audio: Fix handling of external devices disconnection
A mix port can be patched to multiple connected device ports. Thus, when
disconnecting an external device and removing the connected port, the
profiles of the mix port can only be cleared iff there are no more
connected device ports patched to it, and it did not have profiles prior to
connection of the first device.

Enhanced VTS tests to catch this problem in the HAL implementations. Also,
ensure that audio ports and audio routes do not change after the test
finishes. This ensures that tests can't affect each other.

Bug: 298175108
Test: atest audiosystem_tests
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ia666b874958fb260513fc2b8cd20a823953ec679
2023-09-13 19:41:46 -07:00
Mikhail Naganov
fcf980e586 audio: Properly support external device port with static configs
External device ports might not have dynamic profiles, for example,
ports for BT devices. Properly handle this case in the default
implementation.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Test: atest audiosystem_tests
Change-Id: I8d4bcbf6ccf2ba05436e68e3ba94567fc7610eb7
2023-09-08 09:47:30 -07:00
Ram Mohan
18f0d5121a aosp aidl bluetooth parameter support
Bug: 228804498
Test: atest VtsHalAudioCoreTargetTest
Change-Id: If1820018d5a6750eed0d0b486e15fc7c717aa11c
2023-08-02 21:42:01 +05:30
Mikhail Naganov
b03b5c4a06 aosp aidl bluetooth audio hal implementation
Bug: 228804498
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id5fb60fe53ead9f5d2e6ecbb9988a23835cf2509
2023-08-02 21:42:01 +05:30
Mikhail Naganov
780fefb331 audio: Update ChildInterface to set scheduler policy lazily
Since the client may end up never retrieving the interface
instance for sending it over Binder, postpone setting
of the scheduler policy to until that very moment.

Rename 'ChildInterface::getPtr' to 'getInstance' for clarity.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I31f9dd832c7f85f9632d1d389a8b1063d237d4c1
2023-07-24 16:36:51 -07:00
Treehugger Robot
12c4bf6ba1 Merge changes from topic "fix-b-264712385-primary-module" into main
* changes:
  audio: Move StreamContext ownership out from StreamCommonImpl
  audio: Use ChildInterface in StreamCommonImpl
  audio: Update StreamAlsa and alsa utils for built-in devices
  audio: Simplify and extend alsa::Mixer
2023-07-20 23:09:50 +00:00
Mikhail Naganov
6ddefdbcdf audio: Move StreamContext ownership out from StreamCommonImpl
Upcoming implementations of the streams of the primary module
will need to change the underlying stream type depending on
the current connected device. The stream context must persist,
thus its life time must be bound to the IStreamIn/Out implementation.
Move the StreamContext instance under ownership of StreamIn/Out.

Add StreamCommonImpl::onClose so that the owner of the context
may know when it is safe to reset it.

Re-arrange the order of the arguments when creating a stream
so that the context always comes first.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Iaf13d4bc3a53cbfc27264d3abd1f6c417ece3941
2023-07-19 17:49:28 -07:00
Peter Yoon
918a6a5ce9 audio: Allow Module subclasses to customize Configuration
When a vendor HAL reuses libaudioserviceexampleimpl,
a subclass of Module cannot change Configuration.

This change adds virtual method Module::initializeConfig(),
then a vendor HAL can override it to load custom Configuration.

Test: atest VtsHalAudioCoreTargetTest
Change-Id: I63fa8d70f3c4e13c8938070ee5431ebefd36bb58
2023-07-15 05:50:27 +09:00