Commit graph

1920 commits

Author SHA1 Message Date
Shunkai Yao
84cfecd616 Merge "Fix the audio source table in Processing" into main 2023-08-24 21:11:05 +00:00
Treehugger Robot
4115d8b01d Merge "Remove the limitation of max open streams" into main 2023-08-24 19:29:36 +00:00
Shunkai Yao
2461891a1c Remove the limitation of max open streams
Bug: 295055755
Test: atest CtsMediaAudioTestCases
Change-Id: Ifc0bec23ccc2845657389783194eb18fcc7884fa
2023-08-24 18:14:03 +00:00
Treehugger Robot
16012b6b06 Merge "Migrate String8|16.setTo to assignment operator" into main 2023-08-24 15:54:28 +00:00
Treehugger Robot
58d953e4be Merge "audio: Make IConfig.getSurroundSound default implementation more robust" into main 2023-08-23 22:31:08 +00:00
Tomasz Wasilczyk
17034e5f39 Migrate String8|16.setTo to assignment operator
Bug: 295394788
Test: make checkbuild
Change-Id: Ic98514f48399115046029e68883408090f0cd0db
2023-08-23 22:14:17 +00:00
Mikhail Naganov
1e25ef808f audio: Make IConfig.getSurroundSound default implementation more robust
In the case when there is a problem with the legacy APM XML file,
the converter provides a default surround sound config. However,
the default implementation of IConfig::getSurroundSoundConfig did
not take an advantage of that, and was returning an empty config,
which is not accepted by VTS.

Also, improve logging messages: clarify the situation when no readable
audio policy XML file found, and use outer functions name for lambdas.

Bug: 293978054
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Iae069a0498009605ef5ededb9c9112efab08548a
2023-08-23 14:18:27 -07:00
Treehugger Robot
ff0aae4132 Merge "Use String8/16 c_str [audio]" into main 2023-08-23 20:46:44 +00:00
Tomasz Wasilczyk
b20afc5f87 Use String8/16 c_str [audio]
Bug: 295394788
Test: make checkbuild
Change-Id: I9cba2d925dc1e5363927ba336b0ca2c43207ddad
2023-08-23 18:45:04 +00:00
Shunkai Yao
c1056947dc Fix the audio source table in Processing
Bug: 297158046
Test: atest VtsHalAudioEffectTargetTest
Change-Id: I7102608b945b92e7d66322bc94130aa965e471ea
2023-08-23 17:40:21 +00:00
Shunkai Yao
d3e5e33330 Merge "Update vts to align AOSP effects support requirement with CDD" into main 2023-08-23 15:34:13 +00:00
Shunkai Yao
9696741d0c Update vts to align AOSP effects support requirement with CDD
Bug: 296790934
Test: atest VtsHalAudioEffectFactoryTargetTest
Change-Id: I1c837125e62a083d95e279ed0584a9bccea3dcbd
2023-08-23 15:33:51 +00:00
Shunkai Yao
7816f26afa r_submix: keep the signed value for offset calculation in AIDL implementation
otherwise a negative offset will result in long sleep

Bug: 295055755
Test: atest android.media.audio.cts.AudioPlaybackCaptureTest
Change-Id: Ie941cc2525e3ea42b53106ae3a65242794b1dd1b
2023-08-22 20:50:31 +00:00
Treehugger Robot
7f2619ddff Merge "audio: Fix remote submix module device ports handling" into main 2023-08-19 03:53:26 +00:00
Tomasz Wasilczyk
fed7d54dfc Don't use String8::empty
With the current definition, it's an alias of default constructor. This
has very different meaning from std::string empty, especially that
static method String8::empty can still be called from instance context.

One of such bugs are present in in ParametersUtil.

Bug: 295394788
Test: make checkbuild
Change-Id: I9116a0c42a6a9e94116eaaaa0fd60568db428838
2023-08-17 13:53:55 +00:00
David Li
b089c0cfee audio: Fix remote submix module device ports handling
- remove the default address "0" for IN_SUBMIX and OUT_SUBMIX;
 - remove the profiles in the device port and assign profiles when
   connecting;
 - make remote submix input to use "virtual" connection type,
   same as the output;
 - fix ModuleConfig in VTS to avoid returning devices with virtual
   connections as "external devices" because they can actually
   be connected even when connection simulation is disabled;
 - fix TryConnectMissingDevice VTS test to disconnect the device
   if the operation has unexpectedly succeeded.

Bug: 286914845
Bug: 294976817
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ife11c9c356d1b5dc587d08cef47294e3b29f65c5
2023-08-10 14:37:31 -07:00
Treehugger Robot
ff1f1f3494 Merge "audio: Implement the major functionality of the primary CF HAL" into main 2023-08-08 07:56:05 +00: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
cf824f65c8 audio: Implement the major functionality of the primary CF HAL
Core HAL changes:

1. Add StreamPrimary implemented via StreamAlsa.

2. Align the configuration with the HIDL HAL.

3. Fix position retrieval vs. standby call.

4. Fix sleeps in StreamAlsa.

VTS changes:

1. Use several bursts for stream I/O test scenarios that check
   observable position increase. This is because the position may
   not be available until a couple of transfers have been made.

2. Do not require position increase for the scenarios that do
   not make several bursts. As specified above, the position may
   not have been increased for the ALSA case. Whereas, using
   multiple bursts in all scenarios will increase test time, and
   make the state machine transitions graph more complicated.

3. Hook up the test config file to shut down audioserver during
   VTS tests, fix the test config file.

Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Test: compare APM dumps for AIDL vs. HIDL
Change-Id: I85271564c664fa40008d60e82b32eaa66a99c68f
2023-08-07 13:38:50 -07:00
Mikhail Naganov
459b7331e9 audio: Make renamings suggested by reviewers
Rename DriverInterface::getPosition -> refinePosition. This reflects
the fact that the driver may provide more precise position, however
this is an optional operation.

Rename StreamIn/Out::mContext -> mContextInstance. This is
to emphasize that StreamIn/Out actually own the context and they
hold the real context instance, not just a reference/pointer
to it, like other classes involved in the inheritance chain.

Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id7159f9bf3ee020dc7cf594ec35f5d59d23d7e31
2023-08-03 10:31:12 -07:00
Mikhail Naganov
09d45c473e Merge "audio: Address comments from an internal review" into main 2023-08-03 15:58:56 +00:00
Mikhail Naganov
0faf339425 audio: Address comments from an internal review
Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I2f636c77f67fdd8eeac70dd304848bf7f76db4e5
2023-08-02 12:24:47 -07:00
Treehugger Robot
0bc307a5dd Merge "Audio r_submix : Handle the usecase when no data is available to read." into main 2023-08-02 18:51:53 +00:00
Treehugger Robot
169be3476d Merge changes from topic "bluetoothmodule" into main
* changes:
  aosp aidl bluetooth parameter support
  aosp aidl bluetooth audio hal implementation
2023-08-02 17:41:07 +00: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
François Gaffie
acd4a677f0 Audio: add system usage to audio policy engine schemas
Bug: 293917986
Test: m

Change-Id: I49a8d3cfeb45eddc95ad6ab4a33b0adf0585cde2
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
2023-08-02 10:47:00 +02:00
Shraddha Basantwani
675cce24d6 Audio r_submix : Handle the usecase when no data is available to read.
Bug: 290116295
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ifd6706d593f890dd8ae148523a37177774c8ffd4
2023-08-02 05:19:24 +00:00
Shraddha Basantwani
2e460345a2 Audio r_submix : Replace usage of portId by device address
Use stream switcher to obtain device address for creation
of a remote submix stream.

Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I8dde3d59e488c9621dce78ffd5249254ecfc0b1a
2023-08-01 12:06:38 +00:00
Shraddha Basantwani
035beba203 Audio : Fix a few minor issues with stream switcher class
1. Constructor should forward variable arguments
2. mContext initialization was missing
3. Add nullptr check for addEffect and removeEffect methods

Bug: 264712385
Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I4037292bf497be186b26508bd16846886fa4fe55
2023-08-01 12:06:20 +00:00
Mikhail Naganov
43a85cfb2b audio: Add a helper class to simplify legacy HALs migration
Since in the C and HIDL APIs the method for opening a stream
receives the device to connect to, some legacy HAL implementations
took an advantage of that. In AIDL APIs device port connection
process is more dynamic and independent of the stream creation.

To simplify porting of legacy implementations to AIDL, a helper
class StreamSwitcher is added. It emulates the legacy behavior
by allowing to postpone the stream implementation creation until
the connected device is known. Until that moment, it exposes
to the client a stub implementation of the stream interface.

Bug: 264712385
Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ie8ae0338fd22f705e00a34e56a7fa235eda5ed9e
2023-07-24 16:40:39 -07:00
Mikhail Naganov
1eedc130e8 audio: Move frame counter to StreamContext
Moving frame counter to the StreamContext class enables
switching stream drivers on the fly while keeping the frame
count monotonically increasing.

StreamWorkerCommonLogic now holds a pointer to StreamContext,
which makes redundant storing copies of the fields of the latter.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: If6716f4051c484b52927cbfe4032df7c907eb3a5
2023-07-24 16:37:18 -07:00
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
Mikhail Naganov
2eabaf995b audio: Use ChildInterface in StreamCommonImpl
Replace the pair of 'shared_ptr<>, Binder' with
the equivalent ChildInterface.

Fix logging of returned sub-objects to print their
Binder value instead of the local pointer.

Bug: 264712385
Test: m
Change-Id: I1350e7b3720c6244cd8527e1d021ee9577399291
2023-07-19 17:36:37 -07:00
Mikhail Naganov
422f7e6b1b audio: Update StreamAlsa and alsa utils for built-in devices
Use new functions added to alsa proxy layer for opening
attached (built-in) devices.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ia2a47ff96fa62f99ce4ec4a0993ca3fd86f82c9d
2023-07-19 17:35:39 -07:00
Mikhail Naganov
f12d4a1ef8 audio: Simplify and extend alsa::Mixer
Remove alsa::MixerControl. tinyALSA contains utility
functions for setting values in percents, they use
the same logic as used to be there for handling
the "volume" control. Use access serialization at
the mixer level, rather than for each control.

Move the call to 'mixer_open' to alsa::Mixer.

Add controls for capture (mic) mute and gain. They
will be used by the primary HAL.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I0fad994153de96aceec3eb8f2fec19805ec912f8
2023-07-19 17:35:38 -07:00
Shraddha Basantwani
7770c158a1 Audio : Fix minor comments in r_submix module
Add missing check for StandbyTransition variable
Add missing & in const arguments

Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id7a30e0697da80a272768bbf2aa8e3ed748e93f4
2023-07-19 16:43:50 +05:30
Treehugger Robot
1829d2133f Merge "audio: Fix state machine initial and final state symbols" into main 2023-07-18 22:59:06 +00:00
Mikhail Naganov
f082902b41 audio: Fix state machine initial and final state symbols
In UML, the initial state is a solid circle, the final
state is a double circle. In the Core HAL diagrams it
was the opposite.

Test: dot -Tpng stream-{in|out}-[async-]sm.gv -o ...
Change-Id: Id69f17d0a47227e744eb6dadcb5fee08c07bb0bd
2023-07-18 14:46:18 -07:00
Shunkai Yao
a8c5e014db Update effect AIDL state machine graph
Bug: 271500140
Test: dot -Tpng state.gv -o state.png
Change-Id: Icbabe75e24497594f8bc62985553c1c13d268dae
2023-07-18 21:22:15 +00:00
Treehugger Robot
cdac9b5064 Merge "Make EffectFactory implementation thread-safe" into main 2023-07-17 22:43:24 +00:00
Treehugger Robot
03a07174dd Merge "Support custom effect type UUID in audio effect AIDL example service" into main 2023-07-15 00:56:10 +00:00
Shunkai Yao
074cf23ff6 Make EffectFactory implementation thread-safe
Also adjust some log level as verbos

Bug: 271500140
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Change-Id: I04560c62bdbcfb85dbe223bec0149b112205a323
2023-07-14 23:57:32 +00:00
Shunkai Yao
80e5850d82 Support custom effect type UUID in audio effect AIDL example service
Parse custom effect type uuid in audio_effects_config.xml, so OEM can
add effect types without changing code

Bug: 271500140
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Change-Id: I558958cc42c6c4a304e0ab1239ddefec9575a5af
2023-07-14 23:57:21 +00: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
Mikhail Naganov
f0ad731bb9 Merge changes I392933f8,I5e4da0c3,I2134b15e into main
* changes:
  audio: Add optional 'DriverInterface::getPosition' method.
  audio: Create ModulePrimary and ModuleStub
  audio: Move tinyALSA-specific code to Module/StreamAlsa
2023-07-13 20:10:10 +00:00
Mikhail Naganov
704aec434e audio: Add optional 'DriverInterface::getPosition' method.
This is a method which can be optionally implemented
by a stream in case it can provide more exact position,
for example by taking into account data in intermediate
buffers.

Implemented this method for StreamAlsa and StreamRemoteSubmix.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I392933f8f6b22d784726925199db00dcb0313648
2023-07-13 11:25:47 -07:00
Mikhail Naganov
521fc49fba audio: Create ModulePrimary and ModuleStub
Make 'Module' more abstract by moving stream creation
methods to more concrete 'ModulePrimary' and 'ModuleStub'.
'ModulePrimary' is now closer to the CF primary module:
it was stripped off USB devices from its configuration,
these got moved to 'ModuleUsb', and got rid of BT A2DP
and LE interfaces, these will be on 'ModuleBluetooth'.
Note that 'ModulePrimary' still uses stub streams, this
will be changed in subsequent patches.

'ModuleStub' is what 'Module' used to be, just a module
for improving test coverage. It includes simulation of
offload streams and dummy BT objects.

Bug: 264712385
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I5e4da0c32c00d65688f2eda78b2c79594e4e4671
2023-07-13 11:25:23 -07:00