Force DIRECT flag if current playback thread is direct output thread.
This can happen when the playback is re-routed to direct output stream
by dynamic audio policy.
Bug: 130296239
Test: manual
Change-Id: I24efd87f74bacf6b769d3663e9521eb27b1704e9
Compute summary statistics based on the current device
rather than the entire Audio Thread duration.
Test: adb shell dumpsys media.metrics
Bug: 149850236
Change-Id: Ie6d459b06b4a469401ee9e0c194e45ea5ce380c6
Compute summary statistics based on the current device
rather than the entire AudioTrack or AudioRecord duration.
Test: adb shell dumpsys media.metrics
Bug: 149850236
Change-Id: Ia3a5707c43c4530f5a6ac90f52901bd2e0bd0bab
After refactoring audio device type, the output devices will only be set
when create/release audio patch. In that case, the output devices are
empty when creating the thread. If the "ro.audio.silent" is set, it will
make master muted if the output devices are empty. To fix the issue, do
not check silent mode when the output devices are empty, but check
silent mode when output devices are updated.
Test: atest AudioHostTest with setting "ro.audio.silent"
Bug: 154037767
Change-Id: I6cb219353e541ba99ba9acebd6ce853128d963d3
In aaudio, when adding tracks to mixed stream, it is needed to update
audio attributes to HAL whenever the tracks are added or removed.
Currently, only the audio attributes used to open the stream will be
sent to the HAL. In that case, adding audio attributes of the clients
when starting the stream can help solve the problem. In audio flinger,
the client's audio attributes will be used to create MmapTrack.
Test: play multiple aaudio tracks, add log
Bug: 77279923
Change-Id: Ic1c536049e194a2bb7513425ee4828d52769d27f
Add an argument to IAudioFlinger::createEffect() API to
ask AudioFlinger to just run the pre flight checks but not
create the actual audio effect instance and allocate resources.
This is the basis of an API for apps to query if a given
effect can be created without having to allocate the resources
and risk an exception when calling the constructor.
Bug: 150699608
Test: CTS and GTS Tests for audio effects
Change-Id: Ibdda22fd945c88c33e3c7342a7a5ed3e02d399ac
When creating native audio track, a IAudioTrackCallback will be created
systematically. All callbacks will be cached in Threads and protected by
a lock. Whenever there is a callback event from audio HAL, it will
finally trigger callback to native audio track. Currently, there is only
one callback event, which is codec format change.
Bug: 150301890
Test: manual
Change-Id: I32293627ed923b17dd25f11f0ee0a0c35cd7c01f
The access to call audio (record and play) will be granted only to the app associated with Dialer role, who also includes a new system permission.
Test: Compilation and manual tests
Bug: 135197853
Change-Id: I65ca823c235d4d3420630837427103783ad1d1b0
This code has null checks with intervening unconditional dereferences of
the potentially-null variable.
It's not clear that `mOutput` can ever be null to begin with. If it can
be, we have a few dereferences to guard. :)
Caught by the static analyzer:
frameworks/av/services/audioflinger/Threads.cpp:2671:19: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]
frameworks/av/services/audioflinger/Threads.cpp:2852:9: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]
Bug: None
Test: TreeHugger
Change-Id: I456581204718390088998a1fe2514dff63f6578f
Routing strategy call assistant was added without
associated volume stream and wass reusing AUDIO_STREAM_PATCH.
This is violating the rule that two strategies cannot
share the same volume stream.
Bug:148588565
Test: play music and check volume
Change-Id: Ib3fb2a1b7b5f3118bf16a3cc9d8e578fa0431645
In order to avoid subsequent tracks using stale kernel timestamps while
computing track timestamps, clear the timestamp info upon flush.
Change-Id: I2b8af33b287aee986871b6415b89f9c53d92f3a6
Add management of audio effects applied to a specific input
or output audio device.
A new class DeviceEffectProxy derived from Effectbase is added
to represent an effect attached to a particular audio device type and
address. This proxy manages one or more actual EffectModule instances
automatically added to a playback or capture thread or directly to the
audio HAL when the targeted audio device is used by an audio patch.
A new DeviceEffectManager class is added to manage creation and release
of DeviceEffectProxy instances and monitor creation and release of audio
patches and create or release actual effect instances accordingly.
Bug: 136294538
Test: make
Change-Id: I23b9f9db4459136039c5ee327cf3b1aefa7db5af
Merged-In: I23b9f9db4459136039c5ee327cf3b1aefa7db5af
Introduce a class EffecBase as a parent class of
EffectModule with default implementation for handles management,
basic properties storage and state management.
Bug: 146177259
Test: CTS: AudioEffectTest, EqualizerTest, VisualizerTest,
AudioPreProcessingTest
Test: manual test: Play Music EQ settings, Duo EAC and NS
Change-Id: Id91cef9db6b4f6be0d2e77a8b4afcbdc7234e519
Merged-In: Id91cef9db6b4f6be0d2e77a8b4afcbdc7234e519
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
Merged-In: I4e3a55ed1244b918429dd9e217b6efecc1ec6449
Add management of audio effects applied to a specific input
or output audio device.
A new class DeviceEffectProxy derived from Effectbase is added
to represent an effect attached to a particular audio device type and
address. This proxy manages one or more actual EffectModule instances
automatically added to a playback or capture thread or directly to the
audio HAL when the targeted audio device is used by an audio patch.
A new DeviceEffectManager class is added to manage creation and release
of DeviceEffectProxy instances and monitor creation and release of audio
patches and create or release actual effect instances accordingly.
Bug: 136294538
Test: make
Change-Id: I23b9f9db4459136039c5ee327cf3b1aefa7db5af
Introduce a class EffecBase as a parent class of
EffectModule with default implementation for handles management,
basic properties storage and state management.
Bug: 146177259
Test: CTS: AudioEffectTest, EqualizerTest, VisualizerTest,
AudioPreProcessingTest
Test: manual test: Play Music EQ settings, Duo EAC and NS
Change-Id: Id91cef9db6b4f6be0d2e77a8b4afcbdc7234e519
This reverts commit c0abc6239e.
Reason for revert: broken build on target cf_x86_phone-userdebug_coverage
Change-Id: Ic6808bfd31bedfa85b7d7a120e4c6f6273678f73
This is in preparation of the addition of audio effects attached to a
specific audio device that will not be attached to a particular
ThreadBase or Effectchain.
Create an clean callback interface used by the EffectModule to interact
with the rest of the audio framework. This callback must be implemented
by the EffectModule parent (e.g an EfffectChain).
Als refactor EffectHandle enabled(), disable() and disconnect methods()
to avoid dealing with the ThreadBase directly.
Bug: 136294538
Test: make
Change-Id: I9160f88f7fbb0447b5e679260bf0401d3af591d2
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
Separate SET_DEVICE and SET_INPUT_DEVICE command in effects as it can
be multiple devices for output case, but only single device for input
case.
Use AudioDeviceTypeAddr instead of just audio device type as address
can be useful to identify audio device if there are multiple devices
with the same device type connected.
Bug: 135621476
Test: atest AudioEffectTest BassBoostTest DynamicsProcessingTest
Test: atest EqualizerTest VirtualizerTest VisualizerTest
Change-Id: Ie9df88e3338730392abbc3efae5daadc70398ff7
Merged-In: Ie9df88e3338730392abbc3efae5daadc70398ff7
As audio device type must not be used as a bit mask, there is a
requirement to refactor the code in audio flinger. This CL includes:
1. Use DeviceTypeSet for recording output devices in Threads. The input
and output device types in Threads will only be updated when creating
an audio patch.
2. Use helper functions in audio flinger for checking whether an audio
device type is a certain category.
3. Use DeviceDescriptorBaseVector as vector of DeviceDescriptorBase.
DeviceDescriptorBaseVector will be used in RecordThread to record output
devices, which will be used in audio effect.
4. Do not use set parameters when communicating output devices to
RecordThread. Instead, adding a new event in Thread to update output
devices directly.
Bug: 135621476
Test: atest AudioTrackTest AudioRecordTest AudioPlaybackCaptureTest
Test: atest AudioHostTest AudioServiceHostTest RoutingTest
Test: atest AudioEffectTest BassBoostTest DynamicsProcessingTest
Test: atest AAudioTests
Test: audio smoke test, run OboeTester
Change-Id: I87f3e59fd01b0b100232d61a9abbc471c61110c4
Merged-In: I87f3e59fd01b0b100232d61a9abbc471c61110c4
Also add track state name helper function for logging.
Test: Play video clip then pause and resume several times
Bug: 145613591
Change-Id: If4fc2565da9b3d4964fb9fdb6f5854ff6fbadfb8
Sometimes after switching songs in Files, audio driver
enters "PAUSED" state, and no sound anymore.
In normal case, "paused" track will be removed from active tracks,
then audio hal will make this stream enter standby mode.
Actually there are two paths to move paused tracks into standby mode:
1> track underruns twice:
if (--(track->mRetryCount) <= 0) { // mRetryCount is 2
tracksToRemove->add(track);
} else {
doHwPause = true; // pause
}
Unfortunately, this issue happened exactly in the middle state:
track underrun for the first time, it enters to paused state;
then before it underrun for second time, it is stopped due to MediaPlayer.
2> track is paused and code goes here:
if (mStandby || !last ||
track->presentationComplete(framesWritten, audioHALFrames) ||
track->isPaused() ||
+ track->isStopped()) {
tracksToRemove->add(track);
}
But when the issue happens, track is in stopped state,
there is no logic to standby it anymore, so add one.
Change-Id: I70cac1f3d6b065690400f6a2363712d4642a9763
Separate SET_DEVICE and SET_INPUT_DEVICE command in effects as it can
be multiple devices for output case, but only single device for input
case.
Use AudioDeviceTypeAddr instead of just audio device type as address
can be useful to identify audio device if there are multiple devices
with the same device type connected.
Bug: 135621476
Test: atest AudioEffectTest BassBoostTest DynamicsProcessingTest
Test: atest EqualizerTest VirtualizerTest VisualizerTest
Change-Id: Ie9df88e3338730392abbc3efae5daadc70398ff7
As audio device type must not be used as a bit mask, there is a
requirement to refactor the code in audio flinger. This CL includes:
1. Use DeviceTypeSet for recording output devices in Threads. The input
and output device types in Threads will only be updated when creating
an audio patch.
2. Use helper functions in audio flinger for checking whether an audio
device type is a certain category.
3. Use DeviceDescriptorBaseVector as vector of DeviceDescriptorBase.
DeviceDescriptorBaseVector will be used in RecordThread to record output
devices, which will be used in audio effect.
4. Do not use set parameters when communicating output devices to
RecordThread. Instead, adding a new event in Thread to update output
devices directly.
Bug: 135621476
Test: atest AudioTrackTest AudioRecordTest AudioPlaybackCaptureTest
Test: atest AudioHostTest AudioServiceHostTest RoutingTest
Test: atest AudioEffectTest BassBoostTest DynamicsProcessingTest
Test: atest AAudioTests
Test: audio smoke test, run OboeTester
Change-Id: I87f3e59fd01b0b100232d61a9abbc471c61110c4
Fix issue where RecordTrack silencing didn't silence the
full buffer: the memset to 0 was using the RecordThread frame
size, not the RecordTrack frame size.
OP_RECORD_AUDIO was only enforced at the start of a recording
which would fail if not granted. This patch silences the recording
(i.e. silence is recorded instead) when it is lost, and undoes that
when granted again. This requires:
- propagating the package name of the client to the RecordTrack class
- registering an appOp callback in RecordTrack (through a new
OpRecordAudioMonitor class) to (un)silence the recording
- update the isSilenced() method to take into account the appOp.
Bug: 138968594
Bug: 138636979
Test: run app that records audio, then "adb shell appops __pack_name__ 27 2"
and verify recording is silent after that.
Change-Id: Ib33f5b592185a67204997213bab1ac2594d90d37
(cherry picked from commit ddf87effa4)
Merged-In: Ib33f5b592185a67204997213bab1ac2594d90d37
(cherry picked from commit 7307293e8b)
Add missing calls to ATRACE for direct writes and frames ready
on direct thread.
Test: <start direct output>
external/chromium-trace/systrace.py audio
Merged-In: Iee6ea72442f9902819628735e19cce0ba1546165
Change-Id: Iee6ea72442f9902819628735e19cce0ba1546165
This allows to replace direct reading from HAL with obtaining
audio data from another source.
It should be possible to encapsulate reading from FastCapture
in the same manner, but it's not required for direct inputs.
Test: make
Merged-In: I3f005583410cc9c5d4b07c127d95e236abb4a85f
Change-Id: I3f005583410cc9c5d4b07c127d95e236abb4a85f
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
This allows to replace direct reading from HAL with obtaining
audio data from another source.
It should be possible to encapsulate reading from FastCapture
in the same manner, but it's not required for direct inputs.
Test: make
Change-Id: I3f005583410cc9c5d4b07c127d95e236abb4a85f
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