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
OpPlayAudioMonitor was constructing a weak pointer to itself
in the constructor. This practice can lead to crashes due to
race conditions vs object destruction. This code is now moved
to onFirstRef method which is called when at least one strong
reference exists.
This change also reduces the number of created OpPlayAudioMonitor
objects by using a factory method.
Bug: 130038586
Test: enable / disable DND mode
Change-Id: I22e63a883ebaa25b9c96e79271bb9693b5ed75cd
AudioFlinger used to reject requests for the low latency FAST
path when the capacity was != mPipeFramesP2.
But if the caller requests < mPipeFramesP2 than we can just bump it
up to mPipeFramesP2 because the API allows that.
For example, on Pixel, mPipeFramesP2 is 4096
Bug: 80308183
Test: adb shell input_monitor_callback -pl -b4000 -m1
Test: should see performance mode 12 for LOW_LATENCY
Change-Id: I987067910de3194fb52370d0ea1626cffad6248c
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
AudioPolicy used to hide activity of stream patch to prevent changing
the volume.
This CL replaces the filtering of the stream patch activity on the policy
by a full volume range within audio flinger.
It updates also product strategies example for automotive to add associated
strategy and full range volume.
Bug: 130284799
Test: make
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Change-Id: I6e77dc2cbed0289f0a1341f7597b1c25abee5f7d
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
Allow at most one effect chain with same sessionId on mPlaybackThreads.
Test: poc, CTS effect tests
Bug: 123237974
Merged-In: Ide46cd23b0a9f4295f0dca2fea23379a76b836ee
Change-Id: Ide46cd23b0a9f4295f0dca2fea23379a76b836ee
(cherry picked from commit 1631f06feb)
(cherry picked from commit f963b2bfda)
It's possible that tracks with the same session id running on various
playback outputs, which causes effect chain being created on the same
session twice. As a result, the same effect engine will be released
twice as the same context is reused.
Output that has effect chain with same session id is more preferable.
Test: No regression with Play Music and Effects
Bug: 123082420
Bug: 123237974
Merged-In: I690ea3cb942d1fdc96b46048e271557d48000f43
Change-Id: I690ea3cb942d1fdc96b46048e271557d48000f43
(cherry picked from commit 9aeb1770d4)
(cherry picked from commit 5945746bca)
The haptic intensity for fast track should be initialized, or it will be
HAPTIC_SCALE_MUTE by default, which may result in no haptics.
Bug: 130312331
Test: play haptics stream with FastMixer enabled
Change-Id: If5a1ea12c563c4af1422b2e32451b80e69d2ef58
The haptic data will be partially interleaved at the end of the buffer
after processing audio mixing. When processing audio effect, only audio
data will be handled. In that case, haptic data will be missed if there
is any audio effect. Copying haptic data directly from audio effect in
buffer to out buffer could help solve the problem.
Bug: 129956425
Test: play haptic with audio effect.
Change-Id: I2b48bb43bec10167d4eacbcaa5c27959e0d44c32
Fix a cross deadlock between thread and effect chain mutex introduced by
commit 446f4df5.
Bug: 130044136
Test: start/stop audio capture for voice communication in 2 different apps
Change-Id: I23bdbd203476d2bc0b3d8d87ab66e1a9c00f7bcd
Mute/unmute tracks according to changes in OP_PLAY_AUDIO for
the current usage.
In audio policy: always assign AUDIO_STREAM_ENFORCED_AUDIBLE
to sonification tracks with AUDIBILITY_ENFORCED flag.
Do not mute tracks from root / audio server.
Do not mute UI sounds on AUDIO_STREAM_ENFORCED_AUDIBLE
stream type.
Bug: 112339570
Test: enter DnD, play notifications, verify not heard
Change-Id: Ia5f1118481cf0573101acf2092fbd0ce2cf8c038
Previously, ThreadBase::mLock was only acquired inside
ThreadBase::dumpBase method. That means, dumping of fields of
descendant classes, tracks, and effect chains was performed
without holding ThreadBase::mLock.
This patch changes the way of how dumping is driven. Now only
ThreadBase has a public 'dump' method which is non-virtual.
This method takes the lock and dumps all the fields, tracks, and
effect chains. It calls virtual methods for dumping the contents
of descendant classes.
Bug: 118842894
Test: compare audioflinger dumps A/B
Change-Id: Iaafc75d13935a6a92ca37f9567b7ac7c31374b3e
Fix missing log line in the case when there are no effects in
the chain.
Bug: 118842894
Test: adb shell dumpsys media.audio_flinger
Change-Id: I31fe4760caa61610de4f143b3a6ae185efb55baa
The technique of bouncing lock attempts does not work well
in the case when another lock has higher priority and acquires
the lock frequently. Timed lock works better in this case
because the acquiring thread is then put in a queue and gets
the lock as soon as another thread releases it. The wait time
in the worst case (deadlock) is the same.
Bug: 118842894
Test: Run VOICE_COMMUNICATION capture + AEC effect, dump audioflinger
Change-Id: Idc4fc2b6f5faf6988979f9354dd92441af33e600
This makes the libaudioflinger build deterministic between
devices.
A few notes:
- the include-path-for include is obsolete, so it was removed
- the AUDIOSERVER_MULTILIB use was removed, as I believe it's
unused
Bug: 121208203
Test: make
Change-Id: I08eb0d7f53f1fbcef3e14faa3ea75b5326383ef8
Not required and do not assume it.
Test: no regression with atest CtsNativeMediaAAudioTestCases
Bug: 128615806
Change-Id: I29d77d01aad417cc6aa6f882b7bc0812775e13c6
Output error messages on failure.
Test: CTS effects, dedicated test with bad sessionId
Bug: 128528126
Change-Id: Icdd306c30e8eb818b0a27d6463fa785bac2fb707
Allow at most one effect chain with same sessionId on mPlaybackThreads.
Test: poc, CTS effect tests
Bug: 123237974
Change-Id: Ide46cd23b0a9f4295f0dca2fea23379a76b836ee
The code for clearing software patch connections was missing
a check for a null track pointer.
Bug: 126789266
Bug: 128269566
Test: see repro steps in b/128269566
Change-Id: Ice6887622d5fa2fa3198ce15146bff3cb05f7451
This was not efficient and leaded to an assert in obtainBuffer.
I'm not sure which condition can lead to a getNextBuffer of size 0,
but it has been observed and is not forbidden by getNextBuffer
documentation.
Test: atest android.media.cts.AudioPlaybackCaptureTest#testCaptureMediaUsage
Bug: 111453086
Change-Id: I5accf7c1d488ff4686272588329bab71d64f67cd
Signed-off-by: Kevin Rocard <krocard@google.com>
Otherwise incorrect state might be hidden.
Also: Unify devicesToString() and deviceToString() to toString().
Miscellaneous cleanup of replicated functionality.
Test: Basic audio sanity, AF and APM dumpsys check
Change-Id: Ic81167e2d2dbfcca881f0898764cf886215c217c
Implemented for threads that read/write PCM.
Test: audioflinger dumpsys Play Music, Movies, Video Recording
Bug: 114112762
Change-Id: I866a8b639d18426633088d6a03d9135f4ee09fd3
The implementation uses IBase::debug() method which can write
debugging info into the provided file descriptor (same model
as used for devices and streams).
Bug: 69939533
Test: adb shell dumpsys media.audio_flinger
Change-Id: I02a74b51977d105edf6f7e624ea26f866c965708
Use the constant from IExternalVibratorService.
Bug: 124318236
Test: play audio-haptic coupled file
Change-Id: Ice2ac13d0f6a6a749bb6243230524336144fa5f4
Track::interceptBuffer failed to write all the audio if the source BP
could not returned the requested buffer size.
This is actually normal when the source circular buffer wraps around.
Handle it by retrying if the first buffer is too small.
Test: adb shell audiorecorder --target /data/file.raw
Bug: 111453086
Change-Id: I42a7962449a0f075909a29f5f8f5ba82ca1d0085
It's possible that tracks with the same session id running on various
playback outputs, which causes effect chain being created on the same
session twice. As a result, the same effect engine will be released
twice as the same context is reused.
Output that has effect chain with same session id is more preferable.
Test: No regression with Play Music and Effects
Bug: 123082420
Change-Id: I690ea3cb942d1fdc96b46048e271557d48000f43
In order to avoid track to be added to tracksToRemove
redundantly, merge the adding operation under exclusive
condition check.
This can make sure the add can happen only one time within
one prepareTracks iterator.
authored-by: Zhou Song <zhous@codeaurora.org>
Test: AF active track removal with audio playback pause
Bug: 123375253
Change-Id: If35348af2144a28b84241e1cb93f497d5eec9a8a
If a track is paused right after start before it gets a chance to mix
the first frame. Don't apply volume ramp if it resumes later.
Test: Basic audio sanity. Partner CL.
Bug: 123063164
Change-Id: I969ff1b6edce8faf77f2cdc481db9c1e3ef6d3dd
The test case here involves two applications both of
which play the same music clip. When the 2nd application
ends playback, the 1st application must resume playback
where it left off. But it is possible that the new
AudioTrack.start() command from the 1st application is processed
after the 2nd application has paused and terminated.
This will prevent a flush to clear any state before playback
of the 1st application can resume. Direct thread thus
stays in pause state indefintely.
Issue unconditional flush for direct thread when a new
track is added to a direct output.
Test: partner CL submit, check compilation
Bug: 123082418
Change-Id: I33d36db35358a1b3b89dd5b2b8cb4db1f9c6d4a0
* changes:
Propagate track status to interception patch track
Add secondary output to audio tracks
Audioflinger: add timeout to PatchTrack
Audiopolicy: Move AudioPolicyMixCollection in helper function
Add MIX_ROUTE_FLAG_LOOP_BACK_RENDER
Clean up logic for FastTrack AudioMixer track initialization.
Test: SoundBar menu scrolling, AudioFlinger tee
Bug: 119284313
Change-Id: I551d9d54d82e0029a49c6481ba8669093359d6d1
The secondary are returned from mixes (from DAP loopback&render),
from getOutputForAttr.
All getOutputForAttr* of the stack are update.
Internal getOutputForAttr use descriptor, external one use handles.
The secondary output are saved in each track and the track is
invalidated if the list of secondary output changes.
In audio flinger, create a pair of recordTrack & patchTrack to pipe
the intercepted audio audio to the secondary output.
Test: adb shell audiorecorder --target /data/file.raw
Bug: 111453086
Change-Id: Id6523d9e383c15a0e39313d5f355df809b7e72fe
Add support for timeout that was only supported by PatchRecord.
This is implemented by moving the timeout and common code in a base
class.
Also remove PatchRecord useless virtual inheritance of RecordTrack.
Test: adb shell audiorecorder --target /data/file.raw
Bug: 111453086
Change-Id: I833148f31a311ca41092be1d7e2d170f086322c5
Signed-off-by: Kevin Rocard <krocard@google.com>
Overflow is expected when 32-bit counter wraps after several hours.
So prevent sanitization from causing a crash.
Bug: 122986677
Test: run a stream for more than 12 hours so the position overflows
Change-Id: I0f397f193288c2493a2036f67849bb12a9c9f221
The haptic playback should be controlled by vibrator service. Via the
interface, audio server could notify vibrator service about starting or
stopping haptic playback and get vibrator intensity from vibrator
service. Vibrator service could call mute/unmute to control the haptic
playback.
Test: Manually
Change-Id: Iad24813977e4dea0d67a91f8f8b390a016ce4ca2
Use the same logic in VibrationEffect.scale to control the intensity of
haptic playback in audio framework. Note that as the maximum amplitude
of vibrator is 255, convert the haptic data to pcm_8_bit before doing
scaling.
Test: Manually
Change-Id: I6136d27c9255a215834b6e3092aa8ad696fbae04
Test: Change Balance through Settings, play audio
Bug: 28390736
Co-author: Ed Savage-Jones <edward.savage-jones@sony.com>
Change-Id: I0169b436ccbaa5628584d9f4954dd7c76d021aae
Add new effect flag to monitor requested volume from
audio framework.
Pass requested volume directly if effect is volume monitor,
and others still follow an original rule by volume controller.
Bug: 123251705
Test: On/off equalizer on spotify/google music.
Switch songs with equalizer
Attach an effect with EFFECT_FLAG_INSERT_ANY,
EFFECT_FLAG_INSERT_FIRST,
EFFECT_FLAG_INSERT_LAST
and check received volume.
Change-Id: I01632bebb32aa6f921c964536039d43859ae3632
Signed-off-by: Jasmine Cha <chajasmine@google.com>
This commit adds the following audio capture sources:
- AUDIO_SOURCE_VOICE_PERFORMANCE: for real time live performances like Karaoke.
- AUDIO_SOURCE_ECHO_REFERENCE: for capturing the reference signal to suppress by an echo
canceller. Protected by privileged permission CAPTURE_AUDIO_OUTPUT.
Also added device AUDIO_DEVICE_IN_ECHO_REFERENCE selected when the requested
capture source is AUDIO_SOURCE_ECHO_REFERENCE.
Bug: 118203066
Test: CTS tests for audio capture
Change-Id: Ieb159ea82a7b81acf762506a44e24ec80111609f
In PatchPanel::createAudioPatch() verify that when creating a patch with
an output or input mixer as source or sink, no patch with the
same output or input mixer remains in the patch list.
This will prevent a call to releaseAudioPatch(() received
later with a stale patch handle due to delayed request to clear current
output or input routing.
Test: play music and insert USB headset.
Change-Id: I9417bf061f5ef1d93cf3871a9ed51ee2b6ae62ef
When opening an input stream for a software patch, pass in
the downstream destination device info. This helps the intermediate
module to set up any device-specific processing.
Note that the intermediate module must implement Audio HAL V5.0
in order to be able to receive this information. It's not available
on the legacy audio HAL API either.
Bug: 120859615
Test: make
Change-Id: I542a47d2c299fe19f576d5f5c2b237cc00ae5b93
In case of creation of AudioPatch with the same device type but a different
device id (typically: a device has been connected / disconnection, so
removed and re-attached to its corresponding module, a new Id is assigned),
the cache configuration of the clients is not updated.
If the client calls getRoutedDevice, the id will not be up to date and even
may refer to unknown port id.
Test: as follows:
1 / Calls setDeviceConnectionState AUDIO_DEVICE_OUT_HDMI state=1 mame=y_dummy_hdmi @=my_dummy_hdmi
2 / Plays explicititely on this device (by getting the id
AudioSystem::listAudioPorts
2 / Calls setDeviceConnectionState AUDIO_DEVICE_OUT_HDMI state=0
3 / Calls setDeviceConnectionState AUDIO_DEVICE_OUT_HDMI state=1 mame=y_dummy_hdmi @=my_dummy_hdmi
Plays explicititely on this device (by getting the id
AudioSystem::listAudioPorts
4 / Calls AudioTrack->getRoutedDeviceId()
The id shall match the second one, NOT the first one
that does not exist any more
Change-Id: I608ed8d78907b5ea1c9b6ef13c6cbfe528d88f44
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
When trying to play with haptic channel mask, use adjust channels
buffer provider to make the haptic channel the same as the output one.
If haptic playback is supported, use adjust channel non destructive
buffer provider to output haptic data to the end of the sink buffer.
Otherwise, haptic data will be ignored.
Test: Manually
Bug: 111454766
Change-Id: Ic5f780de48c1e71de6ba5c4774d1ed2e9c8c51a0
When haptic playback is supported according to audio policy
configuration file, try to open the output stream with haptic channel
mask. When trying to creat a track with haptic channel mask, use haptic
output if it is available.
Bug: 111454766
Test: Manually test
Change-Id: Ia8c70dd7f602a134d0509630eb734b8c540dea7d
This reverts commit 4c1ef4b64d.
Reason for revert: b/120588242
Bug: 120588242
Change-Id: Iac41f371cb739c54d5ce519232688bebe2285c72
Test: Launch QSB and capture from mic icon
exitStandby() was crashing if headphones were
unplugged between the open and start of a MMAP stream.
Bug: 120564294
Test: see repro steps in bug
Change-Id: Ic42743682ffeb48f2869eaa90581b4e4f7fcb1ab
Implement concurrent capture in audio policy manager:
- Attach AudioRecord client to already opened input when possible
instead of systematically opening a new input for each client.
- Always allow inputs to start even in case of concurrency.
- Clients are selectively silenced based on their app state by audio
policy service.
- In case of concurrency on a given input stream, device and source is
chosen based app states and source priority.
Bug: 111438757
Test: Manual capture tests with solotester and Camera, Assistant and Duo
Test: CTS tests for AudioRecord
Change-Id: I302710ff545f67361d9aca89e81de40771ce7fb0
Return the port ID allocated by audio policy manager instead of the
internal track ID allocated by audio flinger when an AudioTrack or
AudioRecord is created.
This information is more useful for logs and allows to associate information coming
from audiopolicy manager with a specific client instance.
Bug: 111438757
Test: Manual playback and capture tests
Change-Id: Ib467d8fcc34d9a8aa7bcaac0770a741982b847c5
The Java AudioTrack interface has a setPresentation API. This
calls the setParameters API in IAudioTrack. However, this does
not eventuate into a call into the android.hardware.audio@4.0
IStreamOut selectPresentation API.
Add selectPresentation API to IAudioTrack and call down to the
android.hardware.audio@4.0 IStreamOut selectPresentation API.
Translate into calls to setParameters API for legacy HAL
interfaces.
Bug: 63901775
Test: compile
Change-Id: Id634a107f3f93ab18dc80d2bd0af67bda35e859f
Test: A/V sync of direct/offload DD+ non HW A/V sync playback thread
through MSD, and MSD -> Audio HAL patch in DD+ non HW A/V sync
mode.
Change-Id: I244e9fda9741fe9a9ea913f39901654ebefb973c
(cherry picked from commit 8729c2eb3eabda3f6b6985a113bd2022b5b379c9)
Increase allowed downstream latency to 5 seconds.
Sometimes software patch might cause >1 second of latency.
Bug: 63901775
Test: MSD prototype
Change-Id: Ie111fa8b87bc7694ef787c6c4b1deca81bda2abb
This case is generally not encountered; we are fixing this
to ensure correctness for future code.
Test: No regression with MP3 effects and solo tester
Bug:118775810
Change-Id: I016e23101d42ffeee1e66102b6f6276f17c47684
Ensure all channels are accumulated.
Test: Use 4ch USB device, play MP3 with effects, see bug
Bug: 115693755
Change-Id: Ic1eb04dcff34284b3fff67266874eca41a43e523
Handle spurious wakeups in stop.
Handle track invalidation.
Clarify state.
Note: start and stop should not be called simultaneously from different
binder threads.
Test: audio sanity
Bug: 117303225
Change-Id: I587d9cda7b0eac5215eb6a88f93ee08e396e3ef9
Avoids race condition where APM::stopOutput is called after
APM::releaseOutput.
Test: audio sanity
Bug: 112067674
Change-Id: I244267d4a157078961589649b1e184206ee23248
There is a suspicion that dumping HAL state for a recently closed
input stream can hang forever, blocking audioflinger and stucking
system boot.
In order to verify, we disable this dumping to see if it would
help with presubmit bots.
Bug: 116211629
Test: see steps in b/116211629#9
Change-Id: I189461187a2310c213278cc2b3af2469d1896965
The more recent work that this was supposed to become is reflected in
dumpsys media.log, so this commit removes some code clutter that is not
used anymore.
Other Changes:
- Use std::make_unique for creating unique_ptr objects
Test: build, dumpsys media.audio_flinger
Bug: 68148948
Change-Id: I4841e118c2cdee4ada4c6cdc0fff1ec2e12b38c4
Dummy NBLog::Writer in FastThread must not be stored by value
because it's a RefBase descendant. Storing it by value causes
a diagnostic output from ~RefBase because no strong
references to it ever exist. In future this will cause a crash.
Test: verify there are no "RefBase: Explicit destruction" messages
in logcat
Change-Id: I95716ec8e29fdd9485ef64a3334cef49bf29bc96
Other Changes:
- added thread_params_t type to NBLog
- rearranged ordering of macros in TypedLogger.h
Test: dumpsys media.log with --json, --pa, and --plots options
Bug: 68148948
Change-Id: If97714271a085a99bba0ab3ae0c268a9f407f053
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I8875bc7ed073aae84d5df97eb39c8c745ca627ef
NBLog.cpp was deleted and split up into Entry.cpp, Merger.cpp,
Reader.cpp, Timeline.cpp, and Writer.cpp. NBLog.h was split up into
Entry.h, Events.h, Merger.h, Reader.h, Timeline.h, and Writer.h. NBLog.h
now includes all of these new headers except Merger.h, which is managed
exclusively by MediaLogService.
Other changes:
- changed NBLog from a class to a namespace
- changed NBLog::thread_info_t.type to enum and replaced magic numbers
- fixed some fragile build dependencies in libaudioclient and medialog
No other changes were made, and all functionalities that existed prior
to this commit remain the same.
Test: build, dumpsys media.log
Bug: 68148948
Change-Id: I1ce6dcb7b30d004f90584edfad7103a89f7bab0c
* changes:
AudioRecord: Add client side track id for logging
AudioTrack: Add client side track id for logging
AudioFlinger: Use track ids in log messages
AudioFlinger: Replace track name with id
When the latency number is too high, it becomes ambiguous
whether it's in milli- or nano-seconds.
Test: dumpsys
Change-Id: I175a562f403dc4d67e50687927cd4edf9bc7d922
"Master mute" which can be toggled on via "ro.audio.silent" property
has user-hearable effect, but is not reflected in the dumpsys.
This can cause confusion (see the bug referenced).
Note that we need to dump PlaybackThread::mMasterMute, not
AudioFlinger::mMasterMute, as the latter does not get updated
by threads in order to avoid taking a lock.
Bug: 113348789
Test: toggle property, check media.audio_flinger dump
Change-Id: I7f276b233df2f5eca585ffb30031835c030858e1
No new functionality was added, and no existing functionality was
removed.
Event types have been renamed and reorganized according to
functionality. A compile-time mapping from Event to C++ data type allows
for a generic Event log() template function to avoid the need to add a
new logging function when a new Event is added to enum NBLog::Event.
Most LockedWriter functions were deleted because they did not involve
accessing shared variables. Only the functions that accessed shared
variables were kept in LockedWriter.
Test: dumpsys media.log -r
Bug: 68148948
Change-Id: I8a27f1690795cdb0b84e92033b7cbf4588ba175e
ReportPerformance::writeToFile and the recording of PerformanceAnalysis
FastMixer timestamps are disabled for now.
Test: dumpsys media.log -r
Bug: 68148948
Change-Id: I4ba55fc20521ad2278348e6a3f713f9db04d951b
Music volume is set to max for an instant
when enabling non-offloadable effect during compress offload playback.
Non-offloadable effect module having volume control is created
and linked to Offload thread.
After that, when enabling it during playback,
volume is set max to Offload thread to switch volume control module
before switching Playback thread from Offload to Mixer.
Then, until completing thread switch,
Offload Thread works with max volume.
To avoid this issue, check effect capability
so that only offloadable effect can set volume on Offload Thread.
Bug: 113311497
Test: Enable non-offloadble effect during offload playback
Change-Id: I91b7313d55ca7cfcde206f158ce553432499e992
Merging is temporarily disabled for now because the readers managed by
the merger are the same as the ones used for the dumpsys log dump, and
reading from the log effectively consumes the buffer. Eventually, the
readers for the two functionalities will need to be separated to avoid
conflict. The dump of the merged buffer is also disabled, which removes
the dumping of histograms.
The new types added are monotonic thread cycle time, CPU thread cycle
time, CPU frequency, and latency (which will need to be specified in
further detail later). Logging support is added only for monotonic
thread cycle time at the moment.
Test: build, log monotonic thread cycle time in FastThread, check output
in dumpsys media.log -r.
Change-Id: I1b781d6db102fb917fd0bac964eeebd0309234c0
Bug: 68148948
Should not configure effect by thread sample rate
if effect is not offloadable.
Because of offload output may be different from
the sample rate supported by sw effect.
Bug: 70912361
Test: Create AudioEffect during 24kHz mp3 playback
Change-Id: Ie5bf264a9790d936c24476ea127bc6da9eefde73
Even though effect module has "EFFECT_FLAG_VOLUME_CTRL" flag,
there is some case where volume setting is not sent to offload thread.
That leads to sudden increase of audio volume or too low volume.
This change is to support delegation of volume control completely
for offload audio effect.
Bug: 37443095
Test: Enable/Disable Audio effects during offload playback
Change-Id: I7033071edc99fadc519efd7adc895dc10f7b9d86
This relies on being able to obtain presentation position and
capture position accurately from the HAL, in the presence
of potential underruns or overruns.
Test: MSD hal dumpsys
Bug: 112428710
Change-Id: I9aad574baaff60b5e0c5d8c39a2147d19ee613f5
Test: Check AudioFlinger dumpsys during MSD direct record
Bug: 112388863
Change-Id: Id404c70af0c0e23a1e349522568b20f50573b1e9
(cherry picked from commit 2ceaf3dee96d1696b315afdee9ffc0df662f88d8)
Apps are not expected to send any setParameter, system should only send
very few keys. This log can help verify what is bypassing audioflinger
control.
Only the first 1024 characters are logged per SimpleLog limitation
to avoid high memory retention in the privilege audio service
in case very big strings are sent.
Thus in the worst case around 60*1*3=180kB can be consumed in Audioflinger
by those logs (aka: no app memory deny of service).
Test: adb shell dumpsys media.audio_flinger
Change-Id: Ida9c21be9d20528f67a63eddf6ca7a6c962c7cc2
Signed-off-by: Kevin Rocard <krocard@google.com>
Allows getting effect descriptors by type or uuid,
not just by uuid.
Bug: 78528249
Test: Builds. Manually tested that an app playing audio with an effect works.
Change-Id: I9d339a7d6d81161065e1adaf427dd2d3430436c2
Use fast mode with patch track/patch record if fast mixer/fast capture
is enabled. With the fast track and fast mixer/fast capture, we can get
a better performance on latency.
Bug: 111800664
Test: make phone call on marlin/walleye with enabling legacy usb hal
Change-Id: I0edd5978049e7c55da217a7a19e45fcbe5c3ac62
Revert CPU_FREQUENCY_STATISTICS macro in Configuration.h.
Test: build with different #define, dumpsys media.audio_flinger
Change-Id: I91680c462b069779d8db3b7a10603fb11a81a135
After separating the constants for MSD service and module names,
use the module name when working with modules.
Bug: 63901775
Test: make
Change-Id: Icf80d28903e5c36051e33c4be818fd3d7256ce91
This logic got broken in ag/668511. The stream type was always
extracted from the 2nd patch source, which does not present
for device->device patches.
Test: MSD prototype, USB headset telecom calls in Pixel
Change-Id: Idc8314819010c3a315c5220785a4190e26e55b47
When passing parameters to immediate output streams also check
if there are any downstream patch threads that need to receive
these parameters.
Added AudioFlinger::forwardParametersToDownstreamPatches_l
method, similar to existing broacastParametersToRecordThreads_l.
Bug: 63901775
Test: make
Change-Id: I83229fd6f4890e5e69a40d568d1c3e1eebed6504
Refactor audio policy service APIs controlling audio playback (startOutput, stopOutput, releaseOutput)
To allow finer grain control per AudioTrack client.
Test: AudioTrack CTS test. manual test of playback use cases.
Change-Id: I49a681f3c2a8211e524824993049b24d8086376d
Change the fatal condition in AudioFlinger::RecordThread to info.
Require AUDIO_INPUT_FLAG_DIRECT when creating tracks on such streams
from the client side. Note that PatchPanel uses PatchRecord constructor
directly.
Bug: 63901775
Test: on MSD prototype
Change-Id: Ic94e51e6b8a089f3100131851db8c3ce0994b4ac
If the patch sink configuration specifies sampling rate, format,
and channel mask, use them when opening the output side of
a software patch.
Bug: 63901775
Test: MSD prototype; Telecom calls via USB headset on Pixel.
Change-Id: I705d46524cfcc59c88c57b18a45bee0c6b922b62
When the system inserts an intermediate processing module between
audio flinger and hardware HAL, and they are connected via a
software patch, the threads of this patch need to receive
metadata passed to the thread serving the "upstream" device of
the processing module.
PatchPanel stores an association between "upstream" streams
and the software patch. This allows audio flinger to access
the patch threads.
For more info, see the comments in PatchPanel.h
Bug: 63901775
Test: manual
Change-Id: I60e578c37a1bc7385daf32d379ea143120584a31
Use `audio_patch_is_valid` function.
Add basic tests for the following functions:
audio_patch_is_valid
audio_port_config_has_hw_av_sync
audio_patches_are_equal
Bug: 63901775
Test: systemaudio_tests
Change-Id: I378ab544e4148fda0dd7b9520d6fd57ff01cb34b
When piping encoded audio data via software patch, it needs
to be created without the buffer converter. In this case the audio
data is copied directly from ResamplerBufferProvider.
Added input flag AUDIO_INPUT_FLAG_DIRECT to indicate to PatchPanel
that the PatchRecord track needs to be opened in this mode.
This flag can be later added to minor Audio HAL update.
Bug: 63901775
Test: MSD scenario; verified that phone over USB headset still works
on marlin / sailfish
Change-Id: If2745778d356769b143fb3c29910275ddef119ac
When creating a software patch for transporting encoded
audio (AC3), the old heap size was not sufficient.
Bug: 63901775
Test: check for "not enough memory for pipe buffer" log message
while creating a patch for transporting AC3
Change-Id: Idb0b2604f35f00e65e28bf8c066f6d861b2dd3c9
Add a verification on actual size of the fd backing up the IMemory
recevied for sound model or recognition config.
Fix similar problem for AudioTrack shared buffer.
Bug: 78596657
Test: run POC. OK Google regression.
Change-Id: I7cb02785f8ba46c437c7fcaa5b821f4b7e3240a0
Use server timestamp if track has no actively presented frames
(i.e. drained). Sometimes track frames may not have reached the HAL.
Test: audioflinger dumpsys with BT audio
Bug: 80447764
Change-Id: Iffc52f4cfcbadd419c6b6ccfa278e0712f3af4af
- When filling out audio_port_config from AudioPortConfig and
AudioFlinger's threads, populate audio_port_config.flags when needed.
- When creating software patches, apply the flags provided
in audio_port_config_flags to the created threads.
Bug: 63901775
Test: use USB headset for telephony on sailfish
Change-Id: I7704797a84427f7a9431e5132b8f5c51538f9217
Replaces main and aux buf from track dump.
Bug: 80272001
Test: adb shell dumpsys media.audio_flinger
Change-Id: I5d6565410e652ec7fc6701b171d299dea9f7bc3e
1) Fix bad WAV files for tee sources that aren't 16 bit PCM.
2) Allow multiple RecordThread tees instead of one.
3) Allow dump from non-fast MixerThreads (e.g. deep buffer).
4) Parallelize tee dumping for improved concurrency;
dump outside of AF lock.
5) Async dumping to allow dump to be issued in time critical code.
6) Improve file naming to distinguish record vs playback tracks,
threads, and dump reason.
7) Allow Tee insertion anywhere in code with global running
Tee management.
8) Increase resolution of filename time to msec avoid file overwrite.
9) Dump track data upon removal from active tracks to improve
timeliness of dumped data.
10) Dump tee data on tee destruction.
11) Refactor Tee code out of AudioFlinger.cpp; minimize footprint.
AudioFlinger enabling code requires Configuration.h define TEE_SINK;
this is disabled, hence avoiding regression risk.
Test: Enable tee log, repeatedly call dumpsys, examine files.
Bug: 78369241
Change-Id: I7b22cfa7dbbc1601828de931522065a509ab4047
Change captureAudioOutputAllowed to check client pid.
Check calling uid with AID_AUDIOSERVER instead of calling pid with
own pid. This is consistent, and works if AudioFlinger and
AudioPolicyManager exist as different processes.
Remove getpid_cached since getpid() is very fast. This removes
any initialization issues.
Replace getuid() with AID_AUDIOSERVER to remove ambiguity of
multiple native audio services for multiple users. Only
one exists regardless of users.
Do not use multiuser UID checks for certain native services
that do not spawn for multiple users to prevent accidently exposure.
Move permission checks to use ServiceUtilities for control and
consistency.
Rename isTrustedCallingUid to isAudioServerOrMediaServerUid
so that permission check is explicitly known to caller.
Update MediaLogService to use ServiceUtilities.
Test: Basic sanity
Test: AudioTrackTest, AudioRecordTest, SoundPool, SoundTrigger
Bug: 79485140
Change-Id: Ib8ccb36929a9b4806c01626f32fa023a046d6020
Example output:
Software patches:
Patch 44: thread 0xa6d83900 => thread 0xa7dfe000
This helps to identify threads used for the patch.
Test: adb shell dumpsys media.audio_flinger
Change-Id: I6c70945abd8e4abd46cd0311559d35efb6127555
This piece of logic does not seem to be correct:
(patch->sinks[i].type == AUDIO_PORT_TYPE_MIX ||
patch->sinks[i].ext.mix.hw_module != srcModule)
I assume it should be:
(patch->sinks[i].type == AUDIO_PORT_TYPE_MIX ||
(patch->sinks[i].type == AUDIO_PORT_TYPE_DEVICE &&
patch->sinks[i].ext.device.hw_module != srcModule)
Was working fine because 'hw_module' is the first field both
in audio_port_config_device_ext and audio_port_config_mix_ext.
Test: make
Change-Id: Icf80cec701048bddc4d63eaedf00fc75b5b891dd
Provide PatchBuilder helper class instead of fiddling with
struct audio_patch directly.
Rename 'getAudioPortConfig' methods of AudioFlinger helper
classes into 'toAudioPortConfig' to match classes
of AudioPolicyManager.
Factor out common code in AudioPolicyManager that was
adding audio patches. For that, AudioOutputDescriptor now inherits
from AudioSessionInfoProvider, and the latter has been extended
with 'setPatchHandle' method.
Test: switch to/from Bluetooth on phone calls and media playback,
use camcorder
Change-Id: Idd99645dc6943ed078c4d94d0197fead7831ab4d
selectedDeviceId is not cleaned when retrying open input.
and will add this selectedDeviceId into input routing.
Which will cause getDeviceForInputSource() not doing
mEngine->getDeviceForInputSource() but only return
route->mDeviceDescriptor->type() and failed to route to
the correct device.
Test: self-test routing is corrected.
Bug:79332409
Test: routing is corrected.
Change-Id: Ia85c773f3549befb929178469116dc2d4e4945ad
Missing header file hidden by compile flag.
Test: Compilation is fixed when flag enabled
Bug: 78310170
Change-Id: Ie938193c5d87de04f22318a8fb4fffb4a4412a53
channelMaskToString in Threads.cpp was missing some of newly
added discrete channels.
Test: adb shell dumpsys media.audio_flinger
Change-Id: I09c60b0cbbf3e10bcac6bc30e47f5009e50ccc93
When a new patch is being added to mPatches in this line:
mPatches.insert(std::make_pair(*handle, std::move(newPatch)));
the source of the move--`newPatch` remains intact, and if it
is a software patch, it has playback and record patch handles
remaining to be non-NONE values. Thus, on destruction it falsely
warns that it hasn't been cleared.
The solution is to define a move constructor for Endpoint which
"transfers" patch handle ownership.
Also delete copy constructors to make sure that each Patch is
a unique resource.
Test: create a software patch, watch logcat
Change-Id: I41ea2dff087696252132e79d827e705378baaf8f
Restore buffer mFrameCount as error clears it.
Test: phone call with usb device, simulate underrun.
Bug: 79423841
Change-Id: Ia00d08b6753b5c65cf7f07bf1c889fd6d1eefd0a