History log of /frameworks/av/services/audioflinger/Threads.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
13084621072ea2e4c34e2a9d79793c621d9bf005 17-May-2016 Eric Laurent <elaurent@google.com> audioflinger: fix invalidateTracks() on offload thread

Commit 05317d29 introduced a regression causing a systematic flush
on offload output thread when invalidateTracks() is called even if
no track is using the stream type specified.

Bug: 28786996
Change-Id: Iee393ee8b1093c40647235bd35f4a6fa9b62937a
/frameworks/av/services/audioflinger/Threads.h
e93cc03da360a1a0d2ad937c745ce8c8e8be81c2 05-May-2016 Eric Laurent <elaurent@google.com> audioflinger: various offload playback fixes

Revert underrun sleep time optimization added for
offload by commit 51716185 which can cause music to pause for a few
seconds in some corner cases.

Allow underruns in STOPPING_1 state to avoid dropping last buffer
received by the AudioTrack callback after stop() is called by the
client.

Allow interruption of thread loop sleep if a command is pending to
speed up track start sequence.

Do not wait for a full AudioTrack buffer before writing to audio HAL
when resuming playback or transitioning to next track.

Also moved log level for underruns in AudioSink from I to D to reduce
spam on user builds.

Bug: 28545177
Bug: 27682362
Bug: 28347796

Change-Id: I05b651b7878a2d2eedcac43cd669e32add171d40
/frameworks/av/services/audioflinger/Threads.h
05317d29b27e5fda654bea21b80d4423a03f49b3 04-May-2016 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: set flush pending on invalidating offload track

On invalidating an offload track, the IAudioTrack instance is
destroyed and the offload output is released. If it so happens
that APM::getOutputForAttr for the new IAudioTrack is called before
OffloadThread::prepareTracks_l checks and removes an invalid track,
the same output can get reused.

The side effect of this is data present in HAL and below from before the
invalidate will be rendered before data from the new seek position
is rendered. This is unexpected.

To fix this, set hint to issue flush when an offload track is invalidated.

Bug: 28566885
Change-Id: Ib6c38a3abb600598b87591bac90d03b7150d5216
/frameworks/av/services/audioflinger/Threads.h
dc2c50bad491d2c0c8a2efc0e24491076701c63c 21-Apr-2016 Glenn Kasten <gkasten@google.com> Make max fast tracks configurable using a property

ro.audio.max_fast_tracks

Rename the currently configured maximum number of fast tracks
from FastMixerState::kMaxFastTracks to FastMixerState::sMaxFastTracks.

There is no guarantee that the CPU will be able to handle
the configured number of fast tracks.

Bug: 27564141
Change-Id: If9af226d839b226503488c3cb20a4bb8950b429d
/frameworks/av/services/audioflinger/Threads.h
4a8308b11b92e608cdaf29f73f7919e75706f9a2 18-Apr-2016 Glenn Kasten <gkasten@google.com> Add AudioSystem::getFrameCountHAL()

And add comments about declaring methods in binder opcode order.

Bug: 28117362
Change-Id: I3c4426fa4bb3ce9c4a207a44d3bb1103d7fef160
/frameworks/av/services/audioflinger/Threads.h
646679779a8f952980a5d4219ad9c6f93efc4b92 31-Mar-2016 Eric Laurent <elaurent@google.com> audioflinger: keep wakelock during offload playback

Add a system property ro.audio.offload_wakelock to select
if a wakelock should be kept during offload playback while waiting for
write completion callback.
The default is yes, keep the wakelock.

On some platforms, the cost of entering or exiting suspend is so high
that is it better to not release a wakelock at all rather than releasing
it periodically.

Bug: 26208297
Change-Id: Ib41c7e4ed9c8c0c063363eb9fe99a2ecc81b521b
/frameworks/av/services/audioflinger/Threads.h
d848eb48c121c119e8ba7583efc75415fe102570 08-Mar-2016 Glenn Kasten <gkasten@google.com> Use audio_session_t consistently

Bug: 27562099
Change-Id: I328d8226191386b163f2ace41233607294c50dcd
/frameworks/av/services/audioflinger/Threads.h
517161856d74f5fe39cce131f29b977bc1745991 01-Mar-2016 Eric Laurent <elaurent@google.com> audio flinger: fix offload track underrun

Fix offload track underrun detection causing early disabling
of offloaded audio tracks.

Optimize sleep time in case of underrun to avoid spinning while
waiting for new data.

Re-enable offload when streaming

Bug: 26668110

Change-Id: I874728c69647ac05e1effb84c48700a6d0ac7435
/frameworks/av/services/audioflinger/Threads.h
c54b1ffc92b8ad27608a8af21033d7cab33cb3a0 23-Feb-2016 Andy Hung <hunga@google.com> Fix AudioTrack presentationComplete regression

Bug: 27310929
Change-Id: Id52299660d90b07220a4fd9996da53fe755a41f1
/frameworks/av/services/audioflinger/Threads.h
818e7a32ce3633980138aff2c2bfcc5158b3cfcc 17-Feb-2016 Andy Hung <hunga@google.com> Implement server side playback timestamps with 64 bit accuracy

Provide server timestamps if the HAL doesn't provide it.
Provide monotonic - boottime translation.
Integrate record timestamps and playback timestamps together.

Bug: 17472992
Bug: 22871200
Bug: 26400089
Bug: 26682703
Change-Id: If1974f94232fcce7ba0bbcdf63d9e54ed51918ff
/frameworks/av/services/audioflinger/Threads.h
e10393e72454bfd8298017dc193faf424f4e9a8f 12-Jun-2015 Andy Hung <hunga@google.com> Fix audio timestamp computation for pause, stop, and dynamic speed changes

Timestamp on pause and underrun (stop) do not reflect actual position.
Timestamps do not account for dynamic changes to track speed / sample rate.

Bug: 11085154
Bug: 17552775
Change-Id: I0e5e40ab3eaee82f0c91b9f399089698a0b1947e
/frameworks/av/services/audioflinger/Threads.h
3f0c902beb53a245c9db35e871607dba05b8d391 16-Jan-2016 Andy Hung <hunga@google.com> Add AudioRecord timestamps

Bug: 13569372
Bug: 22886739
Change-Id: Ibc81afefb733d23676a632a0f2da31163fdbe05f
/frameworks/av/services/audioflinger/Threads.h
03c48d5afcb3dfc1e43df93e1f3b3b3e9292e148 28-Jan-2016 Glenn Kasten <gkasten@google.com> Add limiter for mono blend

Bug: 26904791
Change-Id: I76b16e70871cd9fc0a9b8badc66f27069fabe1cb
/frameworks/av/services/audioflinger/Threads.h
d79072e9dff59f767cce2cda1caab80ce5a0815b 06-Jan-2016 Glenn Kasten <gkasten@google.com> Remove TimedAudioTrack and associated code

Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
/frameworks/av/services/audioflinger/Threads.h
2ddee19245641e86bca436dda23a0f5089bf2ab5 19-Dec-2015 Andy Hung <hunga@google.com> Add setMasterMono and getMasterMono

Bug: 15283594
Bug: 22700363
Change-Id: I32dc1fcecf285967a61bd508af3bb299595db57d
/frameworks/av/services/audioflinger/Threads.h
3f273d10817ddb2f792ae043de692efcdf1988ae 24-Nov-2015 Wei Jia <wjia@google.com> Uses AudioFlinger to signal battery stats for audio.

Bug: 18177221
Change-Id: I704010c037cb99bb74b98798ee8e494fa8bdc875
/frameworks/av/services/audioflinger/Threads.h
7c1ec5f038e63a5eb8b04434577c25bc23f5f410 09-Jul-2015 Eric Laurent <elaurent@google.com> audio: several fixes in audio routing callbacks

- audio policy:
Force device change to ensure new audio patch creation
upon first track activity on a given output.
Fix function device_distinguishes_on_address() which could mistake
some output device with remote submix input device.

- audio flinger:
Reduce number of binder calls upon new client registration by only
sending ioConfigChanged() callbacks to newly registered client.
Fix first patch after output thread creation not triggering an
ioConfigChanged() callback.

-audio system:
Force client registration upon routing callback installation to force
new ioConfigChanged() callback from audio flinger.

Bug: 22381136.

Change-Id: Ieb0d9f92f563a40552eb31bc0499c8ac65f78ce4
/frameworks/av/services/audioflinger/Threads.h
e8726fea8a53bf3474aa3c6deaf2f6c1f565e694 26-Jun-2015 Eric Laurent <elaurent@google.com> reduce number of binder calls from mediaserver

Reduce the number of audio port, audio patch and
IO config changed binder calls from mediaserver to
client processes:
- Do not call IO config changed callback if selected
device is the same as previously selected one on a given
audio flinger playback or capture thread.
- Do not call the audio port or audo patch list update
callback on a client if this client as no listener registered.

Bug: 22045560.

Change-Id: If780e105404de79b7cb5c80c27b793ceb6b1c423
/frameworks/av/services/audioflinger/Threads.h
40eb1a1f8871909c272e72afaf7d5af84fea2412 18-Jun-2015 Andy Hung <hunga@google.com> Reduce log messages on AudioFlinger throttle

Bug: 21858740
Change-Id: I8f291b64c1033867bb57ffceaa3b7d94aa998715
/frameworks/av/services/audioflinger/Threads.h
43b4dcc660e6da96285e4672ae371070ab845401 10-Jun-2015 Phil Burk <philburk@google.com> AudioFlinger: flush stream when switching tracks

For direct threads, when recycling a stream, perform a flush so
that the frame position is reset.

Bug: 21145353
Change-Id: I08611cd64bb249a9659c44f9e4c47e7455f4838f
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/services/audioflinger/Threads.h
08fb1743f80437c38b4094070d851ea7f6d485e5 01-Jun-2015 Andy Hung <hunga@google.com> Throttle MixerThread data pull to no more than twice expected rate

This helps prevent underruns with NuPlayer and other applications
which set up buffers that are close to minimum size or use deep
buffers, and rely on a double-buffering sleep strategy to fill.

Enabled by default. Disabled by setting af.thread.throttle 0

Bug: 19062223
Bug: 21198655
Change-Id: Ia52b48e0c99588af5db53c43fede2afd775b8899
/frameworks/av/services/audioflinger/Threads.h
ad9cb8b88e4f8face23f01d8dc89fa769dacb50f 27-May-2015 Eric Laurent <elaurent@google.com> audio flinger: add suffix to time variables names

Add suffix to clarify units for the following variables:
standbyTime -> mStandbyTimeNs
standbyDelay -> mStandbyDelayNs
activeSleepTime -> mActiveSleepTimeUs
idleSleepTime -> mIdleSleepTimeUs
sleepTime -> mSleepTimeUs

Change-Id: I7f5d602c39e0ef3f6fe9ef99eaf1b351c7bd4fc3
/frameworks/av/services/audioflinger/Threads.h
72e3f39146fce4686bd96f11057c051bea376dfb 20-May-2015 Eric Laurent <elaurent@google.com> audio flinger: do not call JAVA services until system is ready

Wait for system ready indication form AudioService before enabling
calls to scheduling service or power manager.

Bug: 11520969.
Change-Id: I221927394f4a08fd86c9d457e55dd0e07949f0cf
/frameworks/av/services/audioflinger/Threads.h
f6870aefc5e31d4220f3778c4e79ff34a61f48ad 08-May-2015 Eric Laurent <elaurent@google.com> audio flinger: fix fuzz test crash

Clear output stream pointer in duplicating thread
when the main output to which it is attached is closed.

Also do not forward master mute and volume commands to
duplicating threads as this is not applicable.

Also fix logic in AudioFlinger::primaryPlaybackThread_l()
that could accidentally return a duplicating thread.
This never happens because the primary thread is always
first in the list.

Bug: 20731946.
Change-Id: Ic8869699836920351b23d09544c50a258d3fb585
/frameworks/av/services/audioflinger/Threads.h
296fb13dd9b5e90d6a05cce897c3b1e7914a478a 01-May-2015 Eric Laurent <elaurent@google.com> Implement audio device callback

Add class AudioSystem::AudioDeviceCallback notifying
AudioSystem clients upon device selection change on a given
input or output thread.
Maintain a list of installed callback per I/O handle in AudioSystem
and call registered callbacks when an OPEN of CONFIG_CHANGED event
is received on IAudioFlingerClient::ioConfigChanged().
Add methods to AudioTrack and AudioRecord to add and remove device
change callbacks.
Add methods to AudioTrack and AudioRecord to query currently selected
device.
ioConfigChanged() events now convey the audio patch describing
the input or output thread routing.

Fix AudioRecord failure to start when invalidation is
handled by start().

Change-Id: I9e938adf025fa712337c63b1e02a8c18f2a20d39
/frameworks/av/services/audioflinger/Threads.h
8ce74c3c11458faa34395591a3424e90db856bfc 02-May-2015 Phil Burk <philburk@google.com> Merge "AudioTrack: fix direct tracks not pausing" into mnc-dev
6fc2a7c81f62b1e21487ae37e11aae6241bc3ead 01-May-2015 Phil Burk <philburk@google.com> AudioTrack: fix direct tracks not pausing

When a Direct Track is paused and the HAL does not support
pause() and resume() then the HW never gets paused.
The app can just keep writing data, which gets played.

Bug: 18899620
Change-Id: Ice0f360956ff7ca425f6f24a0a2a8640d8b43fa8
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/services/audioflinger/Threads.h
73e26b661af50be2c0a4ff6c9ac85f7347a8b235 28-Apr-2015 Eric Laurent <elaurent@google.com> AudioSystem: refactor audio config cache and callbacks

Clean up implementation of audio configuration cache and
callback events from AudioFlinger:

- Define class AudioIoDescriptor for audio input and output
configurations outside of AudioSystem class.
- Do not use void * but an AudioIoDescriptor as argument to
audio config callbacks from AudioFlinger.
- Remove unused configuration events.
- Move AudioSystem audio input and output cache from static singletons to
members of AudioFlingerClient subclass.

Change-Id: I67c196c32c09ce2756af0755ee1fe631040c3270
/frameworks/av/services/audioflinger/Threads.h
054d9d3dea1390294650ac704acb4aa0a0731217 24-Apr-2015 Eric Laurent <elaurent@google.com> PatchPanel: do not use setParameters() internally.

Do not use setParameters() with AUDIO_PARAMETER_STREAM_ROUTING
when communicating the input or output device selected to playback or
record threads, even for HAL version less than 3.0.
Use createAudioPatch()/releaseAudioPatch() instead.
This allows to send more information on the output or input device being
selected.

Also fix a regression introduced in L where the output device selection
was not communicated to effects on record threads.

Change-Id: I4780ada53241d56694b005c992171e173c3bf8f5
/frameworks/av/services/audioflinger/Threads.h
d330ee46022f34da76d14d0c4d2910526ecc2321 20-Apr-2015 Andy Hung <hunga@google.com> Add floating and multichannel record to AudioFlinger

Change-Id: Ia388fb012a0b6d81613ef87142a97d76836338f9
/frameworks/av/services/audioflinger/Threads.h
5744661e85981f8a9456bf470e2761235fc026da 20-Apr-2015 Andy Hung <hunga@google.com> Make record buffer in RecordThread variable format

Change-Id: Id4bb9b973eeea16946fba3bc084c7ac270d9fa33
/frameworks/av/services/audioflinger/Threads.h
73c02e4277b399c2ec1555d32b6ad5df23bb83dc 29-Mar-2015 Andy Hung <hunga@google.com> Improve ResamplerBufferProvider

Change-Id: I3cc3af221ad5797ff219d75227350733afa180db
/frameworks/av/services/audioflinger/Threads.h
97a893eb34f8687485c88eaf15917974a203f20b 29-Mar-2015 Andy Hung <hunga@google.com> Add RecordBufferConverter for RecordThread data processing

Change-Id: Ia3aab8590cd41e8a7cba0a7345d70d2866d92045
/frameworks/av/services/audioflinger/Threads.h
f59497bd3c190e087202043de5450ef06e92b27d 27-Jan-2015 Glenn Kasten <gkasten@google.com> Update comments

Change-Id: I37d3c4ce22b74fe8581a886fe5a7f9fef8266dad
/frameworks/av/services/audioflinger/Threads.h
d7dca050c630bddbd73a6623271b34b4290460ee 06-Mar-2015 Glenn Kasten <gkasten@google.com> Rename mName to mThreadName and kNameLength to kThreadNameLength

Change-Id: I0adfcdcab7923a07a840ec0e04528cb8bfc41f10
/frameworks/av/services/audioflinger/Threads.h
81879df8dc51df4d8a3880349e9e1e6b5e3cebfb 07-Jan-2015 Eric Laurent <elaurent@google.com> am 69158e3e: am 6ab33981: am 610255e8: Merge "audioflinger: pause HW A/V sync output when AudioTrack underruns" into lmp-mr1-dev

* commit '69158e3e7b565a5ca131a2efaa9b76615ca80cbb':
audioflinger: pause HW A/V sync output when AudioTrack underruns
b187de1ada34a9023c05d020a4592686ba761278 30-Dec-2014 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: I6c8fe626a3825fa9e139319656d682a57b887c97
/frameworks/av/services/audioflinger/Threads.h
0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d 19-Dec-2014 Eric Laurent <elaurent@google.com> audioflinger: pause HW A/V sync output when AudioTrack underruns

Do not standby, starve or feed 0s to the audio HAL on direct
output using HW A/V sync mode.

Bug: 17883772.

Change-Id: I11e6c97ec24360d75f9b602814d40a54b60cb7a7
/frameworks/av/services/audioflinger/Threads.h
23c8dc13787186dc98731055858b2fba3aedc105 17-Dec-2014 Eric Laurent <elaurent@google.com> am 85aca658: am d33712d7: am 145cf5d8: Merge "audioflinger: implement pause/resume for direct outputs" into lmp-mr1-dev

* commit '85aca658ac7d20584b0647427256df50a5f243ef':
audioflinger: implement pause/resume for direct outputs
d1f69b0b17acbd96987ecb2f3378abd394d05903 15-Dec-2014 Eric Laurent <elaurent@google.com> audioflinger: implement pause/resume for direct outputs

Extend pause/resume support to direct output threads
(was only for offload threads).

If the HAL implements pause/resume, track pause/resume is forwarded to
the HAL.

Pause, flush, resume sequence is respected by executing the HAL
calls in the playback thread (same as offload).

Make sure the track flags on client side are consistent with the
flags on server side.

Bug: 17883772.
Change-Id: I89b360d69818f7a9204bd36e3ec63a79e106ecf1
/frameworks/av/services/audioflinger/Threads.h
3a3e87005fdfbfe4564605220a044b8023d0f539 26-Nov-2014 Eric Laurent <elaurent@google.com> am 72215491: am 1a475921: am 223fd5c9: audio: new routing strategies and stream types

* commit '72215491c60fbcdb9a2f0be782e24e39cca249c5':
audio: new routing strategies and stream types
223fd5c9738e9665e495904d37d4632414b68c1e 11-Nov-2014 Eric Laurent <elaurent@google.com> audio: new routing strategies and stream types

Added new routing strategies and stream type for internal use
by audio policy manager and audio flinger:
- One for accessibility to allow different routing than media
- One for re-routing (remote submix) in preparation of dynamic
policies
- Added stream type for "internal" audio flinger tracks used
for audio patches and duplication.

Bug: 18067208.
Change-Id: I88f884b552e51e4a49c29125e5a1204cf58ff434
/frameworks/av/services/audioflinger/Threads.h
97b7b75b6a31330e213bdb96ccc60916218ad903 28-Sep-2014 Glenn Kasten <gkasten@google.com> Improve dumpsys for output threads

Display output thread type and flags.
Also add units and use consistent spelling.

Change-Id: I19eb627f41c4887b6ad0543024a8477a99890798
/frameworks/av/services/audioflinger/Threads.h
4c053ea158b29fa2cdd4c6f39d3c8da4ee5a7a02 28-Sep-2014 Glenn Kasten <gkasten@google.com> Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp

The per-thread timestamp latch was not synchronized with the per-track
released frames. Now the value of each track's released frames is
latched along with the timestamp.

Bug: 17531839
Bug: 17669342
Change-Id: I9d50c8c6a5de55a3f4561ac40e20d497376c1257
/frameworks/av/services/audioflinger/Threads.h
a49c94ea49c8329a1bdefe980e1f7d335c0d1ec5 02-Oct-2014 Glenn Kasten <gkasten@google.com> Merge "Revert "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp"" into lmp-dev
6954127b7ace022677ac407ff943c2793f8a11be 02-Oct-2014 Glenn Kasten <gkasten@google.com> Revert "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp"

This reverts commit 54464ba861aaafd11ee5645f5d1ecd1171c6e9fe.

Bug: 17733142.

Change-Id: I9886d40032b2f7d96bee03e600e14f78943d8052
/frameworks/av/services/audioflinger/Threads.h
955e24d3a8e218d4711cabc6558781e095011132 30-Sep-2014 Glenn Kasten <gkasten@google.com> Merge "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp" into lmp-dev
54464ba861aaafd11ee5645f5d1ecd1171c6e9fe 28-Sep-2014 Glenn Kasten <gkasten@google.com> Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp

The per-thread timestamp latch was not synchronized with the per-track
released frames. Now the value of each track's released frames is
latched along with the timestamp.

Bug: 17531839
Bug: 17669342
Change-Id: I96252782911bd42a2534cc4030521b7eeb99a7b9
/frameworks/av/services/audioflinger/Threads.h
e659ef420dae0caae84ab78f9df8952acb9ad3a0 29-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: forward flush to direct output streams

Track flush should be forwarded to the audio HAL when playing
on a direct output stream.

Bug: 17704953.
Change-Id: Iafc94327fe9aebf1d4eaa97b76c6767b7ac5babe
/frameworks/av/services/audioflinger/Threads.h
aaa44478a373232d8416657035a9020f9c7aa7c3 13-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: fix pre processing effect leak

When a capture thread was closed, the effects attached to this thread
were left dangling and the associated effect chain destroyed.
When their last client was disconnected, the effects were not released
properly from the effect library because the destruction process could
not be completed without the effect being attached to a thread.

A similar problem prevented a RecordTrack to be properly released if
its client was destroyed after the capture thread.

The fix consists in allowing the effect or record track to be properly
released even if its parent thread cannot be promoted.

Also save any effect chain still present on a closed capture thread
in case a new client wants to reuse the effects on the same session later.

Bug: 17110064.
Change-Id: I5cd644daa357afd1f3548f9bcb28e6152d95fdb8
/frameworks/av/services/audioflinger/Threads.h
83b8808faad1e91690c64d7007348be8d9ebde73 21-Jun-2014 Eric Laurent <elaurent@google.com> audio flinger: add patch connection between hw modules

Add support for audio device connections between different audio
hw modules.
The patch is performed by creating a bridge between the playback
thread connected to the sink device and the record thread connected
to the source device using a pair of specialized PlaybackTrack and
RecordTrack.
- Added PatchTrack and PatchRecord classes.
- Added TrackBase type to indicate more clearly the track behavior.
- A TrackBase can allocate the buffer or reuse an existing one.
- Factored some code in openOutput() and openInput() for internal use
by PatchPanel.

Bug: 14815883.

Change-Id: Ib9515fcda864610458a4bc81fa8f59096ff4d7db
/frameworks/av/services/audioflinger/Threads.h
463be250de73907965faa6a216c00312bf81e049 11-Jul-2014 Andy Hung <hunga@google.com> Return negotiated format with HAL in AudioFlinger

Fixes an issue caused by extended precision and the FastMixer
when the format to the FastMixer was returned instead of the
HAL format.

Change-Id: I2be9d55d5c87d82e46b5200b07fcdd986ebde08a
/frameworks/av/services/audioflinger/Threads.h
5c68f959eaa2e02fed5643c78e281fff42bcc0a2 07-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "IAudioFlinger::openRecord now suggests notificationFrames"
7df8c0b799d8f52d6386e03313286dbd7d5cdc7c 03-Jul-2014 Glenn Kasten <gkasten@google.com> IAudioFlinger::openRecord now suggests notificationFrames

Change-Id: I08885cc381d03c522a23289e74f0e1ed46563863
/frameworks/av/services/audioflinger/Threads.h
5ba4440c11eb975ec0e104e0af1981838f42f57c 04-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete IAudioFlinger::channelCount()"
4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e 13-May-2014 Glenn Kasten <gkasten@google.com> Use sp<> instead of raw pointer for FastMixer

This avoids worry about the thread lifetime during tear-down.

Bug: 15858655
Change-Id: I896d24317bd6f53a574645cdf4cd514eaa205dd5
/frameworks/av/services/audioflinger/Threads.h
6dbb5e3336cfff1ad51d429fcb847307c06efd61 13-May-2014 Glenn Kasten <gkasten@google.com> Use of fast capture by normal capture

Will only configure fast capture path if the input buffer size is less than
10 ms and the input sample rate is same as the primary output sample rate.

Change-Id: I4a7cdc6069d750845412c626d27e83f72a1ab397
/frameworks/av/services/audioflinger/Threads.h
f947dbce4390f2c3c460325d37002a34f09c0b74 01-Jun-2014 Glenn Kasten <gkasten@google.com> Remove obsolete IAudioFlinger::channelCount()

Change-Id: Ie623edae2e795f9155f1f452fe4e6c7217a4a4c8
/frameworks/av/services/audioflinger/Threads.h
1c333e252cbca3337c1bedbc57a005f3b7d23fdb 20-May-2014 Eric Laurent <elaurent@google.com> audioflinger: first patch panel implementation.

Added a new PatchPanel subclass to AudioFlinger
to handle audio ports and audio patches configuration
and connection.
The first implementation does not add new functionnality.
AudioPolicyManager uses patch panel interface to control
device routing.
AudioFlinger:
- Added PatchPanel class. The first implementation does not
add new functionnality. PatchPanel handles routing commands
for audio HAL after 3.0 or converts to setParameters for audio
HALs before 3.0.
- Added config events to ThreadBase to control synchronized
audio patch connection.
AudioPolicyManager:
- Use PatchPanel API to control device selection isntead of setParameters.
- New base class AudioPort common to audio device descriptors
and input output stream profiles. This class is RefBase and groups
attributes common to audio ports.
- Use same device selection flow for input as for outputs:
getNewInputDevice -> getDeviceForInptusiource -> setInputDevice

Change-Id: Idaa5a883b19a45816651c58cac697640dc717cd9
/frameworks/av/services/audioflinger/Threads.h
c62476f0c0c1cf9283a38852bde0a4c9434df712 24-May-2014 Andy Hung <hunga@google.com> Merge "Add format parameter to getTrackName() and track_t"
6181ffd90a436f333c43a7f812391eee2c35005a 13-May-2014 Glenn Kasten <gkasten@google.com> Allow track buffer "allocation" to be from pipe

Change-Id: Ib9ac170f8e8b7746b3588157a56cbee3b753a1cb
/frameworks/av/services/audioflinger/Threads.h
e8a1ced4da17dc6c07803dc2af8060f62a8389c1 10-May-2014 Andy Hung <hunga@google.com> Add format parameter to getTrackName() and track_t

Change-Id: Ia152a839014e235fbfb656104c15d7c1b456d02e
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
021cf9634ab09c0753a40b7c9ef4ba603be5c3da 13-May-2014 Eric Laurent <elaurent@google.com> AudioFlinger: add specific mutex for client lists

Add a specific mutex to protect access to mClients and
mNotificationClients lists. This avoids locking the main AudioFlinger
mutex from inside thread loops and allows not to worry about
cross deadlocks when sending a config event with status reply while
keeping the ThreadBase or AudioFlinger mutex locked.
As a way of consequence, remove notification client list passed to
processConfigEvents_l() and audioConfigChanged() as the list
can now be accessed by locking client mutex only.

Change-Id: I228022204b6709a8bb60cc96d9514a6ffe59b62e
/frameworks/av/services/audioflinger/Threads.h
1035194cee4fbd57e35ea15c56e66cd09b63d56e 09-May-2014 Eric Laurent <elaurent@google.com> audioflinger: refactor thread config events

Merge config events and set parameters messaging mechanism.
- setting parameters now uses the config event mechanism
- config event now allow to wait for a condition and synchronize caller
binder thread with execution thread and return an execution status.
- simplify locking mechanism to avoid unlocking the thread
mutex while processing events.

Change-Id: Ia49cb3e617abec4bacb6c1f9a8cb304c4ed3902e
/frameworks/av/services/audioflinger/Threads.h
b880f5e5fc07397ddd09a94ba18bdf4fa62aae00 07-May-2014 Glenn Kasten <gkasten@google.com> Add a per-thread heap that is read-only to clients

Change-Id: I401263566ca20fbfb565689c8fa99458d3b283b2
/frameworks/av/services/audioflinger/Threads.h
3a6c90aa0617666d9abc94c02b752d9eb3d64772 13-Mar-2014 Glenn Kasten <gkasten@google.com> Add FIXMEs to createRecord for fast capture

Change-Id: I759be200fae32969212c52a409f46f2e704081e3
/frameworks/av/services/audioflinger/Threads.h
010a1a1a552cdaad362cea8a0333b8906402dbcb 13-Mar-2014 Andy Hung <hunga@google.com> Revert "Revert "Convert AudioFlinger mSinkBuffer to flexible format""

This reverts commit e2a9c29f35e0c09782558542fc4cf9823779590e.
/frameworks/av/services/audioflinger/Threads.h
e2a9c29f35e0c09782558542fc4cf9823779590e 13-Mar-2014 Eric Laurent <elaurent@google.com> Revert "Convert AudioFlinger mSinkBuffer to flexible format"

This reverts commit e7e676fd2866fa4898712c4effa9e624e969c182.

Bug: 13450717.
Change-Id: Ib80b0d14428fecce33c62003a1fcf83f71cee03b
/frameworks/av/services/audioflinger/Threads.h
e7e676fd2866fa4898712c4effa9e624e969c182 05-Mar-2014 Andy Hung <hunga@google.com> Convert AudioFlinger mSinkBuffer to flexible format

Change-Id: I618d9c99a5f6f8c8d6a9f4b2d19e82c9ddc3b06e
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
98ef978df4e928f486d244c4d7f7ad9f13111e98 04-Mar-2014 Andy Hung <hunga@google.com> Add mEffectBuffer to AudioFlinger

Change-Id: Icf97c50040bc127723d56eb4d2fb6e790a7253d9
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
69aed5f0f4a3be3996d1e78a0473e1a72c1547da 26-Feb-2014 Andy Hung <hunga@google.com> Add MixerBuffer for accumulation of float audio

Path into and out of MixerBuffer is set up, but not
currently enabled.

Change-Id: I9d50752607d22dd2a3d9cc7e053babf8dfb22958
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
25c2dac12114699e90deb1c579cadebce7b91a97 27-Feb-2014 Andy Hung <hunga@google.com> Rename mixBufferSize to mSinkBufferSize in AudioFlinger

Change-Id: I4d1d18d716fa3ad8c0e7cc87f5a2823422f504eb
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
2098f2744cedf2dc3fa36f608aa965a34602e7c0 27-Feb-2014 Andy Hung <hunga@google.com> Rename mMixBuffer to mSinkBuffer in AudioFlinger

Change-Id: I1f55630425b8ce36e9df2aaf64e06a8960b69a47
Signed-off-by: Andy Hung <hunga@google.com>
/frameworks/av/services/audioflinger/Threads.h
4cc0a6a835c806d200ef83ef31fe5bef327c355c 17-Feb-2014 Glenn Kasten <gkasten@google.com> Multi-client recording continued

Remove mReqChannelCount and mReqSampleRate.
Increase number of input frames needed for sample rate converter.
Add TODO comments to investigate later.
Fix bugs in sample rate conversion.

Change-Id: I3aa54b862843d518b6e4ece9a7f52fd27d741629
/frameworks/av/services/audioflinger/Threads.h
25f4aa83efaa9179e65a20583a6d441de2c3ff3f 07-Feb-2014 Glenn Kasten <gkasten@google.com> Move handleSyncStartEvent and clearSyncStartEvent to RecordTrack

Change-Id: I611a63e63acf3eb17e2072c1a77b91fe9e62e36a
/frameworks/av/services/audioflinger/Threads.h
deca2ae0a7cf8bc54ff3f30b7dc39bbc78b94c0d 07-Feb-2014 Glenn Kasten <gkasten@google.com> Add _l suffix to readInputParameters/OutputParameters

They are always called while thread mutex is locked,
or in the thread constructor.

Change-Id: I56df71563a52a5cd6cea6fc0914df993519e1b74
/frameworks/av/services/audioflinger/Threads.h
6dd62fb91d82dedcfa3ab38c02eb0940b4ba932a 06-Dec-2013 Glenn Kasten <gkasten@google.com> Multi-client recording

Supports multiple clients both at native sample rate and with resampling.

Change-Id: Icea55b4fd30751761b7debaa3ce016c79e712d8d
/frameworks/av/services/audioflinger/Threads.h
1d6fa7af1288b550faabe4ec2cf98684236723db 11-Feb-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of 566be7c3 to master

Change-Id: I7b1cc71057b2bd4f771e7bcf508a8c3abd6017ce
377b2ec9a2885f9b6405b07ba900a9e3f4349c38 03-Feb-2014 Kévin PETIT <kevin.petit@arm.com> Make frameworks/av 64-bit compatible

Contains the necessary changes to make frameworks/av build and work
on a 64-bit machine.

Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

Change-Id: I725feaae50ed8eee25ca2c947cf15aee1f395c43
/frameworks/av/services/audioflinger/Threads.h
4944acb7355b3aa25748fd25945a363a69d65444 19-Aug-2013 Glenn Kasten <gkasten@google.com> Fix whitespace

Change-Id: I9add0872030a26933f6b6dad1be299154611cc56
/frameworks/av/services/audioflinger/Threads.h
f74f213c0cd0612101e00a73704429dac1a92fe3 07-Feb-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: Offload track transition fix"
d9a4783985203c759ddcca784798ef395668fe05 07-Feb-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: Modify flush handling for offload path"
010c4c8ec50eb04ece15f792c508a3b869749310 07-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix IoConfigEvent constructor initializer list"
4c6a433d74d5ae8b9bc0557207e3ced43bf34a25 15-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> AudioFlinger: Offload track transition fix

Trigger state changes in OffloadThread on adding a new offload track.

Bug: 12530661
Change-Id: I95b62764c7ac041d470702e86b951f812eb0e70f
/frameworks/av/services/audioflinger/Threads.h
7844f679be8d94c5cdf017f53754cb68ee2f00da 15-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> AudioFlinger: Modify flush handling for offload path

Do not allow an offload track to directly control the offload thread
behavior. OffloadThread can check for any pending flush reporting
by its active tracks and decide to flush the HW or not.

Bug: 12530661
Change-Id: Ib33f023c942f6c091b618004136b153c38a6eef6
/frameworks/av/services/audioflinger/Threads.h
0f11b51a57bc9062c4fe8af73747319cedabc5d6 01-Feb-2014 Glenn Kasten <gkasten@google.com> Fix unused parameter warnings in audio

Change-Id: I665ba3358dd9502f0adec70d486e7bf8a2e1b0fe
/frameworks/av/services/audioflinger/Threads.h
49debee5bdddd7a1e0742a3ab66d4630bbe25ca2 01-Feb-2014 Glenn Kasten <gkasten@google.com> Fix IoConfigEvent constructor initializer list

Fortunately this bug never showed up, because the parameter
field has not been used yet.

Change-Id: I2b36e2b7e1dcc2039c494fc5ea4994d262435aac
/frameworks/av/services/audioflinger/Threads.h
f0002d142e6d24c5438600b2c259679de710f8ac 24-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Replace control block frameCount_ by explicit in/out parameter"
5f972c031d4061f4f037c9fda1ea4bd9b6a756cd 13-Jan-2014 Glenn Kasten <gkasten@google.com> AudioRecord::getInputFramesLost() cleanup

Fixed bug that if the binder call failed (for example if the
IAudioFlinger binder is dead), then getInputFramesLost was returning
garbage. Now it correctly returns zero, which is the error value for
this method.

The type declarations for getInputFramesLost were inconsistent:
a mixture of unsigned int, size_t, and uint32_t. Now it returns uint32_t
everywhere, which is what the underlying HAL API returns.

Added a FIXME about the side effect behavior. This will need review
for multi-client.

Change-Id: Ifa2e117a87dbd0c1f2c892a31d1c3dd919bf1a0a
/frameworks/av/services/audioflinger/Threads.h
74935e44734c1ec235c2b6677db3e0dbefa5ddb8 19-Dec-2013 Glenn Kasten <gkasten@google.com> Replace control block frameCount_ by explicit in/out parameter

in IAudioFlinger::createTrack and IAudioFlinger::openRecord

Change-Id: I09c644c80e92c8e744b1b99055988a2588b2a83d
/frameworks/av/services/audioflinger/Threads.h
2b806406ac1ec680b6fe3aaa84c54bdc4e43ad8d 21-Nov-2013 Glenn Kasten <gkasten@google.com> Change mActiveTrack to mActiveTracks vector

The size of mActiveTracks is still limited to 1 for now.

Change-Id: Ia6b06b25d8c4709f087110ae29c589999407a2a2
/frameworks/av/services/audioflinger/Threads.h
731076cc7857fe322eed018569a2a67f6eac0e54 15-Nov-2013 Eric Laurent <elaurent@google.com> am 06d62548: am d7e59228: audioflinger: do not use raw pointer for tracks

* commit '06d6254823b8f7a46690369e57b5f149c94c9f65':
audioflinger: do not use raw pointer for tracks
d7e59228caad3867794d847f6bf163c6495e9506 15-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: do not use raw pointer for tracks

Commit 9da3d95 surfaced a problem caused by the use of a raw
pointer to a track in offload thread implementation.

Pointers to tracks should always be weak or strong pointers.

Bug: 11708529.
Change-Id: Ic48632532d186c9be8261f73cefdf824b9fbbd2b
/frameworks/av/services/audioflinger/Threads.h
8594843c15b4722ced39436fe9e64f3e57e7ace4 19-Aug-2013 Glenn Kasten <gkasten@google.com> Pull HAL reads out of RecordThread resample

Previously, the resample was indirectly calling HAL read
from within the BufferProvider's getNextBuffer. Now the HAL
read is done ahead of time into a circular buffer,
and the getNextBuffer just reads out of that memory.

This change will permit some future planned features.

Also removed the mono to mono resampling optimization,
as that optimization will no longer be valid in the future.

Change-Id: I59f5016a2df91078d697c37a7dec2d9d9f44542e
/frameworks/av/services/audioflinger/Threads.h
93e471f620454f7de73d190521568b1e25879767 19-Aug-2013 Glenn Kasten <gkasten@google.com> Rename standby methods

ThreadBase::standby() returns the value of mStandby.

RecordThread::standby() "overrode" ThreadBase::standby(), but with a
different meaning and no return value. This meant you couldn't
access the parent's class definition within RecordThread.

This could be confusing, so this CL renames RecordThread::standby()
to standbyIfNotAlreadyInStandby().

Change-Id: I9196ee12701dd2dccdfaed922af2d7b8e8774676
/frameworks/av/services/audioflinger/Threads.h
d21952fe5bc94f7bb6ee729f806c0e641fdb1a0d 29-Oct-2013 Eric Laurent <elaurent@google.com> am 7f8f7585: am fd477974: AudioFlinger: more fixes for offload audio lost

* commit '7f8f758506a95d6fe5c0e52aa7b5ef82fb18861a':
AudioFlinger: more fixes for offload audio lost
fd4779740ec3e9e865d5514464df26d015354388 26-Oct-2013 Eric Laurent <elaurent@google.com> AudioFlinger: more fixes for offload audio lost

mStandby being false was not a reliable indication that
something had been written to audio HAL.

Considering the last track in mActiveTracks vector as the
latest activated track was wrong as this is a SortedVector.

Bug: 11247103.
Change-Id: I397d011c5afcdd779def3fe25aaae7669a472cfc
/frameworks/av/services/audioflinger/Threads.h
9cae217050aa1347d4ac5053c305754879e3f97f 14-Jan-2013 Marco Nelissen <marcone@google.com> Assign blame for playback wakelocks.

Set a work source for the playback wakelock, so that playback is
counted against the requesting app instead of the media server.

Cherrypicked from master.

b/9464621

Change-Id: I7329f88a288a95a582a78005a1c3d16a5a611e31
/frameworks/av/services/audioflinger/Threads.h
462fd2fa9eef642b0574aa7409de0bde3fec8d43 14-Jan-2013 Marco Nelissen <marcone@google.com> Assign blame for playback wakelocks.

Set a work source for the playback wakelock, so that playback is
counted against the requesting app instead of the media server.

Change-Id: I7329f88a288a95a582a78005a1c3d16a5a611e31
/frameworks/av/services/audioflinger/Threads.h
6a7327f110b86613e6e8c7de105c49803acacc1d 18-Oct-2013 Eric Laurent <elaurent@google.com> am 6edd8ca5: am 6a51d7ed: audioflinger: fix track terminated before playing

* commit '6edd8ca5b7e3d169db4314d2b994bc9d48e9e082':
audioflinger: fix track terminated before playing
6a51d7ed7062536ccc892c8850a34ed55cbc8d5c 18-Oct-2013 Eric Laurent <elaurent@google.com> audioflinger: fix track terminated before playing

When a track is terminated before any audio was written,
we should not send a drain request to the HAL. The drain
will be ignored and we will wait the async callback for ever.

Also fix a potential deadlock by not deleting a track with the
thread mutex held: mPreviousTrack changed from a sp to a raw pointer.

Bug: 11247103.
Change-Id: I0a4b47b099204c7c326d45d700234ab8f72d8eae
/frameworks/av/services/audioflinger/Threads.h
3278eed31fcf82045ac00dcd549dda5270c88971 15-Oct-2013 Narayan Kamath <narayan@google.com> am 8580679e: am 014e7fa2: Make Audio wakelock names less unique.

* commit '8580679e1780617d978d28a43e932314b86608ce':
Make Audio wakelock names less unique.
014e7fa2e90827d911c37bb0ce4d2e10e14d0bb3 14-Oct-2013 Narayan Kamath <narayan@google.com> Make Audio wakelock names less unique.

These wakelocks now show up in the client process, where they
might cause wakelock overflows if AudioFlinger threads die often.

The client process should be agnostic of audio flinger threading,
so don't make the wakelock names rely on audioflinger thread names.

Wakelock names now depend only on the audio flinger thread type, and
not the ID itself.

bug: 11200551

Change-Id: Ia1f71b569cb7502d617b77596abc245f461a6ec0
/frameworks/av/services/audioflinger/Threads.h
5918e0cb64200f64632595f7aea6062c65d43353 04-Oct-2013 Marco Nelissen <marcone@google.com> am b5677882: am 8097068d: Merge "Better recording wake lock accounting" into klp-dev

* commit 'b5677882cf9a34bd3f2daf76d10951282ea9b083':
Better recording wake lock accounting
e14a5d6d2cc91dd2fc09ffdf7aa670b37da0795d 03-Oct-2013 Marco Nelissen <marcone@google.com> Better recording wake lock accounting

Count wake lock use against the app that initiated the recording,
not against the media server.

b/10985160

Change-Id: Iae6e6c030b7f1c6081d9c79725d6990f60dadaaa
/frameworks/av/services/audioflinger/Threads.h
a6c7d98033c161592a062c61eaa6b7fd635e3006 30-Sep-2013 Eric Laurent <elaurent@google.com> am 0adc67df: Merge "audioflinger: fix crash when starting offload thread" into klp-dev

* commit '0adc67dfc5cedb211c36f06849681a60a32f5805':
audioflinger: fix crash when starting offload thread
4de95592980dba88a35b3dc8f3fd045588387a4f 27-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix crash when starting offload thread

Passing a sp to parent thread to AsyncCallbackThread() constructor
causes a strong reference to be acquired on the OffloadThread inside
its constructor which causes an early launch of the thread loop
with unpredictable consequences.

Pass a wp to parent thread instead.

Also move the creation of the AsyncCallbackThread to
readOutputParameters() where mUseAsyncWrite is initialized which
makes more sense.

Also change the type of AsyncCallbackThread parent thread to PlaybackThread
instead of OffloadThread to allow a broder use of non blocking write which
in theory is not limited to audio offload use case.

Bug: 8174034.
Change-Id: I4b093b022030cd4f5eb8b8e477333e91098a6549
/frameworks/av/services/audioflinger/Threads.h
0230a2a8a413076a138db4c4e1dea018104fd5e2 20-Sep-2013 Eric Laurent <elaurent@google.com> am c6bed216: am a3b97ad2: Merge "audioflinger: implement getTimestamp() for offloaded tracks" into klp-dev

* commit 'c6bed216e3a759a855ac4b9b743fbaed2d5929c1':
audioflinger: implement getTimestamp() for offloaded tracks
d2b80a1fb90cb4dc3f569e716af0279c1e1ea72d 20-Sep-2013 Eric Laurent <elaurent@google.com> am ce3e7cb0: am fbb2609f: Merge "audioflinger: fix lost offload thread resume event" into klp-dev

* commit 'ce3e7cb0bd09e7861d417b7d45c1e5921f10a93f':
audioflinger: fix lost offload thread resume event
a3b97ad288e6808c54c6275eaac1bd53108d8f11 20-Sep-2013 Eric Laurent <elaurent@google.com> Merge "audioflinger: implement getTimestamp() for offloaded tracks" into klp-dev
accc147666bfd37fc8b4ef745f18a8c751555ec2 20-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: implement getTimestamp() for offloaded tracks

Bug: 9587132.
Change-Id: Ie9d5f4cca96306d08bc9a2dbd6edd8953096702d
/frameworks/av/services/audioflinger/Threads.h
ede6c3b8b1147bc425f7b923882f559a513fe23b 19-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix lost offload thread resume event

It was possible that a resume request signaled by addTrack_l()
while waiting for an async write callback is lost. This is because
mSignalPending was not set and waitingAsyncCallback_l() would pause the
thread loop before executing prepareTracks_l().

The fix consists in using signal_l() method to wake the thread
loop o that mSignalPending is set.

Also make sure that sleepTime is reset to 0 when resuming to make sure
that we write any remaining bytes to the HAL.

Bug: 10810347.

Change-Id: If9a3b22cc3b9e6eb384a56c48c40e6258d0896ad
/frameworks/av/services/audioflinger/Threads.h
bfc4214079875f0dc8c349e8c475d1813c234e67 06-Sep-2013 Eric Laurent <elaurent@google.com> am 99b84e8b: am 3b4529e0: audioflinger: remove async write race conditions

* commit '99b84e8b013a6e0b926693067b00e82cfbe2ca4f':
audioflinger: remove async write race conditions
3b4529e03c5fc7a44c22f9091ad15a269bfca3a8 06-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: remove async write race conditions

Remove possible race conditions between async callback
thread and offload thread when clearing and setting the
draining and write blocked flags.

Bug: 8174034.
Change-Id: I7af10491f39dc0e7d7414862a9d8e763daa2e2b7
/frameworks/av/services/audioflinger/Threads.h
f557872b594d15599bdb65efd91eb5adeb1d0840 30-Aug-2013 Glenn Kasten <gkasten@google.com> am 908d3c09: am 51ec03c2: Merge "Implement Track::getTimestamp()" into klp-dev

* commit '908d3c09ca7f2ccb280aa5dc8d876099ff9a9d0f':
Implement Track::getTimestamp()
bd096fd9d8e5fc0e62f98807f4818a06f70d0812 23-Aug-2013 Glenn Kasten <gkasten@google.com> Implement Track::getTimestamp()

using a new timestamp latch in PlaybackThread, and
AudioTrackServerProxy::framesReleased() which returns mServer.

Change-Id: I1ebfba968c773faaab95648c272fd3ebd74718d6
/frameworks/av/services/audioflinger/Threads.h
f777331418a86cd9fd709af898ef24a69967aeb4 14-Aug-2013 Glenn Kasten <gkasten@google.com> Add ThreadBase::processConfigEvents_l()

Change-Id: I6bcdc212a984c52ab98b0b0744943b4ecc1e1542
/frameworks/av/services/audioflinger/Threads.h
e198c360d5e75a9b2097844c495c10902e7e8500 13-Aug-2013 Glenn Kasten <gkasten@google.com> Whitespace

Change-Id: Id3ccc183a03421330d0498faaa62a45915cdc3d6
/frameworks/av/services/audioflinger/Threads.h
9156ef3e11b68cc4b6d3cea77f1f63673855a6d1 07-Aug-2013 Glenn Kasten <gkasten@google.com> Status pointer passed by caller is always non-NULL

in createTrack, openRecord, createEffect, createTrack_l,
createRecordTrack_l, and createEffect_l.

Change-Id: I2e459e4de9c78145f4d496e6abf289479a2f0941
/frameworks/av/services/audioflinger/Threads.h
e92db4bdb575d897d6bbd5086761fa9387393c83 12-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Pull up readyToRun into ThreadBase"
b0e6b967c290c905c4c696df4a8ac9e9d591928b 12-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Simplify the code that allocates mMixBuffer by removing mAllocMixBuffer"
f874f1375d758c8a7a84572a94371fbd4085f0df 08-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Pull up mBufferSize from RecordThread to ThreadBase"
cf04c2cb8e031acc03c1c91cb1ccab15098c89b6 06-Aug-2013 Glenn Kasten <gkasten@google.com> Pull up readyToRun into ThreadBase

Change-Id: Ib150afd72c3b35d83599a61664e89302a8feb4b5
/frameworks/av/services/audioflinger/Threads.h
c1fac191069774c7bfcb062edbb821ea56e7dbc0 06-Aug-2013 Glenn Kasten <gkasten@google.com> Simplify the code that allocates mMixBuffer by removing mAllocMixBuffer

Change-Id: I5ac41210251789a034d760309c50fe018f2442ce
/frameworks/av/services/audioflinger/Threads.h
70949c47fbae3f836d15f040551d7631be3ed7c2 06-Aug-2013 Glenn Kasten <gkasten@google.com> Pull up mBufferSize from RecordThread to ThreadBase

Now both playback and record threads have a HAL buffer size for fast
tracks, and a potentially larger-sized buffer for normal tracks.

Change-Id: I6f57b85ecece3cbd4e9e64b8c41c3352f7656912
/frameworks/av/services/audioflinger/Threads.h
90e58b1fefc8caf70b34301a92bc86179580b6fc 01-Aug-2013 Glenn Kasten <gkasten@google.com> RecordThread::createRecordTrack_l use flags for fast tracks

Look at client's request for a fast track in the flags parameter,
and check whether the request can be satisfied.

Change-Id: I65ddaeb1b85670fe9066076f638bfed0cda01c0d
/frameworks/av/services/audioflinger/Threads.h
ddb0ccf3fb6fe8da8c71a6deb30561b821f3c0a2 01-Aug-2013 Glenn Kasten <gkasten@google.com> RecordTrack::createRecordTrack_l flags are in/out

The flags are currently unused, but will be used for requesting a fast
track. Making flags in/out will allow reporting back up to client that
the request is denied.

Change-Id: Ifbee57da3632ce130551065a426577fb97b1a68d
/frameworks/av/services/audioflinger/Threads.h
b08ab81bab9e8cd2e3a7fff02725a387070fd078 31-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Add resampler comments and fix a typo"
34af02647b387a252fb02bab8e2cb9f7bd9c8abb 30-Jul-2013 Glenn Kasten <gkasten@google.com> Add resampler comments and fix a typo

Change-Id: Ie071673875f663de4212eed4a4dff89d51a5a915
/frameworks/av/services/audioflinger/Threads.h
548efc94813c1dec6e8cf6c085ae41ccb04827f1 29-Nov-2012 Glenn Kasten <gkasten@google.com> Rename RecordThread::mInputBytes to the more generic mBufferSize

This prepares for using it in PlaybackThreads later

Change-Id: Id90a92aa6372e4b69914b0008cef07296ca5d6a3
/frameworks/av/services/audioflinger/Threads.h
9b58f63e45ef2fdfb839b9b9bb3411d81eb96128 16-Jul-2013 Glenn Kasten <gkasten@google.com> Move members from ThreadBase to PlaybackThread

Move mNormalFrameCount and frameCountHAL(), since they're not used by
record threads. Also comment which fields are updated by readParameters().

Change-Id: I5fc0a8a89cc637976f22d49271a5a3e136dab4e1
/frameworks/av/services/audioflinger/Threads.h
f6ed423af92a56ef54bba23eba883b1f21448b54 16-Jul-2013 Glenn Kasten <gkasten@google.com> Treat mChannelCount as uint32_t consistently

mChannelCount was 8-, 16-, or 32-bits

Change-Id: I2cc2fedf3e33144e5c8bbd9894763282d9217f63
/frameworks/av/services/audioflinger/Threads.h
afbbc6c5f6bc470d504dcf24ceb3ac21d57fb78d 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Simplify RecordTrack::stop()"
a8356f663014e7d4c27869629af83d8bb3441e19 25-Jul-2013 Glenn Kasten <gkasten@google.com> Simplify RecordTrack::stop()

Change-Id: Ib959c1e9dc9544d12277ce11bea445118b2e0521
/frameworks/av/services/audioflinger/Threads.h
bfb1b832079bbb9426f72f3863199a54aefd02da 07-Jan-2013 Eric Laurent <elaurent@google.com> AudioFlinger: offload playback, non-blocking write

- Added specialized playback thread class for offload playback,
derived from directoutput thread.
This thread type handles specific state transitions for offloaded
tracks and offloading commands (pause/resume/drain/flush..) to audio HAL.
As opposed to other threads, does not go to standby if the track is paused.

- Added support for asynchronous write and drain operations at audio HAL.
Use a thread to handle async callback events from HAL: this avoids locking
playback thread mutex when executing the callback and cause deadlocks when
calling audio HAL functions with the playback thread mutex locked.

- Better accouting for track activity: call start/stop and release Output
methods in audio policy manager when tracks are actually added and removed
from the active tracks list.
Added a command thread in audio policy service to handle stop/release commands
asynchronously and avoid deadlocks with playback thread.

- Track terminated status is not a state anymore. This condition is othogonal
to state to permitted state transitions while terminated.

Change-Id: Id157f4b3277620568d8eace7535d9186602564de
/frameworks/av/services/audioflinger/Threads.h
c6ae3c8a261794fd4445e4e152d1ada074a3f92f 17-Jul-2013 Glenn Kasten <gkasten@google.com> Fix theoretical memory leak in mConfigEvents

Change-Id: I137f70676c8919661e716c33e0dd9c25c2b6285c
/frameworks/av/services/audioflinger/Threads.h
fb1fdc9d6603aa228362e7349451f6455c9849c2 11-Jul-2013 Glenn Kasten <gkasten@google.com> Add comments

Change-Id: Ifbf3a46a4183c8abc0feee1c588953ab10303cc1
/frameworks/av/services/audioflinger/Threads.h
bf04b5860182d8f4130dcb5d6d88ee68a58c99cd 02-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "media.log cleanup" into jb-mr2-dev
ab7d72f0804fbb7e91ad9d2a16f826d97e20e5d0 27-Feb-2013 Glenn Kasten <gkasten@google.com> media.log cleanup

Remove almost all of the specific logs, but leave the media.log
logging infrastructure in place for the next time we need it.

Re-apply a few good changes that were reverted earlier:
- check logf format vs. argument list compatibility
- distinguish potentially modified and actually modified tracks in FastMixer
- fix benign bug where sq->end() was called more than once
- fix a build warning

Bug: 6490974
Change-Id: I02d3e83646c738acaebb415bd0d6b548638b4ef5
/frameworks/av/services/audioflinger/Threads.h
46909e7eb074ce1b95b8a411eb71154f53f84f77 26-Feb-2013 Glenn Kasten <gkasten@google.com> Remove tee sink debugging at compile time

Bug: 8223560
Change-Id: Iddbfb06c45d43d9f20bb428215dd4094931e19a7
/frameworks/av/services/audioflinger/Threads.h
7f5d335f7b4caecd0dfb8f1085f352f1d2da5d2e 16-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 32584a7d672864b20ab8b83a3cb23c1858e908b7

Change-Id: I9dc680578b955b1af462eeb7a49d61a0d45eb81b
/frameworks/av/services/audioflinger/Threads.h
32584a7d672864b20ab8b83a3cb23c1858e908b7 13-Feb-2013 Glenn Kasten <gkasten@google.com> Temporary additional logging to investigate bug

The bug appears related to continuing to use an invalid buffer provider
in fast mixer after track destruction, so focus the added logs in that area.

Also includes a bug fix: was calling log in an unsafe place
near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250.

Details:
- include caller pid or client pid where appropriate
- increase log buffer size
- log mFastIndex when AudioMixer sees an invalid bufferProvider.
- log both potentially modified and actually modified tracks in FastMixer.
- fix benign bug where sq->end() was called more than once.
- log StateQueue push() call and return.
- increase StateQueue size from 4 to 8 entries
- log mixer->enable(), bufferProvider, and currentTrackMask
- log buffer provider addresses
- increase fast mixer log buffer again
- check logf format vs. argument list compatibility
- add logging to AudioMixer
- add checking of magic field in AudioMixer to detect overwrites
- add bool AudioMixer::enabled()
- increase log buffer sizes yet again
- enable assertion checking without ALOGV
- improve a few log messages
- check for corruption in more places
- log in all the process hooks
- add new mixer APIs so we can check for corruption of mixer state
- fix a build warning

Bug: 6490974
Change-Id: Ib0c4a73dcf606ef9bd898313b3b40ef61ab42f51
/frameworks/av/services/audioflinger/Threads.h
e186b51e0a9834b287d7a509e960eaf1b688db75 15-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 639482c24c911b125398b31883ba6d55faebe28b

Change-Id: I11f2829072ab11e18b0663024f27bf31192f1d39
/frameworks/av/services/audioflinger/Threads.h
639482c24c911b125398b31883ba6d55faebe28b 13-Feb-2013 Glenn Kasten <gkasten@google.com> Temporary additional logging to investigate bug

The bug appears related to continuing to use an invalid buffer provider
in fast mixer after track destruction, so focus the added logs in that area.

Also includes a bug fix: was calling log in an unsafe place
near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250.

Details:
- include caller pid or client pid where appropriate
- increase log buffer size
- log mFastIndex when AudioMixer sees an invalid bufferProvider.
- log both potentially modified and actually modified tracks in FastMixer.
- fix benign bug where sq->end() was called more than once.
- log StateQueue push() call and return.
- increase StateQueue size from 4 to 8 entries
- log mixer->enable(), bufferProvider, and currentTrackMask
- log buffer provider addresses
- increase fast mixer log buffer again
- check logf format vs. argument list compatibility
- add logging to AudioMixer
- add checking of magic field in AudioMixer to detect overwrites
- add bool AudioMixer::enabled()

Bug: 6490974
Change-Id: I1f3f18aa62d9fbd35bc32285b669f5ba40efe28e
/frameworks/av/services/audioflinger/Threads.h
51eb3965caa8ba135bcdd8ffb7a2024a042ecdc0 14-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 0ddd56316262ac74a95e9edb595697c163136d6d

Change-Id: I180a928af6f5a38d15a5efe44cd1fe927b5d961c
/frameworks/av/services/audioflinger/Threads.h
0ddd56316262ac74a95e9edb595697c163136d6d 13-Feb-2013 Glenn Kasten <gkasten@google.com> Temporary additional logging to investigate bug

The bug appears related to continuing to use an invalid buffer provider
in fast mixer after track destruction, so focus the added logs in that area.

Also includes a bug fix: was calling log in an unsafe place
near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250.

Details:
- include caller pid or client pid where appropriate
- increase log buffer size
- log mFastIndex when AudioMixer sees an invalid bufferProvider.
- log both potentially modified and actually modified tracks in FastMixer.
- fix benign bug where sq->end() was called more than once.
- log StateQueue push() call and return.

Bug: 6490974
Change-Id: Iee7c8f40e20b6000cd8286c0ec6a14fff4a37af1
/frameworks/av/services/audioflinger/Threads.h
ecd9389c8712aedeb2a79823ea0e4fb842684269 12-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 3051df27261e9952c0e642dec548515250e85f6a

Change-Id: I8bf5c3e91b65bd20de26f480c367c2854b62373c
/frameworks/av/services/audioflinger/Threads.h
3051df27261e9952c0e642dec548515250e85f6a 12-Feb-2013 Glenn Kasten <gkasten@google.com> Temporary additional logging to investigate bug

The bug appears related to continuing to use an invalid buffer provider
in fast mixer after track destruction, so focus the added logs in that area.

Also includes a bug fix: was calling log in an unsafe place
near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250.

Details:
- include caller pid or client pid where appropriate
- increase log buffer size

Bug: 6490974
Change-Id: I4c030f171343fe4b483eae0ddea4427118d8d4b1
/frameworks/av/services/audioflinger/Threads.h
59686720182dcaa1a1a4757964df38c16f1a5246 04-Feb-2013 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix RecordThread initial device"
d3922f72601d82c6fc067a98916fda0bd1291c5f 02-Feb-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix RecordThread initial device

A regression was introduced when the audio device enums where
modified for a 32 bit representation: the device passed when
constructing a RecordThread was still the concatenation of input
device and output device bit fields on one 32 bit value which
is not possible anymore.

The fix consists in modifying the RecordThread constructor to accept
separate values for input and output devices.

Change-Id: I81fb5f4718428b54251e65d74b86e198ce15193e
/frameworks/av/services/audioflinger/Threads.h
9e58b552f51b00b3b674102876bd6c77ef3da806 19-Jan-2013 Glenn Kasten <gkasten@google.com> AudioFlinger uses media.log service for logging

Change-Id: Ia0f8204334f6b233f644d897762a18c95d936b4b
/frameworks/av/services/audioflinger/Threads.h
81784c37c61b09289654b979567a42bf73cd2b12 19-Nov-2012 Eric Laurent <elaurent@google.com> AudioFlinger files reorganization

Audioflinger.cpp and Audioflinger.h files must be split to
improve readability and maintainability.

This CL splits the files as follows:

AudioFlinger.cpp split into:
- AudioFlinger.cpp: implementation of IAudioflinger interface and global methods
- AFThreads.cpp: implementation of ThreadBase, PlaybackThread, MixerThread,
DuplicatingThread, DirectOutputThread and RecordThread.
- AFTracks.cpp: implementation of TrackBase, Track, TimedTrack, OutputTrack,
RecordTrack, TrackHandle and RecordHandle.
- AFEffects.cpp: implementation of EffectModule, EffectChain and EffectHandle.

AudioFlinger.h is modified by inline inclusion of header files containing
the declaration of complex inner classes:
- AFThreads.h: ThreadBase, PlaybackThread, MixerThread, DuplicatingThread,
DirectOutputThread and RecordThread
- AFEffects.h: EffectModule, EffectChain and EffectHandle

AFThreads.h includes the follownig headers inline:
- AFTrackBase.h: TrackBase
- AFPlaybackTracks: Track, TimedTrack, OutputTrack
- AFRecordTracks: RecordTrack

Change-Id: I512ebc3a51813ab7a4afccc9a538b18125165c4c
/frameworks/av/services/audioflinger/Threads.h