Audio policy engine supports receiving a preferred device to use
for a given strategy (Engine superclass). Use of the preferred
device intervenes at the level of the each engine implementation,
here in the default engine in getDevicesForProductStrategy() method
so it is saved in the routing cache, and respects existing routing
priorities.
Refactor the loops for call and output rerouting into a new
updateCallAndOutputRouting() method.
Bug: 144440677
Test: atest AudioServiceHostTest#testPreferredDeviceRouting
Change-Id: Ic4c690e1b0d8020c4335979e40e14e6df5887879
Add the possibility to specify a target audio device when
creating an audio effect by passing its type and address to
AudioEffect constructor.
When doing so, the session ID must be AUDIO_SESSION_DEVICE.
Bug: 136294538
Test: make
Change-Id: I2a2eba340d3c2537285c091e9a53f305ff161a2b
Add specific audio session ID for effects applied to a
particular audio device.
Device specific effects will be attached to a particular audio sink or
source device identified by its unique audio port ID and will all use
this same session ID.
Only one session of this type exists on a given playback or record
thread.
All effects in this session apply to the same device ID and are created/released
when the routing (audio patch) of this thread output or input stream is updated.
Bug: 136294538
Test: make
Change-Id: I4e3a55ed1244b918429dd9e217b6efecc1ec6449
Add request to create tombstones of audio HAL servers before restarting
audioserver process when the watchdog triggers.
Add audio device factory HAL interface API to retrieve HAL process pids when
possible (on debug builds).
Add AudioFlinger service API to set audio HAL process pids from
JAVA AudioService.
Bug: 141528385
Test: Force watchdog and verify tombstone creation
Change-Id: I68c1e8fb4db23e5952ad0c93d7d0b9d121b8ec18
Merged-In: I68c1e8fb4db23e5952ad0c93d7d0b9d121b8ec18
Add the possibility for apps to indicate that their
capture use case is private and that a privileged Assistant
should not be able to capture concurrently.
This allows to override the default behavior tied to the audio
source (e.g VOICE_COMMUNICATION is private by default but
UNPROCESSED is not).
- Add AAudio API to set and get privacy sensitive mode on input stream
- Add MediaRecorder API to set and get privacy sensitive mode
- Modify AudioSource constructor to accept audio attributes instead of an
audio source to specify the use case.
- Modify audio policy concurrent capture logic to use audio attributes
flag instead of audio source to decide of a capture client has
requested privacy mode or not.
Bug: 137850106
Test: CTS AudioRecordTest and MediaRecorderTest, manual audio smoke tests
Change-Id: I250ea5da4c1da809ceac0da22ae9bee15b937001
Refactor interface between audio flinger and audio policy. Use device
descriptor instead of audio device type and address. DeviceDescriptor
can contain more information that may be useful when opening an output
stream.
In audio policy, if multiple audio devices are passed in when opening
an output stream, one device is extracted using the same strategy as
when selecting a device for volume application. When starting source,
audio policy manager will call audio flinger to create audio patch. In
that case, multiple devices will still be patched to the output stream.
Test: atest AudioTrackTest AudioPlaybackCaptureTest
Test: atest audiopolicy_tests, audio smoke test
Change-Id: I46dc2da621614f8716c6c73cf807fe7d2d672cda
Merged-In: I46dc2da621614f8716c6c73cf807fe7d2d672cda
This change mainly aims at refactoring libmediahelper. Libmediahelper
doesn't need to be stored in media folder. In that case, move
libmediahelper related file to a new folder. In the meantime, move
AudioParameter.h from libaudioclient to libmediahelper. There is no
need to keep AudioParameter.h in libaudioclient while AudioParameter.cpp
is in libmediahelper.
Test: make
Bug: 135621476
Change-Id: Icce6615b7e3a68be8b7492f2a91922ab04464ca2
Merged-In: Icce6615b7e3a68be8b7492f2a91922ab04464ca2
Move AudioDeviceTypeAddr from AudioPolicy.h to libaudiofoundation.
AudioDeviceTypeAddr is a class that contains audio device type and
address. It can be used not only in audio policy, but also other places.
Bug: 135621476
Test: make, atest AudioHostTest
Change-Id: Ib257859891c647c07f22771012efdada438a4ff5
Merged-In: Ib257859891c647c07f22771012efdada438a4ff5
1. Query 44100 and 48000 SR if proposed SR is not supported
2. Query AUDIO_CHANNEL_IN_MONO and AUDIO_CHANNEL_IN_STEREO if
proposed channel_mask is not supported
3. Return with bytes rather than frames
4. Fix destinationFramesPossible usage
Test: run cts
android.media.cts.AudioRecord_BufferSizeTest#testGetMinBufferSize
Bug: 144245613
Bug: 144245318
Bug: 144000030
Change-Id: I0fa90eb1bef63bd441724cdb0fa7f9172f503364
Add request to create tombstones of audio HAL servers before restarting
audioserver process when the watchdog triggers.
Add audio device factory HAL interface API to retrieve HAL process pids when
possible (on debug builds).
Add AudioFlinger service API to set audio HAL process pids from
JAVA AudioService.
Bug: 141528385
Test: Force watchdog and verify tombstone creation
Change-Id: I68c1e8fb4db23e5952ad0c93d7d0b9d121b8ec18
Move AudioDeviceTypeAddr from AudioPolicy.h to libaudiofoundation.
AudioDeviceTypeAddr is a class that contains audio device type and
address. It can be used not only in audio policy, but also other places.
Bug: 135621476
Test: make, atest AudioHostTest
Change-Id: Ib257859891c647c07f22771012efdada438a4ff5
Add new audio mode AUDIO_MODE_CALL_SCREEN allowing call screening
to take place while other audio use cases are still active.
Also add API and audio policy configuration attribute to
indicate if the platform supports this audio mode.
Bug: 140384450
Test: make
Change-Id: If2fc56dbbd10aae2cf1498480471b35de0940228
Refactor interface between audio flinger and audio policy. Use device
descriptor instead of audio device type and address. DeviceDescriptor
can contain more information that may be useful when opening an output
stream.
In audio policy, if multiple audio devices are passed in when opening
an output stream, one device is extracted using the same strategy as
when selecting a device for volume application. When starting source,
audio policy manager will call audio flinger to create audio patch. In
that case, multiple devices will still be patched to the output stream.
Test: atest AudioTrackTest AudioPlaybackCaptureTest
Test: atest audiopolicy_tests, audio smoke test
Change-Id: I46dc2da621614f8716c6c73cf807fe7d2d672cda
This reverts commit a0877dc731.
Reason for revert: Should work with go/pag/1465463 merging to master.
Change-Id: I17217744eacabf15621d4a5aac9dd1678e37e4ba
This change mainly aims at refactoring libmediahelper. Libmediahelper
doesn't need to be stored in media folder. In that case, move
libmediahelper related file to a new folder. In the meantime, move
AudioParameter.h from libaudioclient to libmediahelper. There is no
need to keep AudioParameter.h in libaudioclient while AudioParameter.cpp
is in libmediahelper.
Test: make
Bug: 135621476
Change-Id: Icce6615b7e3a68be8b7492f2a91922ab04464ca2
Split AudioMixer into the base part which doesn't rely on
the framework and can be used in vendor code and the derived part
which is intended to be used by Audioflinger.
Test: A/B compare output from test scripts, manual testing on the phone
Merged-In: I24c390f67f20baa8109902099359ca6e34eebcfd
Change-Id: I24c390f67f20baa8109902099359ca6e34eebcfd
- Remove unused dependencies on libnbaio and libnblog;
- Move dependencies on libaudiohal and libsonic to libaudioprocessing
as AudioMixer implementation does not use them.
Test: make
Merged-In: I258a450725bdacb4fcf437b6f86582d51d40e622
Change-Id: I258a450725bdacb4fcf437b6f86582d51d40e622
Since AudioParameter.h is vendor-available, some vendors may
still use the old parameters. Leave the old parameters there
but mark as deprecated.
Bug: 138868195
Test: make
Change-Id: I6d12b7ac360309014a240a321c3cd32b39d8f740
Merged-In: I6d12b7ac360309014a240a321c3cd32b39d8f740
During the transition to Treble, "device connect" / "disconnect"
parameter was erroneously attributed to audio streams. This
issue got fixed in Audio HAL V4.0, but AudioParameter file
was still using incorrect name for the constant.
Test: make
Change-Id: I4056ad9e98af6dadd017d22bc4bde031cac75631
Merged-In: I4056ad9e98af6dadd017d22bc4bde031cac75631
This change renames the IMemory raw pointer accessors to
unsecure*() to make it apparent to coders and code reviewers
that the returned buffer may potentially be shared with
untrusted processes, who may, after the fact, attempt to
read and/or modify the contents. This may lead to hard to
find security bugs and hopefully the rename makes it harder
to forget.
The change also attempts to fix all the callsites to make
everything build correctly, but in the processes, wherever the
callsite code was not obviously secure, I added a TODO requesting
the owners to either document why it's secure or to change the
code. Apologies in advance to the owners if there are some false
positives here - I don't have enough context to reason about all
the different callsites.
Test: Completely syntactic change. Made sure code still builds.
Change-Id: I5fb99aa797c488406083178a6b05355d98710d3b
Add the possibility to silence a particular AudioRecord
client rather than silencing all clients sharing the same UID.
Test: AudioRecordTest#testRecordNoDataForIdleUids
Change-Id: Ic472045cd45c7222ca3a88ccf131435fd1e26475
Move ExtendedAudioBufferProvider.h to libaudioclient. This is
a more appropriate location because EABP extends AudioBufferProvider.
Move SingleStateQueue.h to libnbaio_mono. This is a more appropriate
location because SSQ is a non-blocking queue.
This allows to remove the dependency of libnbaio on libmedia
which is a good thing because libnbaio provides more low-level
abstractions than libmedia.
Also, replace a dependency of libnbaio on libbinder with
a dependency on libaudiohal header library.
Test: make
Change-Id: Ie48b523790cd8230695ec2e4710e50981b616289
Since AudioParameter.h is vendor-available, some vendors may
still use the old parameters. Leave the old parameters there
but mark as deprecated.
Bug: 138868195
Test: make
Change-Id: I6d12b7ac360309014a240a321c3cd32b39d8f740
The implementation files are in libaudioprocessing,
thus the header files also belong there.
Test: make
Change-Id: I78ba4ed480413c0a1b871e80971ef5ce1d0c6755
During the transition to Treble, "device connect" / "disconnect"
parameter was erroneously attributed to audio streams. This
issue got fixed in Audio HAL V4.0, but AudioParameter file
was still using incorrect name for the constant.
Test: make
Change-Id: I4056ad9e98af6dadd017d22bc4bde031cac75631
Enable audio capture by the Assistant when RTT is ON during a call
similarly to when an accessibility service is in the foreground.
Also remove log when permission checked for hotword
and audio output capture fail as those checks are now done
systematically.
Also do not check permission to bypass interruption policy if
bypass flags are not set.
Bug: 132976361
Test: use voice input during a call with RTT enabled.
Change-Id: Iff45b0816dac889262ec29ea115f74dea4dc6b6d
In order for the build system to track updates to the header files
during incremental builds, always specify the src files using the same
path as the package for C++ compilations.
Bug: 112114177
Test: m
Change-Id: I5fb25124a26f190c462e2e60fc75a88d48643c10
Merged-In: I5fb25124a26f190c462e2e60fc75a88d48643c10
In order for the build system to track updates to the header files
during incremental builds, always specify the src files using the same
path as the package for C++ compilations.
Bug: 112114177
Test: m
Change-Id: I5fb25124a26f190c462e2e60fc75a88d48643c10
Add check for privileged permission if attributes
flags BYPASS_INTERRUPTION_POLICY or BYPASS_MUTE are set.
Bug: 131873101
Test: Manual smoke tests for audio playback.
Test: Emergency cell broadcast in
Change-Id: I073cf669f606f0d081ff5c8d19f39b5e12efe297
Audio mix rules that contain both a match and exclude for a uid
or usage are ignored for routing evaluation. The implementation
of the uid-device affinity caused uid matches and exclusions to
be added to any mixes, causing previously valid mixes to be
discarded in the routing logic.
The fix consists in implementing the uid-device affinity by only
applying uid exclusions on mixes that:
a/ are compatible with the concept (mixes of players that are
render only),
b/ do not route to the selected devices
c/ do not have a uid match rule (such mixes are already exclusive
to the uid to match)
d/ do not already have a uid exclusion for the uid
Fix removeUidDeviceAffinities() that skipped the wrong mixes.
Bug: 124319394
Bug: 131180578
Test: atest AudioHostTest#testUidDeviceAffinity
Change-Id: I813c4cfb15956e56599740948775c32562266c21
When AudioRecord object is destroyed, it must unregister
with AudioManager so it removes the tracker from
the tracking list.
Bug: 123312504
Test: start and stop audio recording, check "dumpsys audio"
Change-Id: Ida71512cb811d7602da349a58a91c95111078ef4
Callback may wait nearly the entire period when double buffered
which can lead to random glitches. Limit this to half the mixer period.
Test: aaudio test write_sine_callback -pl -n1 -r44100 -s20
Bug: 129545307
Bug: 131601263
Change-Id: I6b7478728fe7ead570251662ee48a8f8adad0d5d
Do not force audio device changed callback when the client
(AudioTrack or AudioRecord) registers to AudioFlinger but only when
it starts playback or capture. Doing so prevents a spurious callback
happing at registration time where a stale device
(previously selected by AudioFlinger thread) but irrelevant to this
client is indicated. This causes a disconnection of AAudio streams
despite no real device change.
Bug: 128630993
Test: CTS: android.nativemedia.aaudio.AAudioTests, android.media.cts.RoutingTest
CTS Verifier: Audio Input/Output Routing Notifications Test
Change-Id: Ia7f1d11490989b0287c97479466c1c07a223aab3
The client must provide a unique Record ID (RIID) when creating
an AudioRecord. This RIID is passed down to AudioInputDescriptor
in AudioPolicyManager which sends configuration updates
via IAudioPolicyServiceClient callback.
By supplying RIID, the Audio Service can coalesce start / stop
events coming from clients (apps) with recording configuration
update events.
For AAudio MMap clients everything is handled at the server
side because they correspond directly to audioserver objects.
Bug: 123312504
Test: android.media.cts.AudioRecordingConfigurationTest
AudioRecordTest#testAudioRecordInfoCallback
MediaRecorderTest#testAudioRecordInfoCallback
manual testing using Oboe and Solo test apps
Change-Id: I3d32241752d9a747736606dc4cb1e068e6b7aa3b
Add pre processing effect management for concurrent capture scenarii.
When several clients on the same input stream have enabled audio effects,
only the effects attached to the top priotity client are active.
Other effects are suspended.
Add AudioFlinger API to suspend/restore audio effects build on top
of exisiting internal effect suspend mechanism.
RecordThread now supports more than one effect chain.
AOSP pre processing implementation supports more than one effect session
per input.
Refactor AudioPolicyManager::closeAllInputs() to call closeInput() on
all inputs instead of partially duplicated code.
Bug: 128419018
Test: make
Change-Id: I685286da4c2905a8894a4354679f9787b1400621
Remove effect specific mutex (mEffectLock) in AudioPolicyService: Due to
concurrent capture (among other reasons), it is necessary that the audio
policy manager state preserved by mLock includes audio effects
registration and enabling.
Moved all audio policy API calls from audio flinger out of locked regions
for audio flinger, thread and effects mutexes to avoid cross deadlocks
between audioflinger and audio policy manager:
- centralized audio policy API calls in EffectModule::updatePolicyState()
- the enabled state now reflects the state requested by the controlling
handle, not the actual effect processing state: a suspended effect is
now considered enabled.
A new audio policy manager API moveEffectsToIo() is added to atomically
handle moving effects to a new input or output without having to call
unregister > register > enable sequence.
Also fix assert in setStreamVolume to match volume group refactoring
in audio policy manager.
Bug: 128419018
Test: CTS tests for audio effects.
Test: manual tests with Duo calls, Play Music, Youtube, notifications
with and without Bluetooth and wired headset.
Change-Id: I8bd3af81026c55b6be283b3a9b41fe4998e060fd
Regression caught on Attributes referred by their flags only
(like BT SCO).
Client may have more flags than the product strategy, checks
to be done on all the flags of the product strategy are requested
by the client.
Bug: 130284799
Test: make
Change-Id: Ie8d41a592342bc0a7a0326f9766e7e7503154e62
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Handles change in Q, where we do not return an invalid kernel time
in the extended timestamp when there is a reported error from the HAL.
Test: Photos, File playback, AudioTrackSurroundTest#testPlaySineSweepBytes
Bug: 113294730
Bug: 118506063
Bug: 119895849
Bug: 120631792
Change-Id: I90f2c7c314baa474c3dd3a24042f1d4b8bc0a12b
The matching rule on audio attributes flags must be that ALL flags
set in the reference attributes are present in the compared attributes
and not just some flags.
Bug: 129721367
Test: change volume in Play Music
Change-Id: I6b5ada937aa169dbf1b0315d56172ae3b7bb4f47
(cherry picked from commit c0c6074f55)
Apps were previously forced to set their allowed capture policy from
either their manifest which is not flexible or from each track which is
a very fine grain but difficult when using libraries like exoplayer.
Thus add an application level policy set with AudioManager.
Test: atest android.media.cts.AudioPlaybackCaptureTest
Bug: 111453086
Change-Id: Ic890b5b041affea757fbd3f2707ff2ce18771828
Signed-off-by: Kevin Rocard <krocard@google.com>
For system application with the new permission CAPTURE_MEDIA_OUTPUT, or
CAPTURE_AUDIO_OUTPUT, allow to capture the audio of playing apps that
allow it.
Test: adb shell audiorecorder --target /data/file1.raw
Test: atest android.media.cts.AudioPlaybackCaptureTest
Bug: 111453086
Change-Id: I5bfca51e48992234508897c595a076d066db26b2
Signed-off-by: Kevin Rocard <krocard@google.com>
Combine adjust channels buffer provider and adjust channels non-destructive
buffer provider.
When contracting mono + haptic channels to mono, do not use
adjust_channels to avoid mixing haptic channel into audio channel.
Bug: 125915810
Test: play audio-haptic coupled files
Change-Id: I39916a3e0628a44ed4a148c265564af7135a2176
When an AudioTrack or AudioRecord is created by system server,
if restoreTrack_l() or restoreRecord_l() is called from AudioTrackThread
or AudioRecordThread, and that then calls audioserver through binder,
which then calls a Java service, binder recursion may call Java
on the original calling thread.
Test: bluetooth calls don't crash
Bug: 126948865
Bug: 127619936
Change-Id: I41fcb666d07c4ab985f5590e40e0c310709e786d
This CL adds the concept of Volume Group to the engine.
It generalizes the volume management today controled by stream types
and hard coded into AOSP.
The goal is to control the volume per attributes, being able to define
a group of attributes that follow the same volume curves.
It intends to replace the concept of aliases in AudioService.
Bug: 124767636
Test: build
Change-Id: Icd079374cc1680d074b01836eca0bceb0b0c5247
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Use the constant from IExternalVibratorService.
Bug: 124318236
Test: play audio-haptic coupled file
Change-Id: Ice2ac13d0f6a6a749bb6243230524336144fa5f4
commit 24a9fb0d left some locking issues with management of device
callbacks in AudioSystem, AudioTrack and AudioRecord.
This change makes that the AudioSystem mutex is not held when
callbacks are called into AudioTrack and AudioRecord removing cross
deadlock risks and allowing AudioRecord and AudioTrack to hold their
mutexes while installing and handling the callbacks
Test: CTS RoutingTest, AudioTrackTest, AudioRecordTest
Change-Id: I5d17e77ca26220092deb0bd6e5a33dc32348d460
This CL forces the onAudioDeviceUpdate on register event.
It also fixes the loss of callback on AudioTrack or AudioRecord
client if received before ioHandle is assigned.
Test: audio smoke tests
Test: CTS for AudioTrack and AudioRouting
Change-Id: I119b5c407da68a5b55162550bea5fa7e724165d1
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
A media application takes advantage of HwAudioSource would call
start/stopAudioSource directly.
Bug: 112161027
Test: Launch FM Tuner application
Change-Id: Ic4c23f51010dbb3f2226d9d2200e11feb908867b