History log of /frameworks/av/services/audioflinger/AudioFlinger.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
293558ad1977e24e65f7ba78f47382d33fc77d64 21-Mar-2017 Andy Hung <hunga@google.com> AudioFlinger: Improve Thread logging.

Test: dumpsys media.audio_flinger
Bug: 30572472
Change-Id: I43f72354a6ece045f5f9f664946a406166974258
/frameworks/av/services/audioflinger/AudioFlinger.h
886deb506ea2938cfec40fc0dd2bff072850386b 13-Mar-2017 Glenn Kasten <gkasten@google.com> Merge "Re-format to decrease the maximum line length of files to 100 characters"
d3bb645f0b7f567b033b8664499d685f8ec10628 06-Dec-2016 Glenn Kasten <gkasten@google.com> Re-format to decrease the maximum line length of files to 100 characters

Test: compiles OK
Change-Id: Ibe663032cd390ed2bcca6dc921d47732e6e15e21
/frameworks/av/services/audioflinger/AudioFlinger.h
89e5a2b102b484fe19dbda2a0b118edfefc70241 09-Mar-2017 Nicolas Roulet <nicoroulet@google.com> Merge "NBLog periodic merging thread"
dcdfaecc1fa630a799e1fdb508a9b92da55abc36 14-Feb-2017 Nicolas Roulet <nicoroulet@google.com> NBLog periodic merging thread

Bug: 35468674
Test: no change in functionality, everything works as before
Change-Id: Id2cea243bc15767ca6803c9505bf23a18411500e
/frameworks/av/services/audioflinger/AudioFlinger.h
18b570146c971fe729c391bfbb869391084e623d 14-Feb-2017 Eric Laurent <elaurent@google.com> audioflinger: add standby() method to MmapStreamInterface

Bug: 33398120
Test: open/start/stop/close MMAP no IRQ stream for capture and playback

Change-Id: I48ec202a71565f759c441c2a835d8c8190e76334
/frameworks/av/services/audioflinger/AudioFlinger.h
30d48d9542fb3f85889108c1ee2daff98a4860e7 14-Feb-2017 Andy Hung <hunga@google.com> Merge "VolumeShaper: Initial implementation"
9fc8b5cd4a64ef07e84c69112461324d5c13a0b0 24-Jan-2017 Andy Hung <hunga@google.com> VolumeShaper: Initial implementation

The VolumeShaper is used to apply a volume
envelope to an AudioTrack or a MediaPlayer.

Test: CTS
Bug: 30920125
Bug: 31015569
Change-Id: I42e2f13bd6879299dc780e60d143c2d465483a44
/frameworks/av/services/audioflinger/AudioFlinger.h
7863c791dba8c4e5e9591b6837d410e580be0a25 10-Feb-2017 Eric Laurent <elaurent@google.com> Merge changes from topic 'mmap_no_irq'

* changes:
Add support for mmap stream
audioflinger: define MMAP HAL Stream control interface
8981605d43e24c46d395acb5f145b99589d45917 12-Jan-2017 Andy Hung <hunga@google.com> AudioFlinger: Move RecordBufferConverter to libaudioprocessing

Test: Recording loopback
Bug: 31015569
Change-Id: I7897d959f36ac7424544e35f47576c99a442dd54
/frameworks/av/services/audioflinger/AudioFlinger.h
6acd1d432f526ae9a055ddaece28bf93b474a776 04-Jan-2017 Eric Laurent <elaurent@google.com> Add support for mmap stream

Add support for MMAP streams created by Oboe service.
- A new audio thread class MmapThread deriving from ThreadBase
is added to manage permissions, volume, routing and wakelocks for activity
on MMAP streams.
- Requests received over MmapStreamInterface to open, start and stop
a MMAP stream are forwarded to audio policy manager so that activity
on MMAP capture and playback streams is visible to audio policy and
taken into account in volume and routing management.
`

Bug: Bug: 33398120
Test: manual test
Change-Id: I957906495fe9277d2972d810b633f50cd1e14ec3
/frameworks/av/services/audioflinger/AudioFlinger.h
fc23520d9c3f15e28baa81de5f7dfa6c1b0af426 21-Dec-2016 Eric Laurent <elaurent@google.com> audioflinger: define MMAP HAL Stream control interface

Added definition of MmapStreamInterface used by Oboe service
to open, configure and control MMAP streams at the audio HAl.

This interface is implemented by audioflinger and abstracts the details
of interacting with audio policy manager and audio HAL from Oboe service.

A callback interface MmapStreamCallback is also defiend to communicate
volume and routing changes back to Oboe service.

Bug: 33398120
Test: build
Change-Id: If953d44903aaa4eb17ff16f1922ca16e5e0e0a87
/frameworks/av/services/audioflinger/AudioFlinger.h
068561c8e84569d51df2adbbb53b56fdfd09c06b 04-Jan-2017 Andy Hung <hunga@google.com> AudioFlinger: Split off audio processing library

Test: native AudioResampler test, general playback test
Bug: 31015569
Change-Id: Ifb248f4402a583438d756c014dcd7a4577aef713
/frameworks/av/services/audioflinger/AudioFlinger.h
022b9953153bdb1984f0abb17d21ef8c1826ad49 05-Jan-2017 Mikhail Naganov <mnaganov@google.com> Re-implement HIDL effect processing using FMQ and IMemory

Result: no hwbinder calls due music processing.

Test: make, use Play Music with effects, check traces
Bug: 30222631
Change-Id: I06d0e94e603688874b31824427f3b0878b5f7c8e
/frameworks/av/services/audioflinger/AudioFlinger.h
f28bcf5c057dd9738a09f3cb367cf0b44087135d 20-Dec-2016 Andy Hung <hunga@google.com> AudioFlinger: Use property for local log lines

dumpsys lines can be increased up to 256 (kLogSize) by

adb shell setprop persist.audio.locallog.lines 256

Test: Run piano app and check audioflinger dumpsys
Bug: 30572472
Change-Id: Ie27812b15732432856452e4c46d81abf860aaee2
/frameworks/av/services/audioflinger/AudioFlinger.h
5b4051afc26367d7accd06580c5135c8295759f9 20-Dec-2016 Andy Hung <hunga@google.com> Merge "AudioFlinger: Associate audio time with client uid"
6a308b02f138e358fb239ee2df5d54dd988f34fd 16-Dec-2016 Eric Laurent <elaurent@google.com> Merge "Add unique audio port IDs to AudioTrack and AudioRecord"
dae27707fc7d8370eb200d25d1a7c6dd7ad5e201 31-Oct-2016 Andy Hung <hunga@google.com> AudioFlinger: Associate audio time with client uid

Group active track operations for add and remove together.
PlaybackThread now uses strong pointer for active tracks.

Test: Play Music, Youtube, Batterystats, CTS AudioTrack
Bug: 32361950
Change-Id: I101df081dd8d090560a83c44c2fa9ffcbf39c84d
/frameworks/av/services/audioflinger/AudioFlinger.h
20b9ef0b55c9150ae11057ab997ae61be2d496ef 05-Dec-2016 Eric Laurent <elaurent@google.com> Add unique audio port IDs to AudioTrack and AudioRecord

This will allow to track activity at the track level instead of
at audio session level as only possible with current implementation.

AudioTracks and AudioRecords will receive a unique audio port ID the
first time they register to audio policy with
getOutputForAttr()/getInputForAttr() and keep this ID for their
lifetime.

This CL is the first partial change and just updates the
audio policy and audio flinger APIs used at track creation time.

Test: basic regression test of audio playback and capture use cases

Change-Id: I8d612e67738e120494f61e3f7c60bfd0b2c6a329
/frameworks/av/services/audioflinger/AudioFlinger.h
b643627a557e44b9ab5879cf71e162af2d514ce3 08-Dec-2016 Eric Laurent <elaurent@google.com> fix client pid for effects applied by audio policy

Test: Hangouts call, Play Music with and w/o effects

Change-Id: Ia9b20f94be667dd92e0497f8ef9c0dc0e95afe28
/frameworks/av/services/audioflinger/AudioFlinger.h
abf6ff26df459d991cdbc2dca3b78046c97469db 03-Dec-2016 Andy Hung <hunga@google.com> Merge "Log audio information to ensure complete delivery"
0d5a2ed0a05a2bf337c68edb54f24c60e18032c1 02-Dec-2016 Eric Laurent <elaurent@google.com> improve audio effect framwework thread safety

- Reorganize handle effect creation code to make sure the effect engine
is created with both thread and effect chain mutex held.
- Reorganize handle disconnect code to make sure the effect engine
is released with both thread and effect chain mutex held.
- Protect IEffect interface methods in EffectHande with a Mutex.
- Only pin effect if the session was acquired first.
- Do not use strong pointer to EffectModule in EffectHandles:
only the EffectChain has a single strong reference to the EffectModule.

Test: Tested with EffectTest app. Regression tests in main audio use cases.

Bug: 32707507
Change-Id: Ia1098cba2cd32cc2d1c9dfdff4adc2388dfed80e
/frameworks/av/services/audioflinger/AudioFlinger.h
2148bf0e79c436b8764b9edc4c8f2730cce98a32 29-Nov-2016 Andy Hung <hunga@google.com> Log audio information to ensure complete delivery

Test: Audio playback
Bug: 30572472
Change-Id: Ibad6fc202692cd3480ae726627252afdead083f3
/frameworks/av/services/audioflinger/AudioFlinger.h
913d06c099bd689375483a839e11057ccf284d1c 01-Nov-2016 Mikhail Naganov <mnaganov@google.com> Move TypeConverter into a shared library

This will be needed for the default implementation of the audio HAL
in TREBLE for parsing supported formats etc. provided by HAL in
a form of string literals.

As a bonus, remove some hand-written type conversions in AudioFlinger
used in dumps.

Example changes in the dump output:

HAL format: 0x1 (pcm16) ==> HAL format: 0x1 (AUDIO_FORMAT_PCM_16_BIT)
Processing format: 0x5 (pcmfloat) ==> Processing format: 0x5 (AUDIO_FORMAT_PCM_FLOAT)
Output device: 0x2 (SPEAKER) ==> Output device: 0x2 (AUDIO_DEVICE_OUT_SPEAKER)
Input device: 0 (NONE) ==> Input device: 0 (AUDIO_DEVICE_NONE)
AudioStreamOut: 0x... flags 0x6 (PRIMARY|FAST) ==>
AudioStreamOut: 0x... flags 0x6 (AUDIO_OUTPUT_FLAG_PRIMARY|AUDIO_OUTPUT_FLAG_FAST)

Test: make & run
Change-Id: I9cde640e6827b7aa6d62e9caade9e738227e299f
/frameworks/av/services/audioflinger/AudioFlinger.h
61a4fac2e3ec271241e3a4f405d7357b7f6ca4c2 13-Oct-2016 Mikhail Naganov <mnaganov@google.com> Remove dependencies on hardware/audio_policy.h

Most of the time it's not needed, may be needed when
USE_LEGACY_AUDIO_POLICY is enabled.

Test: make

Change-Id: Id25eafc05352f07614965913d367d484f2673fbd
/frameworks/av/services/audioflinger/AudioFlinger.h
cbc8f617c1aebef5d041fa40dcd38a5466690b99 12-Oct-2016 Mikhail Naganov <mnaganov@google.com> Eliminate dependencies on hardware/audio.h (trivial cases)

frameworks/av must not depend on hardware/ (except for the code
from libaudiohal that actually calls into HAL).

This CL deals with simple cases where depending on system/audio.h
is enough.

Change-Id: Ia2cb66cc8c92316ce5ab884a008d5e531263c2e4
Test: make
/frameworks/av/services/audioflinger/AudioFlinger.h
a0c91339814f37ea78365afb436c9f3d1f0a0090 19-Sep-2016 Mikhail Naganov <mnaganov@google.com> Update NBAIO to use the new audio HAL abstraction layer

Moved the HAL access abstraction layer to a separate library so it
can be used both by audioflinger and libnbaio.

Bug: 30222631
Test: manual with Loopback app, Hangouts, YouTube

Change-Id: Id622c2f1aa8f55a775d34f369a596c2c4d29d5be
/frameworks/av/services/audioflinger/AudioFlinger.h
1dc98674f701dada94143b4d31b7221c58346c6c 19-Aug-2016 Mikhail Naganov <mnaganov@google.com> Abstract away access to audio streams HAL in AudioFlinger

In this CL all direct access to audio_stream_t, audio_stream_out_t, and
audio_stream_in_t their functions is encapsulated within the new
hierarchy of Stream[In|Out]HalLocal classes. AudioFlinger uses
interface classes Stream[In|Out]HalInterface to access these functions.

Note that NBAIO still receives raw HAL stream handles and needs to be
converted separately.

Bug: 30222631
Test: manual with Loopback app

Change-Id: I6388cfa2006791c9c0aa7bb186719209726a2d48
/frameworks/av/services/audioflinger/AudioFlinger.h
e4f1f63a2c54ee8687ad8cca18df0f6639ad7c81 31-Aug-2016 Mikhail Naganov <mnaganov@google.com> Abstract away access to audio devices HAL

In this CL all direct access to audio_hw_device_t and its functions is
encapsulated within the new class DeviceHalLocal. Loading of hardware
modules is encapsulated withing DevicesFactoryHalLocal. AudioFlinger
uses interface classes DevicesFactoryHalInterface and DeviceHalInterface
to access these functions.

Bug: 30222631
Change-Id: Ic88b20c55813a24b898f4a832e082c17d81935b7
/frameworks/av/services/audioflinger/AudioFlinger.h
598857bdcfc99e8afc597ea815a9b93aa81fe0c4 31-Aug-2016 Andy Hung <hunga@google.com> AudioFlinger: Disable (revert) LockWatch am: deb0335714 am: d8d2728947 am: 5d819b4794
am: 9b7a8f9461

Change-Id: I1840bd725020242337af910ea3f51cd094e3c937
9b7a8f94619b6847db7dc37deb5918b6f3439a43 31-Aug-2016 Andy Hung <hunga@google.com> AudioFlinger: Disable (revert) LockWatch am: deb0335714 am: d8d2728947
am: 5d819b4794

Change-Id: I4754604909ec4658aa3d12e70dbb735e34955901
deb0335714cabc906098fb1d971d992027267fc6 29-Aug-2016 Andy Hung <hunga@google.com> AudioFlinger: Disable (revert) LockWatch

Revert "audioflinger: add watchdog on main mutex"
This reverts commit 17a58b2560c38a8e31a38186f9ab6eb98a38e229.

Revert "LockWatch: Update to Mutex::timeLock specs"
This reverts commit 51a6319111df875710dab25a1a99b10d002c4869.

Bug: 30936184
Change-Id: I0f6df6c98c06e161038b1bf0aae5912619cb4066
/frameworks/av/services/audioflinger/AudioFlinger.h
4a3d5c23f79189eb7ab9f31c440c7da5b15947a2 15-Aug-2016 Mikhail Naganov <mnaganov@google.com> Abstract away access to audio effects HAL and factory

In this CL all direct calls to functions from EffectsFactoryApi.h
and hardware/audio_effect.h are encapsulated within two new
classes: EffectsFactoryHalLocal and EffectHalLocal. AudioFlinger
uses interface classes EffectsFactoryHalInterface and
EffectHalInterface to access these functions.

Bug: 30222631
Change-Id: Id64b9c5529319077f6f968921489a13f60daa977
/frameworks/av/services/audioflinger/AudioFlinger.h
82f5b811b2767289ebb8a9e6af1919c3b72b5121 17-Aug-2016 Eric Laurent <elaurent@google.com> DO NOT MERGE ANYWHERE (nyc-dr1-dev) audioflinger: add watchdog on main mutex

Check every 10 seconds if main audioflinger mutex can be acquired and
trigger audioserver process restart if not.
This will allow to capture tombstones of locked up situations and avoid
the disruption of a system_server restart.

Bug: 30737845
Bug: 30388410
Change-Id: I8a78b8cf813982f70ea598a6d42affc0ecaa76c9
(cherry picked from commit 17a58b2560c38a8e31a38186f9ab6eb98a38e229)
/frameworks/av/services/audioflinger/AudioFlinger.h
85d5dffa0a8f523bd577296c3759479f7db2ddec 18-Aug-2016 Eric Laurent <elaurent@google.com> audioflinger: add watchdog on main mutex am: 17a58b2560
am: ed31582734

Change-Id: I9d5d0573220ba5811d06f2aa2217919a68d8529b
17a58b2560c38a8e31a38186f9ab6eb98a38e229 17-Aug-2016 Eric Laurent <elaurent@google.com> audioflinger: add watchdog on main mutex

Check every 10 seconds if main audioflinger mutex can be acquired and
trigger audioserver process restart if not.
This will allow to capture tombstones of locked up situations and avoid
the disruption of a system_server restart.

Bug: 30737845
Bug: 30388410
Change-Id: I8a78b8cf813982f70ea598a6d42affc0ecaa76c9
/frameworks/av/services/audioflinger/AudioFlinger.h
5ca8f32280377dd923e72c3c6bd3994217461b8b 11-Aug-2016 Chih-Hung Hsieh <chh@google.com> resolve merge conflicts of fd923e7 to stage-aosp-master am: df5d9246f9
am: 63ef5a38f8

Change-Id: I516a43c5e56323e99ad7a8ca2e4811b77c9704f4
df5d9246f9607b1c2f8b134c46a05af06e206da3 11-Aug-2016 Chih-Hung Hsieh <chh@google.com> resolve merge conflicts of fd923e7 to stage-aosp-master

Change-Id: I75b44b89bae41197a1fd68362d20b8ba2b4dd192
36d0ca16024820df9a12903d2ac443fabcc180bc 09-Aug-2016 Chih-Hung Hsieh <chh@google.com> Fix clang-tidy warnings in audio and playerservice.

* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1

Change-Id: I265f3b094e08d5705b506b3fbba51439c134af84
Merged-In: I265f3b094e08d5705b506b3fbba51439c134af84
/frameworks/av/services/audioflinger/AudioFlinger.h
a73356393315ad3ad7cd9196640823d1a9a620dd 10-Jun-2016 Glenn Kasten <gkasten@google.com> getPrimary APIs now examine all non-duplicating output threads

and return the value corresponding to the thread with minimum frame count,
with a preference for a thread with fast mixer if there are multiple
output threads with the same minimum frame count.
This is in keeping with the expectation by apps that the getPrimary APIs
will return a value for the lowest available latency path.

Bug: 29164107
Change-Id: I8ae9bcad2d48185d7717ccf96085834c0ce00e37
/frameworks/av/services/audioflinger/AudioFlinger.h
050677873c10d4da308ac222f8533c96cca3207e 02-Jun-2016 Eric Laurent <elaurent@google.com> Add AudioTrack and AudioRecord flag checks

Verify that the requested flags are compatible with the input
or output flags when creating and AudioRecord or AudioTrack

Get rid of IAudioFlinger::track_flags_t which was redundant
with audio_input_flags_t and audio_output_flags_t.

Change-Id: I0dd9232f857b2737e99a8c668806e45bce09cdbd
/frameworks/av/services/audioflinger/AudioFlinger.h
9ea77cdba8c422940adb57a790b44ac04fe0353f 07-Apr-2016 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: Pass pid of process creating track or opening record

AudioFlinger allocates a Client heap for each unique pid.
If two applications use mediaplayer APIs, the same Client heap
is reused as the pid used is not the application pid but that
of mediaserver. With this change, the pid of the application
pid is used to decide the heap to be used.

Bug: 23525542
Bug: 28772898
Change-Id: I31a695b0b321eff6e2aca80c3bc4aeb3e1cd9ac7
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
d2e67e1ef59921101fd7b047e2acf84e5d16d66e 11-Apr-2016 Glenn Kasten <gkasten@google.com> Reduce rollovers of unique ID generator

Bug: 28119934
Change-Id: I6c57d5555f6c5ddc4d4eee1e6f27fc4aaeb31c83
/frameworks/av/services/audioflinger/AudioFlinger.h
9d003131329450081c8129b3fddd85cf20d2d9d9 06-Apr-2016 Glenn Kasten <gkasten@google.com> Check newAudioUniqueId() parameter 'use'

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

Bug: 27562099
Change-Id: I328d8226191386b163f2ace41233607294c50dcd
/frameworks/av/services/audioflinger/AudioFlinger.h
7fd0422fbd17af3b24eb04421d37fce50f3826e2 02-Feb-2016 Glenn Kasten <gkasten@google.com> Sample rate 0 means a route-dependent rate

Remove check for primary _output_ [sic] sampling rate for fast capture.
Clean up AudioRecord handling of frame count and sample rate.
Clean up AudioTrack handling of notification period updates.
Make AudioRecord and AudioTrack more similar in order of operation, comments, and whitespace.

Bug: 25641253
Bug: 21019153
Change-Id: I24a6677945987fc39a9bf93f70357e4bc7410f98
/frameworks/av/services/audioflinger/AudioFlinger.h
2c073da0f02c3cf7cd4795af2d861222cbcab72a 26-Feb-2016 Glenn Kasten <gkasten@google.com> AudioSystem::getSamplingRate and getFrameCount now work for input

Also fix whitespace and comment in AudioIoDescriptor.

Bug: 25641253
Bug: 21019153
Change-Id: I6a1e2262f44f87ec3ebce6e5274f45ed0f47eb13
/frameworks/av/services/audioflinger/AudioFlinger.h
eeecb980ff4c202d0a3c4b0bfe040dce2f73336d 26-Feb-2016 Glenn Kasten <gkasten@google.com> Add use for audio_unique_id_t

Bug: 25641253
Bug: 21019153
Change-Id: I65dc128e760c245f3d90559635a8981b186c87d7
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
d79072e9dff59f767cce2cda1caab80ce5a0815b 06-Jan-2016 Glenn Kasten <gkasten@google.com> Remove TimedAudioTrack and associated code

Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
/frameworks/av/services/audioflinger/AudioFlinger.h
cb4432af8dc3abc8dc4cc8e5d6080cc68a862ea1 16-Dec-2015 Glenn Kasten <gkasten@google.com> Use FCC_2 and FCC_8 to highlight channel count assumptions

Bug: 21656069
Change-Id: I7678adaac2c4cb429465e2eef03c1c711e550e99
/frameworks/av/services/audioflinger/AudioFlinger.h
aba407f1a6378ac2518d0d76d0d18419b7722a81 21-Aug-2015 Eric Laurent <elaurent@google.com> audioflinger: increase shared memory heap size

Bug: 21093153.
Change-Id: I389af11451b01ce49fdb8957e2f322ba1925a62e
(cherry picked from commit da73b6c7474aaa5616f0214e238776f12717f32b)
/frameworks/av/services/audioflinger/AudioFlinger.h
da73b6c7474aaa5616f0214e238776f12717f32b 21-Aug-2015 Eric Laurent <elaurent@google.com> audioflinger: increase shared memory heap size

Bug: 21093153.
Change-Id: I389af11451b01ce49fdb8957e2f322ba1925a62e
/frameworks/av/services/audioflinger/AudioFlinger.h
eb9487e10294a4e73977f460f30eeaff503acd21 22-Jul-2015 Glenn Kasten <gkasten@google.com> Fix capture overruns at non-primary sample rate

and small buffer size. Also:
Pull out the magic number "12 ms" to a named constant.
Remove obsolete AudioFlinger::mPrimaryOutputSampleRate.

Bug: 22662814
Change-Id: I261f75a222c4505a84aad2493d251bd2dea59f68
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
748a792be85838c429ebf46acf7d6eb02e79f00b 21-May-2015 Eric Laurent <elaurent@google.com> Merge "audio flinger: do not call JAVA services until system is ready" into mnc-dev
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/AudioFlinger.h
64b6cb2cd5646a5ffcdb2cccee09a170ef2882d5 19-May-2015 Andy Hung <hunga@google.com> Allow creation of output endpoints with channel index masks

Bug: 21301523
Change-Id: I97e578f3da933f7086e4f431a199ed907f04cbc8
/frameworks/av/services/audioflinger/AudioFlinger.h
9f578d3297782be6de5373e171f3b4af49726709 05-May-2015 Jean-Michel Trivi <jmtrivi@google.com> Merge "AudioRecord keeps track of UID" into mnc-dev
4cb668392ee0433462251afbee109405c6efacc8 02-May-2015 Jean-Michel Trivi <jmtrivi@google.com> AudioRecord keeps track of UID

Bug 20832981

Change-Id: If5f3c61fae02d86b9d6fdf411711f854fd56c77d
/frameworks/av/services/audioflinger/AudioFlinger.h
cc85abcf4ac398dca240db356b8b4db052b415a4 01-May-2015 Eric Laurent <elaurent@google.com> Merge "AudioSystem: refactor audio config cache and callbacks" into mnc-dev
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/AudioFlinger.h
850206ed9ebc6c663a957a656966bce2604dc170 01-May-2015 Eric Laurent <elaurent@google.com> Merge "PatchPanel: do not use setParameters() internally." into mnc-dev
be71aa29a3c86d2e01cd17839d2a72ab09a1bce5 28-Apr-2015 Svet Ganov <svetoslavganov@google.com> Respect the record audio app op - media

Change-Id: I3a97977b6e9a09355e2008f780d22d480fb7308b
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
d330ee46022f34da76d14d0c4d2910526ecc2321 20-Apr-2015 Andy Hung <hunga@google.com> Add floating and multichannel record to AudioFlinger

Change-Id: Ia388fb012a0b6d81613ef87142a97d76836338f9
/frameworks/av/services/audioflinger/AudioFlinger.h
062e67a26e0553dd142be622821f493df541f0c6 11-Feb-2015 Phil Burk <philburk@google.com> AudioFlinger: call SPDIF wrapper from AudioFlinger

Create an interface layer between the AudioFlinger and the HAL
that manages the wrapping and format conversion.

Removed unnecessary includes.
Handle rate conversion in getRenderPosition().
Try to open HAL with encoded format before wrapping with SPDIF.

Bug: 17566660
Change-Id: I00ad888ca15ff0f85b85efb8167c7f5ea761a244
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
0f5b562737d6b5457aa83a4fdce9c6fb32584d9d 18-Feb-2015 Glenn Kasten <gkasten@google.com> Add devicesToString, inputFlagsToString, and sourceToString

Change-Id: I0c09d76c204ffc5579f62d2ed1faef07922a5962
/frameworks/av/services/audioflinger/AudioFlinger.h
63238efb0d674758902918e3cdaac322126484b7 03-Mar-2015 Glenn Kasten <gkasten@google.com> Remove redundant semicolon from namespace closing

Change-Id: I163f9d3d216c283ae1160ce4802e5247cf44fba7
/frameworks/av/services/audioflinger/AudioFlinger.h
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/AudioFlinger.h
fa90e84ed0cb2abdc0e0873a06d10ccf2b3c34f6 18-Oct-2014 Eric Laurent <elaurent@google.com> audioflinger: new HW A/V sync ID allocation flow

The HW A/V sync ID is now allocated by the audio HAL before the
output stream is created by a call to global get_parameters() with
key AUDIO_PARAMETER_HW_AV_SYNC.

When the AudioTrack is created, the HW A/V sync ID is communicated
to the output stream by stream set_parameters() with key
AUDIO_PARAMETER_STREAM_HW_AV_SYNC.

Bug: 17112525.
Change-Id: Ia8bc6f3bf9f358aa89f3f56ac554e893a19811ad
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
0912a5738d6baf2df7cd62e877240e3807b4b21f 08-Aug-2014 Andy Hung <hunga@google.com> Merge "Fix effect and mono sink handling." into lmp-dev
389cfdbb9a92a438a0d7710321c2964c7ad55eca 08-Aug-2014 Andy Hung <hunga@google.com> Fix effect and mono sink handling.

Do not permit mixing to mono sink in AudioFlinger.
Allow effects on mono sink if not Mixer thread (e.g. Record).

Bug: 16863095
Change-Id: I8b232fc1fb3f07bf017020c5d4f9ace644dec6d8
/frameworks/av/services/audioflinger/AudioFlinger.h
93c3d41bdb15e39dac0faea9c5b60f1637cd477c 01-Aug-2014 Eric Laurent <elaurent@google.com> AudioSystem: add API to query audio HW sync source

Add a method to query from the audio HAL the HW sync
source used for a given audio session.
Modify audio policy to select a direct output with HW sync
when requested.

Bug: 16132368.

Change-Id: I03038f9188f2d389f8a5fd76a671854013a4513e
/frameworks/av/services/audioflinger/AudioFlinger.h
318be3e7d245aea99efa194a16002395b609ab90 30-Jul-2014 Andy Hung <hunga@google.com> Merge "Enable multichannel in AudioFlinger" into lmp-dev
b1ee3954153e9c40280f68d278526ca43c31fdcf 29-Jul-2014 Andy Hung <hunga@google.com> Enable multichannel in AudioFlinger

Change-Id: Ibdbdc6ea0b87cdcd15432257a3455b11b3ce14b7
/frameworks/av/services/audioflinger/AudioFlinger.h
de3f8392fbf380ba6f09d009b00d7172477389a2 28-Jul-2014 Eric Laurent <elaurent@google.com> rename AudioSystem::newAudioSessionId()

Rename AudioSystem::newAudioSessionId() to
AudioSystem::newAudioUniqueId() as it can be used
also for I/O handles.

Bug: 12378680.
Change-Id: I611ea3b5eb57a4b0774437f477ee87dc4ccc2cc2
/frameworks/av/services/audioflinger/AudioFlinger.h
cf2c0210c8afbe7d0661ccbbae3835b5ce73c0bf 26-Jul-2014 Eric Laurent <elaurent@google.com> AudioFlinger: update openInput() and openOutput()

Add parameters to openInput() and openOutput(): device address,
input source.
Allow caller to specify a given I/O handle
Group parameters in a struct audio_config.

Bug: 12378680.
Change-Id: I7e9af74c0d996561cc13cbee7d9012d2daf33025
/frameworks/av/services/audioflinger/AudioFlinger.h
9a59276fb465e492138e0576523b54079671e8f4 22-Jul-2014 Andy Hung <hunga@google.com> Add multichannel capability to AudioFlinger

But not enabled (kEnableExtendedChannels == false).

Change-Id: I62f7e31fbd29ad703a9a02f5d1a280b6972dd423
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
ec40d284218466d8f0e832e7eb88e6ea6c479c88 16-Jul-2014 Glenn Kasten <gkasten@google.com> Add audio_input_flags_t to IAudioFlinger::openInput

For backward compatibility, until flags are correctly calculated,
we will assume that the request is for a low latency input stream.

Change-Id: I76746834e870df00833dc77cbdaa2edd2ffeec95
/frameworks/av/services/audioflinger/AudioFlinger.h
a494e82c3c73508b4d3cfe89e9134de94e12fd31 09-Jul-2014 Andy Hung <hunga@google.com> Enable extended precision PCM output in AudioFlinger

Change-Id: I7c0907c7b2369681975d8ea0192b722d7ed7a867
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
5ba4440c11eb975ec0e104e0af1981838f42f57c 04-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete IAudioFlinger::channelCount()"
6146c08f0c3dd8b9e5788063aa433f304a810602 18-Mar-2014 Andy Hung <hunga@google.com> Add enabling variable for extended precision audio

Set AudioFlinger::kEnableExtendedPrecision = true to enable
extended precision. Enabling will be required for devices (such as
USB) which report 24 bit or 32 bit sink formats.

Change-Id: I0dc1d7a4f7607086d7b536ea0e43aef0e696f2ee
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
4ea00a25cf85877b48ebd1e15a657cfaab29af58 02-Jun-2014 Glenn Kasten <gkasten@google.com> Add mPrimaryOutputSampleRate

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

Change-Id: Ie623edae2e795f9155f1f452fe4e6c7217a4a4c8
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
4b123406c10c17852734a1b691bb9ce2a4cb7caf 11-Apr-2014 Eric Laurent <elaurent@google.com> IAudioFlinger interface extension for patch panel

Change-Id: Iaabe0a7e315d5725e00a74a6ed40339b98f20330
/frameworks/av/services/audioflinger/AudioFlinger.h
c56f3426099a3cf2d07ccff8886050c7fbce140f 22-Mar-2014 Glenn Kasten <gkasten@google.com> Pass stereo gains as packed minifloat

This will allow (eventually) a greater dynamic range for gains.
However there are still a few remaining places in effects and mixer
that will also need to be changed in order to get the full benefit.

Also fixes a minor bug: was not checking for NaN in AudioTrack C++.

Change-Id: I63bce9e82e0a61546d8ff475fb94bcb700d99c96
/frameworks/av/services/audioflinger/AudioFlinger.h
cbe6fddebe3ec84176037de7f9681d2407fa1113 14-May-2014 Glenn Kasten <gkasten@google.com> Merge "Explicitly include Configuration.h"
5b17c0b5b418c340d3e5201a72ee8c88c1755355 13-May-2014 Glenn Kasten <gkasten@google.com> Explicitly include Configuration.h

Must include Configuration.h in any source file with #ifdef or #if that
depends on Configuration.h. This avoid inconsistencies that could result
in subtle bugs.

Change-Id: I99fdf19d56e7c73de4e7d672b937336b932a2a00
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
0fdbdd2a3909e4692fa3baaaa1f53eb91b31af56 10-May-2014 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete IAudioRecord::getCblk()"
26d5ff926fa3323b39ae4408bcd29826a9523c9b 10-May-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: refactor thread config events"
fe9570c7b937b49d3603ccb394aed732b79bc6be 07-May-2014 Glenn Kasten <gkasten@google.com> Remove obsolete IAudioRecord::getCblk()

Change-Id: Id20b5efd765b9796b0e391610e06dc928a829ebf
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
d776ac63ce9c013c9626226e43f7db606e035838 07-May-2014 Glenn Kasten <gkasten@google.com> IAudioFlinger::openRecord returns IMemory(s)

openRecord() now explicitly returns the control block and data buffer
as separate IMemory references. If the IMemory for data buffer
is 0, this means it immediately follows the control block.

Change-Id: Ic098f88f0e037f8fbe30006689e18cacacf09d06
/frameworks/av/services/audioflinger/AudioFlinger.h
bcefec31bd1346133052356ffc8d7ac8a5b13fab 17-Jan-2014 Glenn Kasten <gkasten@google.com> Document AudioFlinger::nextUniqueId()

Change-Id: Iafe96f1c10bd85cb23a2553945ca68aa601dc2eb
/frameworks/av/services/audioflinger/AudioFlinger.h
c5a17425986b4ce3384e6956762c86018b49c4a0 13-Mar-2014 Glenn Kasten <gkasten@google.com> Remove name output parameter from createTrack

It was only used for one log.
A better solution will be a per-track unique ID.

Change-Id: Ia440e02ae4a5a4019a9a2d08970e1ee93ac4c3a3
/frameworks/av/services/audioflinger/AudioFlinger.h
d2304db2fcb5112292105a0949a55986a4c9875f 03-Feb-2014 Glenn Kasten <gkasten@google.com> Rename setStreamOutput to invalidateStream

And simplify by removing the unused I/O handle parameter 'output'.

Change-Id: Ie9c4df17a7378066312d4ed8790fda7a9125c95e
/frameworks/av/services/audioflinger/AudioFlinger.h
d0e0cfa58a35508c14818b88804845194b5d80e1 22-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Make tee sink work again"
f66b42242342017c26eb97de544dae31dd2537ca 20-Feb-2014 Glenn Kasten <gkasten@google.com> Make tee sink work again

It was broken by this earlier change to NBAIO:
> Change-Id: I5eda412648b094358f5eefc38300e9ec8a734cd3
But the code was not being compiled, so the error was not caught earlier.

Also increase the default size of per-track pipe to a reasonable value.

Change-Id: Ica05017e6c6533e1fea9df379a9b204eebed4a1f
/frameworks/av/services/audioflinger/AudioFlinger.h
8ea16e4b0a7d398d26887c18675b3899de5d779d 21-Feb-2014 Eric Laurent <elaurent@google.com> audioflinger: fix race condition in SyncEvent callback

Now that the SyncEvent callback is implemented by the
RecordTrack instead of the RecordThread, there is a possibility
that the callback is called after the track deletion.

SyncEvent callback now uses a weak pointer instead of
a raw pointer as cookie. This allows the callback implementer to
acquire a strong reference on the object pointed to by the cookie.

Bug: 13114128.
Change-Id: Id61b8f06044ed1e52c6f7e7c666cdede68340de2
/frameworks/av/services/audioflinger/AudioFlinger.h
d457c970c8d08519cd77280a90b61ae1e342cfe3 11-Feb-2014 Marco Nelissen <marcone@google.com> Track pid for each session

so they can be properly freed.

Change-Id: I6f389035bc29e74e7c367c1c6d0252b180f666b3
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
b1f5b0dd237c2767ad7bc0b081d03aafc87589ea 10-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix clang warnings in AudioFlinger"
01d3acba9de861cb2b718338e787cff3566fc5ec 06-Feb-2014 Glenn Kasten <gkasten@google.com> Fix clang warnings in AudioFlinger

Change-Id: I0fa61025c979709ad7d655bc717df5f194b6089e
/frameworks/av/services/audioflinger/AudioFlinger.h
b220884bf3129253cc5bc8d030bc475411ea4911 07-Feb-2014 Marco Nelissen <marcone@google.com> Pretty up audioflinger dumpsys

Change-Id: I57e44b4c36b99f7149542bbcf9645521c6152dfa
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.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/AudioFlinger.h
481fb67a595f23c5b7f5be84b06db9b84a41a42f 30-Sep-2013 Glenn Kasten <gkasten@google.com> Add RecordThread media.log and deferred deallocation

This change allows a media.log buffer for RecordThread.

Unlike playback threads which stick around forever, the RecordThread comes
and goes for every capture session. This means that the media.log buffer
for a RecordThread would disappear too, and so was useless. Now when a
thread exits, it's associated media.log buffer is just marked for deferred
deallocation. It is only actually freed when the memory is needed.

Other changes:
- Fix bug in unregistering comparison, it was comparing the wrong pointers
- Increased size of log area so we can log for RecordThread also

Change-Id: If45d4c03a793b86390a0112ec3acc5d41b2e3635
/frameworks/av/services/audioflinger/AudioFlinger.h
b2737d0b33c17e408d96d6f9eeaa3381479c94c7 19-Aug-2013 Glenn Kasten <gkasten@google.com> Use const more places

Change-Id: Ibc068d319d6fff26f2d11248e17481d8f7f027e0
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.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/AudioFlinger.h
34717c83733def81287e2b4ba2f62b416325c7ae 02-Oct-2013 Eric Laurent <elaurent@google.com> am 3424d6e1: am 1adf20ce: Merge "fix volume and effect enable delay on offloaded tracks" into klp-dev

* commit '3424d6e17637e0743ddf3bf4688af8ee36e69264':
fix volume and effect enable delay on offloaded tracks
59fe010bcc072597852454a2ec53d7b0a2002a3b 28-Sep-2013 Eric Laurent <elaurent@google.com> fix volume and effect enable delay on offloaded tracks

Volume: add a method to wake up the mediaserver playback
thread when a volume command is received on an offloaded track.

Effects: call effect chain process on offloaded playback threads
asynchronously from writes to allow effect state updates while
waiting for async write callback.

Bug: 10796540.

Change-Id: Id2747ae88783575d1d7ffd6fc86fbd054ab2c739
/frameworks/av/services/audioflinger/AudioFlinger.h
dc8cae8c118e4aef4ef1f7b2c6f79becc1df4a05 18-Sep-2013 Eric Laurent <elaurent@google.com> am bf5e2397: am 5baf2af5: more support for audio effect offload

* commit 'bf5e23979a03da96ce1d63126c480103232f174b':
more support for audio effect offload
5baf2af52cd186633b7173196c1e4a4cd3435f22 13-Sep-2013 Eric Laurent <elaurent@google.com> more support for audio effect offload

Offloading of audio effects is now enabled for offloaded
output threads. If an effect not supporting offload is enabled,
the AudioTrack is invalidated so that it can be recreated in PCM
mode.

Fix some issues in effect proxy related to handling of effect
commands to offloaded and non offloaded effects.

Also fixed a bug on capture index in software Visualizer effect.

Bug: 8174034.

Change-Id: Ib23d3c2d5a652361b0aaec7faee09102f2b18fce
/frameworks/av/services/audioflinger/AudioFlinger.h
8136cfae9c22ae8ff42eec9ed751833dda605444 09-Sep-2013 Eric Laurent <elaurent@google.com> am 8a910716: am 6ca83fad: Merge "audioflinger: no effects on offloaded tracks" into klp-dev

* commit '8a910716892d17a2ac62c7e9884af0e9d75b26bc':
audioflinger: no effects on offloaded tracks
813e2a74853bde19e37d878c596a044b3f299efc 31-Aug-2013 Eric Laurent <elaurent@google.com> audioflinger: no effects on offloaded tracks

Invalidate offloaded tracks when an effect is enabled
so that the track is recreated in PCM mode and the effect
can be applied.
This is temporary until effect offloading is implemented.

Bug: 8174034.

Change-Id: I77b8b54a10db6cb8334be76d863ea7e720eaad09
/frameworks/av/services/audioflinger/AudioFlinger.h
ec9ad1b0947f5d6b465281312dbe92f096a8f881 30-Aug-2013 Glenn Kasten <gkasten@google.com> am f94b2946: am 56b59224: Merge "Add IAudioTrack::getTimestamp()" into klp-dev

* commit 'f94b2946a511c5cbb6b9001449ca8278cb332bda':
Add IAudioTrack::getTimestamp()
53cec22821072719ee02c856e9ac2dda2496c570 29-Aug-2013 Glenn Kasten <gkasten@google.com> Add IAudioTrack::getTimestamp()

with dummy implementation in AudioFlinger::TrackHandle, and
implement AudioTrack::getTimestamp() using IAudioTrack.

Also document invariant that mAudioTrack and control block are always
non-0 after successful initialization.

Change-Id: I9861d1454cff7decf795d5d5898ac7999a9f3b7e
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
eeca32671896739e84050da5992d5f151a1629de 01-Aug-2013 Glenn Kasten <gkasten@google.com> IAudioFlinger::openRecord track_flags_t flags is in/out

This will allow AudioFlinger to tell client it is denying a request.

Change-Id: Iff2be3ad6636371bbda9c9899a283c94620c1f06
/frameworks/av/services/audioflinger/AudioFlinger.h
d054c32443a493513ab63529b0c8b1aca290278c 12-Jul-2013 Glenn Kasten <gkasten@google.com> Move control block mName to createTrack() output

This is part of a series of CLs to clean up the shared memory
control block, by removing any fields that don't have to be there.

Change-Id: I6e51003a1293b6800258c31b22cff2eba42162e7
/frameworks/av/services/audioflinger/AudioFlinger.h
3dcd00dddec86a1c5133083ad7ba2265d49c048c 17-Jul-2013 Glenn Kasten <gkasten@google.com> Declare methods in binder opcode order

Change-Id: I5f624b7a51ffe1a17a67c056cf984f74e4c56eac
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
4182c4e2a07e2441fcd5c22eaff0ddfe7f826f61 15-Jul-2013 Glenn Kasten <gkasten@google.com> Use AudioSystem::setLowRamDevice() to configure memory

Bug: 9798886
Change-Id: I9321e3f369f1ed9429ae222e3926ebdeb012b8b0
/frameworks/av/services/audioflinger/AudioFlinger.h
0d61251648b5110bfc33ef5b3d19bbf65db0a7b5 16-Jul-2013 Glenn Kasten <gkasten@google.com> Revert "Fix Audioflinger crash when TeeSink is enabled"

This reverts commit 84e391686d7eced293913d1d7993721224ee0ba1.

Bug: 8834855
Change-Id: I8211ef5ea5d87d97ada115723df31c8057f38ca8
/frameworks/av/services/audioflinger/AudioFlinger.h
ad3af3305f024bcbbd55c894a4995e449498e1ba 25-Mar-2013 Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Public API changes for audio offload support.

NOTE: this does _not_ include all private member variables added
to classes as part of offload support. Only public/protected functions
and stubs functions/variables needed to make the changes buildable.

- isOffloadSupported() added to audio policy service
A stub implementation is required to build, this always returns false
- setParameters() added to IAudioTrack
A stub implementation is required to build, this always returns
INVALID_OPERATION

- CBlk flag for stream end

- Change AudioSystem::getRenderPosition() to take an audio_output_t
so caller can specify which output to query

- Add AudioSystem::isOffloadSupported()
This is fully implemented down to the AudioFlinger function
AudioPolicyServer::isOffloadSupported() which is just a stub
that always returns false.

- Add EVENT_STREAM_END to AudioTrack interface.
STREAM_END is used to signal when the hardware has actually finished
playing all the data it was sent.

- Add event type enumeration to media player interface AudioSink callbacks
so that the same callback can be used to handle multiple types of
event. For offloaded tracks we also have to handle STREAM_END and
TEAR_DOWN events

- Pass audio_offload_info_t to various functions used for opening outputs,
tracks and audio players. This passes additional information about the
compressed stream down to the HAL when using offload.
For publicly-available APIs this is an optional parameter (for some of
the internal and low-level APIs around the HAL interface it is mandatory)

- Add getParameters() and setParameters() API to AudioTrack
Currently dummy implementations.

- Change AudioPlayer contructor so that it takes a set of bitflags defining what
options are required. This replaces the original bool which only specified
whether to use deep buffering.

- Changes to StageFright class definition related to handling tearing-down of
an offloaded track when we need to switch back to software decode

- Define new StageFright utility functions used for offloaded tracks
Currently dummy implementations.

- AudioFlinger changes to use extended audio_config_t.
Fills in audio_offload_info_t member if this info is passed in when
opening an output.

- libvideoeditor changes required to add the new event type parameter
to AudioSink callback functions

- libmediaplayerservice changes required to add the new event type parameter
to AudioSink callback functions

Change-Id: I3ab41138aa1083d81fe83b886a9b1021ec7320f1
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Signed-off-by: Eric Laurent <elaurent@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
9f80dd223d83d9bb9077fb6baee056cee4eaf7e5 19-Dec-2012 Glenn Kasten <gkasten@google.com> New control block for AudioTrack and AudioRecord

Main differences between old and new control block:
- removes the mutex, which was a potential source of priority inversion
- circular indices into shared buffer, which is now always a power-of-2 size

Change-Id: I4e9b7fa99858b488ac98a441fa70e31dbba1b865
/frameworks/av/services/audioflinger/AudioFlinger.h
e762be91c3280d837b1d48455cba90459ced7511 10-May-2013 Mathias Agopian <mathias@google.com> make libaudioflinger symbols visibility hidden

we export only symbols needed by clients of this library.
this saves about 130KB (1/3rd of the lib size)

Change-Id: Id81f3ecb299ee3abc0811915cf6efe87180bf15c
/frameworks/av/services/audioflinger/AudioFlinger.h
831a0055665c3d15ff9c99ad23e5ab2b7346f2ac 07-May-2013 Glenn Kasten <gkasten@google.com> Fix Audioflinger crash when TeeSink is enabled

Bug: 8834855
Change-Id: I54665f16d79901970348a8247d9a354da2990f42
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
da6ef1320d0161b1640dc84d7a9c5a25860c3619 10-Jan-2013 Glenn Kasten <gkasten@google.com> Update tee sink

Implement rotation to reduce long-term storage use.
Implement optional per-track tee.
Dynamically enable at runtime based on property, instead of at compile-time.
Dynamic frame count not yet implemented.

Bug: 8223560
Change-Id: I3706443c6ec0cb0c6656dc288715a02ad5fea63a
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.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/AudioFlinger.h
9e58b552f51b00b3b674102876bd6c77ef3da806 19-Jan-2013 Glenn Kasten <gkasten@google.com> AudioFlinger uses media.log service for logging

Change-Id: Ia0f8204334f6b233f644d897762a18c95d936b4b
/frameworks/av/services/audioflinger/AudioFlinger.h
d5681bc9a38fe4cd1d591e6ae62b9c68fb851041 22-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Start isolating control block accesses in a proxy"
8d6cc842e8d525405c68e57fdf3bc5da0b4d7e87 03-Feb-2012 Glenn Kasten <gkasten@google.com> Remove unnecessary parameter

Just get the parameter on server side

Change-Id: I433a63104dbb257e0d862be2ab61847cb36d1c15
/frameworks/av/services/audioflinger/AudioFlinger.h
e3aa659e9cee7df5c12a80d285cc29ab3b2cbb39 04-Dec-2012 Glenn Kasten <gkasten@google.com> Start isolating control block accesses in a proxy

The proxy object will eventually be the only code that understands the
details of the control block. This should make it easier to change the
control block in the future.

Initial set of control block fields that are isolated:
- sample rate
- send level
- volume

Prepare for streaming/static separation by adding a union to the control
block for the new fields.

Fix bug in handling of max sample rate on a track. It was only checking
at re-configuration, not at each mix.

Simplify OutputTrack::obtainBuffer.

Change-Id: I2249f9d04f73a911a922ad1d7f6197292c74cd92
/frameworks/av/services/audioflinger/AudioFlinger.h
e4756fe3a387615acb63c6a05788c8db9b5786cb 29-Nov-2012 Glenn Kasten <gkasten@google.com> AudioTrack::mute() is unused so remove it

If ever needed again, it could be implemented on client side by forcing
a track volume of 0.

Change-Id: I88a9b4f675b6dca2948549414f9ec2c192d29269
/frameworks/av/services/audioflinger/AudioFlinger.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/AudioFlinger.h
a42ff007a17d63df22c60dd5e5fd811ee45ca1b3 14-Nov-2012 Glenn Kasten <gkasten@google.com> Clean up channel count and channel mask

Channel count is uint32_t.
Remove redundant mask parameter to AudioTrack::createTrack_l()
and AudioRecord::openRecord_l().

Change-Id: I5dc2b18eb609b2c0dc3091994cbaa4628062c17f
/frameworks/av/services/audioflinger/AudioFlinger.h
77035d10a740914313500811b31a90ab948bd267 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix time vs. bytes units bug in getRenderPosition"
b603744e96b07b1d5bf745bde593fb2c025cefcf 14-Nov-2012 Glenn Kasten <gkasten@google.com> Don't use control block frame count after create

This is part of a series to clean up the control block.

Change-Id: I7f4cb05aef63053f8e2ab05b286d302260ef4758
/frameworks/av/services/audioflinger/AudioFlinger.h
26c77556efc30800466b60b3975bc35a70c8c28b 16-Nov-2012 Glenn Kasten <gkasten@google.com> Fix time vs. bytes units bug in getRenderPosition

Rename correctLatency since it requires thread to be locked.
Use size_t for byte and frame counts.

Change-Id: I178fdd18bdb823813b9563927bdff8c0d28ca5a5
/frameworks/av/services/audioflinger/AudioFlinger.h
e33054eb968cbf8ccaee1b0ff0301403902deed6 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use size_t for frame counts

Also fix typo: bufferCount should be frameCount.

Change-Id: Ibed539504db75ef99dc21c8ff1bf2987122063a5
/frameworks/av/services/audioflinger/AudioFlinger.h
60a839204713e0f8258d082af83262b1eb33a6c3 21-Jun-2012 Glenn Kasten <gkasten@google.com> Clean up frame size in AudioTrack and AudioFlinger

TrackBase::mFrameSize, mChannelMask, and mChannelCount are now const.
Use TrackBase::mFrameSize instead of re-calculating frame size.
AudioFlinger only sees 16-bit PCM format, conversion from 8-bit is
now entirely on the client side. Previously a small part of the
responsibility was on server side also.
size_t is unsigned, so use %u in logs.
Fix theoretical bug where TrackBase constructor was over-allocating space
for non-linear AudioTrack or 8-bit PCM AudioRecord (probably benign).

Change-Id: I7cbbba0bf4dba29ea751d8af341ab8e5cbbdc206
/frameworks/av/services/audioflinger/AudioFlinger.h
3b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use uint32_t for sample rate

Change-Id: Ie240b48fb54b08359f69ecd4e5f8bda3d15cbe80
/frameworks/av/services/audioflinger/AudioFlinger.h
22eb4e239fbe9103568147d566d7482e480350b8 07-Nov-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: I85d7d2f6381b251db5695202fec75128883a8662
/frameworks/av/services/audioflinger/AudioFlinger.h
9f2016d9adfb4f88fa0bbfcfa5954f79160db595 13-Nov-2012 Glenn Kasten <gkasten@google.com> Rename TrackBase::mFrameCount to mStepCount

This prepares for adding a new field TrackBase::mFrameCount
with a different meaning.

Change-Id: I6bbe2c59f2a882be57caeec2e2e06f439a0e9e83
/frameworks/av/services/audioflinger/AudioFlinger.h
83a0382dc17364567667a4e6135db43f5bd92efc 12-Nov-2012 Glenn Kasten <gkasten@google.com> Move frame size out of the control block

This is part of a series to clean up the control block.

Change-Id: Ifab1c42ac0f8be704e571b292713cd2250d12a3f
/frameworks/av/services/audioflinger/AudioFlinger.h
b929e417853694e37aba1ef4399f188987b709d9 08-Nov-2012 Glenn Kasten <gkasten@google.com> Move buffers pointer out of the control block

This is part of a series to clean up the control block.

Change-Id: Ie474557db7cb360f2d9a0f11600a68f5a3d46f07
/frameworks/av/services/audioflinger/AudioFlinger.h
864585df53eb97c31e77b3ad7c0d89e4f9b42588 07-Nov-2012 Glenn Kasten <gkasten@google.com> Remove CBLK_DIRECTION from control block flags

This is part of a series to clean up the control block.

Change-Id: I0265fece3247356b585d4d48fbda6f37aea8a851
/frameworks/av/services/audioflinger/AudioFlinger.h
e0b07179a48ee50fda931d2aa1b3c751d167e4d7 07-Nov-2012 Glenn Kasten <gkasten@google.com> Remove CBLK_FAST from control block flags

This is part of a series to clean up the control block.

Change-Id: Ic881a3560d9547cb63fcc0cefec87aa3da480e0d
/frameworks/av/services/audioflinger/AudioFlinger.h
85ab62c4b433df3f1a9826bed1c9bec07a86c750 01-Nov-2012 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
/frameworks/av/services/audioflinger/AudioFlinger.h
d06785bebf7e43d4a011b62a252771373ada910c 30-Sep-2012 Glenn Kasten <gkasten@google.com> Save copy of mic input, disabled by default

Change-Id: I4f5e95a5ddf016530d1b2747a0a5ca0962caabda
/frameworks/av/services/audioflinger/AudioFlinger.h
bf1d047d6759c624139bfe9897dc3062d2e446e2 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up constructor and derivation whitespace"
274c02ee1464d8948913ac70e64e8dbb80f82ad7 10-Jul-2012 Glenn Kasten <gkasten@google.com> Clean up constructor and derivation whitespace

Change-Id: I47d688a9c10c4c3c868accc34102fb402ebcac62
/frameworks/av/services/audioflinger/AudioFlinger.h
dc8a0d75bd7b1343cd65c3c7f6e0f91ca0fa6946 06-Mar-2012 Glenn Kasten <gkasten@google.com> Mark volume fields private

Change-Id: I8ffca0460195263d159aa13015c246122d8556a2
/frameworks/av/services/audioflinger/AudioFlinger.h
2bfc6b42b3733c12485dd51ed95191956abc3e4e 28-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> bug 7253033 clean up before closing an output

An output can only be closed if there is no lock contention that
prevents ThreadBase::exit() from being blocked. If an output
device is waiting for an operation to complete (here a write
in the remote_submix module, because the pipe is full), signal
the module that it's entering the "exiting" state.

Change-Id: I8248add60da543e90c25a4c809866cdb26255651
/frameworks/av/services/audioflinger/AudioFlinger.h
cc0f1cfb69ce8b8985fc2c0984847a06a13ad22d 24-Sep-2012 Glenn Kasten <gkasten@google.com> Implement android.media.AudioManager.getProperty()

Bug: 6635041
Change-Id: I3386a4a6c226bc4eceaf65556119e4fb15f73224
/frameworks/av/services/audioflinger/AudioFlinger.h
896adcd3ae6a1c7010e526327eff54e16179987b 13-Sep-2012 Eric Laurent <elaurent@google.com> audioflinger: send priority request from a thread

When creating a fast AudioTrack, a request is sent to SchedulingPolicyService
to elevate the requesting thread priority. This generates a binder
call into system_server process and to a JAVA service via JNI.
If the thread from which the track was created is in the system_server
process and does not have the "can call java" attribute, a crash occurs because
the binder optimization reuses the same thread to process the returning binder
call and no JNI env is present.

The fix consists in sending the priority change request from the AudioFlinger
mixer thread, not from the binder thread.

This also reverts the workaround in commit 73431968

Bug 7126707.

Change-Id: I3347adf71ffbb56ed8436506d4357eab693078a3
/frameworks/av/services/audioflinger/AudioFlinger.h
fe3156ec6fd9fa57dde913fd8567530d095a6550 11-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Communicate audio session ID to downmixer

The audio downmixer effect might need the audio session Id, pass it
from the track creation in AudioFlinger to the downmix effect
creation in AudioMixer.

Change-Id: I5e29540542ae89cf4a0cdb537b3e67f04442a20a
/frameworks/av/services/audioflinger/AudioFlinger.h
f1c04f952916cf70407051c9f824ab84fb2b6e09 28-Aug-2012 Eric Laurent <elaurent@google.com> audioflinger: changes for new audio devices enums

The ThreadBase class now has a separate member for input
and output devices (mInDevice, mOutDevice).

Only query get_supported_devices() from audio HAL if the function
is exposed and if the audio policy manager did not specify the
audio module to open.

Also fixed bug in AEC preprocessing that would reset
to default output device when an input device was given.

Change-Id: I19d4d06aeb920b068e3ef31e6e6be6345ce5d67a
/frameworks/av/services/audioflinger/AudioFlinger.h
57b2dd1e78af53115985f18d31ec5421c9da947e 01-Sep-2012 Eric Laurent <elaurent@google.com> AudioFlinger: send audio source to audio effects

Added support for EFFECT_CMD_SET_AUDIO_SOURCE audio effect
command to inform preprocessings of current audio source
selection for capture.

Change-Id: Ib2418a9aa8114e8457fe828ecd43b230ed86cdd6
/frameworks/av/services/audioflinger/AudioFlinger.h
c3ae93f21280859086ae371428ffd32f39e76d50 30-Jul-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
/frameworks/av/services/audioflinger/AudioFlinger.h
2dd4bdd715f586d4d30cf90cc6fc2bbfbce60fe0 29-Aug-2012 Glenn Kasten <gkasten@google.com> Move libnbaio out of AudioFlinger

libnbaio is now a separate shared library from AudioFlinger, rather
than a static library used only by AudioFlinger.

AudioBufferProvider interface is now also independent of AudioFlinger,
moved to include/media/

Change-Id: I9bb62ffbc38d42a38b0af76e66da5e9ab1e0e21b
/frameworks/av/services/audioflinger/AudioFlinger.h
106e8a42038f9e90d5ff97f8ab6f1a42258bde9e 02-Aug-2012 Glenn Kasten <gkasten@google.com> const methods

Change-Id: I92e32ee16274c032c9d0ce910676be2a7fa52471
/frameworks/av/services/audioflinger/AudioFlinger.h
ee578c0330319f04a48bccbdb26b53fea0388d04 24-Jul-2012 John Grossman <johngro@google.com> AudioFlinger: Better handling for master volume/mute

(cherry picked from commit 93d906837e0e89aa1d9c913ab2b531b809f9bb9e)

> AudioFlinger: Better handling for master volume/mute
>
> Changes to address bug 6842827.
>
> When a HAL is loaded, cache whether or not the HAL supports
> set_master_volume/mute in the AudioHwDevice structure. Store an
> AudioHwDevice in AudioStream(In|Out) structures instead of just an
> audio_he_device_t. This give threads (PlaybackThreads in
> particular) access to the cached capabilities.
>
> When setting master volume/mute, change the system to always set the
> setting on all HAL which support it and also to set the setting on all
> PlaybackThreads. Change PlaybackThreads to apply the setting at the
> in SW mix stage of the pipeline if its assigned HAL does not support
> the setting, or to ignore the setting of the assigned HAL does support
> it.
>
> Change-Id: Ia14137a30b4c3ee6f2d7ddcc8cba87bf5eec87f4
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: Icb6bc13764e100a2003eb1dee2231132ab287d98
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
d8f178d613821c3f61a5c5e391eb275339e526a9 20-Jul-2012 John Grossman <johngro@google.com> Change audio flinger to user HAL master mute if available

(cherry picked from commit 91de9b56282d126ffb36344266af5fee3cefcfdd)

> Change audio flinger to user HAL master mute if available
>
> Hand merge from ics-aah
>
> > Change audio flinger to user HAL master mute if available: DO NOT MERGE
> >
> > Replicate the pattern used for HAL master volume support to make use
> > of master mute support if the HAL supports it. This is part of the
> > change needed to address bug 6828363. Because of the divergences
> > between ICS and master, this change will need to be merged by hand.
> >
> > Signed-off-by: John Grossman <johngro@google.com>
> > Change-Id: I6d83be524021d273d093bcb117b8f2fe57c23685
>
> Change-Id: I32280582905c969aaec2bb166ec5c61df82d737a
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: I5cd709187221d307fe25c5117ccaadca5f6b197b
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
510a3d6b8018a77683dac466127ffd0af34bef6e 16-Jul-2012 Glenn Kasten <gkasten@google.com> Start adding support for multiple record tracks

Replace single mTrack by vector mTracks.
Destroy record tracks similarly to playback tracks.
Dump all record tracks, in addition to the active record track.

Change-Id: I503f10b51928b6b92698fe1c51a9ddd3215df1f4
/frameworks/av/services/audioflinger/AudioFlinger.h
0ec23ce0d1ff79566c402bc30df3074f6e25a22b 10-Jul-2012 Glenn Kasten <gkasten@google.com> Clean up start() parameters

Document where int is used instead of AudioSystem::sync_event_t
(probably because of a header file dependency).
TrackBase::start() and RecordTrack::start() don't need default parameters.

Change-Id: I82f4a4d078be900f3aa4bd926697e32f5ed68ec8
/frameworks/av/services/audioflinger/AudioFlinger.h
e4e2a37dbe2a4d923232305549101f779a2e3638 23-Jul-2012 Glenn Kasten <gkasten@google.com> Extract methods to enter standby and standby mode

Also move initial standby from to threadLoop to avoid a race condition.

Change-Id: I65afca83c36fb41b983b3b1d3dab35d4029560e3
/frameworks/av/services/audioflinger/AudioFlinger.h
0a7af18d0308295405491f86603e3d119450aba0 10-Jul-2012 Glenn Kasten <gkasten@google.com> Use valueAt instead of editValueAt when possible

Change-Id: I885b169f4b176a6b5c2ca9a534214b4ffff1700e
/frameworks/av/services/audioflinger/AudioFlinger.h
58e5aa34f01d663654d8bafad65db1dda42161ff 20-Jun-2012 Glenn Kasten <gkasten@google.com> effect_descriptor_t const correctness

Change-Id: Iad008f20d35a18acf500f773900164552fd0c19e
/frameworks/av/services/audioflinger/AudioFlinger.h
1d491ff06f4b9c90ff24fe953b90d0843eaf1c04 16-Jul-2012 Glenn Kasten <gkasten@google.com> Fix races in AudioRecord stop()

Change-Id: Id0ac1915f57fef4a938c7f90989c1162a8b6c51c
/frameworks/av/services/audioflinger/AudioFlinger.h
be5f05e0fdfc4e3799653702187861a2afa072ee 19-Jul-2012 Glenn Kasten <gkasten@google.com> Internal dump methods return void not status_t

Only the IAudioFlinger::dump() needs to return a status_t.

Change-Id: Iffeb2a7db4846df850b6b2ed960276f1fd75dba0
/frameworks/av/services/audioflinger/AudioFlinger.h
bb4350d3b9e9485ae59e084de270f86aecef8066 04-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_devices_t more places

Change-Id: Id0ace02ca6f480a6c46e11880acf6cdc66d83184
/frameworks/av/services/audioflinger/AudioFlinger.h
d96c5724818fb47917bb5e7abe37799735e1ec0e 25-Apr-2012 Glenn Kasten <gkasten@google.com> Don't call virtual methods in destructor

The result of calling virtual methods from a destructor is undefined.

Change-Id: I0fd4a19626e5ae564a60b753315b5f6c4b8d1f2c
/frameworks/av/services/audioflinger/AudioFlinger.h
1ea6d23396118a9cfe912b7b8a4e6f231e318ea2 09-Jul-2012 Glenn Kasten <gkasten@google.com> Use atomic ops for thread suspend count

There was a theoretical but unlikely race if two binder threads
executed suspend() or restore() concurrently. Also added comments.

Change-Id: I0908acc810b83bdd66455b27ca3429de1662a2cd
/frameworks/av/services/audioflinger/AudioFlinger.h
1879fff068422852c1483dcf8365c2ff0e2fadfc 12-Jul-2012 Glenn Kasten <gkasten@google.com> Add tid parameter to IAudioFlinger::openRecord

Not yet implemented

Change-Id: I35523fb15ad71727ecc9f4bb870f07e4b7397dc4
/frameworks/av/services/audioflinger/AudioFlinger.h
39c54f68804c1ce5c85ec588f3c2c63447a807b4 09-Mar-2012 Glenn Kasten <gkasten@google.com> Remove dead code

Change-Id: If22a6c4e572b0734eba0c5a7ce29a2c61c581e5d
/frameworks/av/services/audioflinger/AudioFlinger.h
04270daf50f0c602d7c57a257a693e68246cbeb7 10-Jul-2012 Glenn Kasten <gkasten@google.com> Record overflow cleanup

Add comments and rename one method for clarity

Change-Id: I04a9147e46e88a072256c0211b112d52202419e2
/frameworks/av/services/audioflinger/AudioFlinger.h
254af180475346b6186b49c297f340c9c4817511 03-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_channel_mask_t more places

Use it in AudioSystem::getOutput(), AudioSystem::getInput(),
IAudioPolicyService::getOutput(), IAudioPolicyService::getInput(),
and various other places in AudioFlinger.

Not done: AudioTrack and OutputDescriptor.

Change-Id: I70e83455820bd8f05dafd30c63d636c6a47cd172
/frameworks/av/services/audioflinger/AudioFlinger.h
2df8f55055fe431a508148cf525df1ba40f03113 10-Jul-2012 Glenn Kasten <gkasten@google.com> Add comments on use of volatile for track count

and add acquire load at the read

Change-Id: Ib41a58f5b1f6af87a8bd63d3f77d2ec0e48cb479
/frameworks/av/services/audioflinger/AudioFlinger.h
a34f8ec169986c5a28600c0decaa4e2db70df8e4 21-Jun-2012 Glenn Kasten <gkasten@google.com> Remove 'volatile' from mMute and add comments

Change-Id: I386ba27b2305a397aba70331c6bf0d35ea727cf6
/frameworks/av/services/audioflinger/AudioFlinger.h
9f34a36d9cdb9595c288e50ffe00da038bc8abb9 21-Mar-2012 Glenn Kasten <gkasten@google.com> Whitespace and indentation

Change-Id: I424052b4ff9218147a5cfc8e6dcd67fe8105d229
/frameworks/av/services/audioflinger/AudioFlinger.h
6648821933dc06c0b09ab2c8b32135edddcd4291 21-Jun-2012 Glenn Kasten <gkasten@google.com> AudioFlinger::getBuffer() always returns non-NULL

Change-Id: I543d3db507597cacbfdad5d9ea71732137fe54fb
/frameworks/av/services/audioflinger/AudioFlinger.h
01542f2704f39956da09ae2840e192dab760091f 02-Jul-2012 Glenn Kasten <gkasten@google.com> Only write to mDevice once

This fixes a bug where readers might see intermediate values.
Also add comments about how mStandby and mDevice are used.

Change-Id: Idc84e56c21381a45137a2ca5ff9c57d437201869
/frameworks/av/services/audioflinger/AudioFlinger.h
c1dae24a08b67b98e18e4239d4f3a74d600d353c 03-Jul-2012 Glenn Kasten <gkasten@google.com> Remove debug code HAVE_REQUEST_PRIORITY and SOAKER

Change-Id: I73a2afe72d8acb53e57e6b4e6fb5133e22b7875a
/frameworks/av/services/audioflinger/AudioFlinger.h
a5f44ebaf58911805b4fb7fb479b19fd89d2e39b 25-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: fix effect disconnect deadlock

Fix possible deadlock when several EffectHandles on the same
EffectModule are destroyed simultaneously:
A wp on an EffectHandle should not be promoted to a local sp
with ThreadBase mutex held as the EffectHandle destructor can be
called when the sp gets out of scope which will call
ThreadBase::disconnectEffect() and try to acquire the mutex.

Use raw pointers instead of weak pointers for the list of handles
on an EffectModule.

Bug 6679606.

Change-Id: Ice8b602fb03a7d363c44ce3dced8a53540d96270
/frameworks/av/services/audioflinger/AudioFlinger.h
dd8104cc5367262f0e5f13df4e79f131e8d560bb 02-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_channel_mask_t more consistently

In IAudioFlinger::createTrack() and IAudioFlinger::openRecord(),
declare input parameter to use correct type audio_channel_mask_t.

In IAudioFlinger::getInputBufferSize(), input parameter is now channel mask
instead of channel count.

Remove unused IAudioFlinger::channelCount(audio_io_handle_t).

In AudioRecord::getMinFrameCount() and AudioSystem::getInputBufferSize(),
input parameter is channel mask instead of channel count.

Change-Id: Ib2f1c29bea70f016b3cfce83942ba292190ac965
/frameworks/av/services/audioflinger/AudioFlinger.h
f1da96d8cf60842538e00a9c950cc451f7da2c10 03-Jul-2012 Glenn Kasten <gkasten@google.com> Remove longStandbyExit

It was never set (the assignment was within an "if" that was never true).

Change-Id: I01cc68e9df6b190eece621b2aa9858b4361880ce
/frameworks/av/services/audioflinger/AudioFlinger.h
415fa7599f48494f99206b8d6e1974abb52c5923 03-Jul-2012 Glenn Kasten <gkasten@google.com> Fix uninitialized field EffectModule::mPinned

Also mark EffectModule::mId and EffectModule::mSessionId const, and
document the initialization of other fields in EffectModule.

Change-Id: Ic1ca008e75e9b5924743ffc35bef80057f3a0669
/frameworks/av/services/audioflinger/AudioFlinger.h
dbabf8a7dfe3aa8bf0ed169220d2009d5891fef2 01-Jul-2012 Eric Laurent <elaurent@google.com> am 651f9e7c: am 717e1286: audioflinger: fix auxiliary effect attachment

* commit '651f9e7c972b58a49066081187161268bcf9237a':
audioflinger: fix auxiliary effect attachment
717e128691f083a9469a1d0e363ac6ecd5c65d58 30-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: fix auxiliary effect attachment

Auxiliary effects (Reverb) are global effects and as such follow
the default rule which is to attach them to the output thread that
handles music streams by default. This causes a problem when several
threads are eligible to handle music streams as tracks can be attached
to either thread based on criteria unknown when teh effect is created.

The fix consists in moving the auxiliary effect if necessary when an
AudioTrack is attached to it and this track is not on the same
output thread.

Bug 6608561.

Change-Id: Ib32c3cabc731b2046aba728be1771982999c6069
/frameworks/av/services/audioflinger/AudioFlinger.h
22167855ff9af7b13fda669ca27c67a037a7d585 20-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: fix setStreamOutput()

AudioFlinger::setStreamOutput() should also work for direct outputs.
Also ignore the destination output specified to match the expected
behavior which is to invalidate all tracks using the specified stream
type so that they can be re created on the correct ouput thread.

Do not send STREAM_CONFIG_CHANGED event wich is ignored by AudioSystem
anyway since the stream to output cache has been removed.

Change-Id: I13d9d47922923b630dd755717875424c16be4637
/frameworks/av/services/audioflinger/AudioFlinger.h
c15d6657a17d7cef91f800f40d11760e2e7340af 30-May-2012 Glenn Kasten <gkasten@google.com> Add audio watchdog thread

Change-Id: I4ed62087bd6554179abb8258d2da606050e762c0
/frameworks/av/services/audioflinger/AudioFlinger.h
28ed2f93324988767b5658eba7c1fa781a275183 07-Jun-2012 Glenn Kasten <gkasten@google.com> Reduce underruns in screen off, esp. with EQ

Add MonoPipe APIs to specify setpoint.
Use screen state to configure pipe setpoint.
Fix a long-standing bug where pipe sleep time was excessive,
which interacted poorly with governor and low clock frequencies.
Now it deducts the elapsed time since last write(),
which was significant when there was EQ and low clock frequency.

Bug: 6618373
Change-Id: I6f3b0072c2244aeb033ef0795ad164491a164ff5
/frameworks/av/services/audioflinger/AudioFlinger.h
f06c2ed50e1db871ae9eb2bd15a196064f8c278c 06-Jun-2012 Marco Nelissen <marcone@google.com> Take latency and current time into account for visualization

Buffer more data, and return the data that is currently being
output from the audio output, to ensure that visualizations are
smooth and responsive even when the audio output has a large
latency and/or large buffers.
b/6522728

Change-Id: I401637f01be7600b3c594a55c869036c13b206c0
/frameworks/av/services/audioflinger/AudioFlinger.h
67c0a58e05f4c19d4a6f01fe6f06267d57b49305 02-May-2012 Eric Laurent <elaurent@google.com> audioflinger: various fixes on direct output

Various fixes in direct output playback thread implementation:
- threadLoop_write() was broken for playback threads that do not
use a pipe sink.
- output buffer size calculation was hard coded for stereo.
- removed software volume that was implemented for PCM stereo
format only: the audio HAL has to implement volume if needed
for direct outputs.

Change-Id: If211b4489be9af395435707b8cf0388cce1347b2
/frameworks/av/services/audioflinger/AudioFlinger.h
399930859a75d806ce0ef124ac22025ae4ef0549 31-May-2012 Glenn Kasten <gkasten@google.com> State queue dump

Bug: 6591648
Change-Id: Iac75e5ea64e86640b3d890c46a636641b9733c6d
/frameworks/av/services/audioflinger/AudioFlinger.h
893a05479c96f911d02beb0443da3ed6508143a7 30-May-2012 Glenn Kasten <gkasten@google.com> Fix fast track leak if out of normal track names

Bug: 6580402
Change-Id: I3ac7f012062c35833147f47ba822eb4bf532a824
/frameworks/av/services/audioflinger/AudioFlinger.h
91b14c4c144d0cc957a427cffc02ba10d0615677 30-May-2012 Eric Laurent <elaurent@google.com> audioflinger: fix effect problem during underrun

When an audio track underruns, the input buffer of the
corresponding effect chain (if any) must be cleared, otherwise
audio from previous mixer run will be fed again to the effect process
function.

Bug 6551652.

Change-Id: I5cd02196745f756c85af82d6937e9dc54369b37f
/frameworks/av/services/audioflinger/AudioFlinger.h
e737cda649acbfa43fc1b74612a83f2fac9aa449 23-May-2012 Eric Laurent <elaurent@google.com> audioflinger: refine latency latency calculation.

There is an audio pipe between the normal mixer output and the fast
mixer to cope for scheduling delays and buffer size difference.
This pipe depth was not taken into account in latency calculation.

Adding the pipe contribution to the latency significantly improves A/V sync.

Bug 6520569.

Change-Id: I5584908e8aa8a02170eb38b22b4370eea800a235
/frameworks/av/services/audioflinger/AudioFlinger.h
fbae5dae5187aca9d974cbe15ec818e9c6f56705 21-May-2012 Glenn Kasten <gkasten@google.com> Keep a copy of most recent audio played

Change-Id: I6b2f97881c39998a2fae9ab79d669af6c0a37e94
/frameworks/av/services/audioflinger/AudioFlinger.h
88cbea8a918bbaf5e06e48aadd5af5e81d58d232 15-May-2012 Glenn Kasten <gkasten@google.com> Display pipe underrun counters in dumpsys

The normal mixer writes it's submix to a pipe, which is read by the fast
mixer. Now dumpsys media.audio_flinger display the raw underrun counters
when fast mixer tries to pull from the pipe but doesn't get enough frames.

Change-Id: I72505f149f9e12802784da654a651d43734e1c79
/frameworks/av/services/audioflinger/AudioFlinger.h
44a957f06400a338e7af20b3d16c4c4ae22a673c 16-May-2012 Eric Laurent <elaurent@google.com> Fix static track activity ref counting

When a static AudioTrack underruns, it means that playback is over.
As apps do not necessarily stop playback explicitly, AudioFlinger
should call stopOutput() to decrease activity ref count in
audio policy manager.

Bug 6486311.

Change-Id: I1ea722c443780329ded6310c958b24726e918d16
/frameworks/av/services/audioflinger/AudioFlinger.h
2986460984580833161bdaabc7f17da1005a8961 09-May-2012 Eric Laurent <elaurent@google.com> Fix issues with synchronous record start.

- Added a timeout in case the trigger event is never fired.
- Extend AudioRecord obtainBuffer() timeout in case of
synchronous start to avoid spurious warning.
- Make sure that the event is triggered if the track is
destroyed.
- Reject event if the triggering track is in an incompatible state.

Also fix a problem when restoring a static AudioTrack after
a mediaserver crash.

Bug 6449468.

Change-Id: Ib36e11111fb88f73caa31dcb0622792737d57a4b
/frameworks/av/services/audioflinger/AudioFlinger.h
09474df67278c0cd621b57c4aef1deaec4d8447f 10-May-2012 Glenn Kasten <gkasten@google.com> Improve underrun handling for fast tracks

Maintain more accurate accounting of type of underrun.
Automatically remove track from active list after a series of "empty" underruns.

Change-Id: If042bf80e1790dcaaf195c99dc9c0ed9b55382c1
/frameworks/av/services/audioflinger/AudioFlinger.h
d08f48c2ad2941d62b313007955c7145075d562c 02-May-2012 Glenn Kasten <gkasten@google.com> Fix stopping process for fast tracks

Previously, the state of a fast track "wiggled" back and forth at the end.

Now it goes through these transitions:
active -> stopping_1 -> stopping_2 -> stopped

This CL is only for fast tracks, and does not change how
normal tracks work.

Change-Id: Icc414f2b48c46dda63cfa6373ca22d033dd21cd4
/frameworks/av/services/audioflinger/AudioFlinger.h
810280460da5000785662f6c5b0c7ff3ee0a4cb3 01-May-2012 Glenn Kasten <gkasten@google.com> Temporary fix for both normal tracks & fast tracks

If there is at least one active fast track, it forces a mixer
status of ready, which messes up the logic for normal track underruns.

Change-Id: I9de2fcaef090e2c2f99682333af3d3dd618b0d6b
/frameworks/av/services/audioflinger/AudioFlinger.h
288ed2103d96f3aabd7e6bea3c080ab6db164049 26-Apr-2012 Glenn Kasten <gkasten@google.com> Fix race condition for non-started fast tracks

This required re-implementing how fast tracks are considered active.
Now, they use the same logic as normal tracks, except underrun is ignored.

Other changes:
- add framesReady() to AudioBufferProvider interface
- rebased
- add track underrun counter state to fast mixer dump state
- move dumpsys header to Track::appendDumpHeader()
so it closer to where tracks are dumped
- display track state in dumpsys as a character code
- measure and display warmup time and cycles in dumpsys
- copy in the presentation complete code
- add ExtendedAudioBufferProvider for framesReady() which returns size_t
- simplify underrun tracking
- deferred reset track after stop()
- add comments

Change-Id: I7db8821bc565230ec76da1f9380fe3fb09735e5b
/frameworks/av/services/audioflinger/AudioFlinger.h
83faee053cfd4251dbb591b62039f563ffdac399 28-Apr-2012 Eric Laurent <elaurent@google.com> AudioFlinger: fix stop detection for static tracks

The end of playback and end of presentation detection was broken for
static AudioTracks (tracks using shared memory buffers passed by client).

The mixer should not wait for a minimal amount of frames to be available to mix
a static track otherwise the last frames might never be consumed.

A static track should be removed from active list in case of underrun even if not
stopped().

Issue 6411521.

Change-Id: I66a2c1a77e98149e5049a223a6f04c3b8c5ad11a
/frameworks/av/services/audioflinger/AudioFlinger.h
da747447c1d4b5205469b4e94485b8769df57a97 26-Apr-2012 Eric Laurent <elaurent@google.com> AudioFlinger: fix tracks ready for mixing logic.

Commit fec279f5 broke the logic allowing to wait for an application
to provide frames for mixing in the case of several active tracks.

This was causing audio gaps when playing music and superposing a
sound Fx (keyboard clicks...).

Issue 6185007.

Change-Id: Id0fad150d0b615646d6b1387c0de8ca944d228f6
/frameworks/av/services/audioflinger/AudioFlinger.h
58912562617941964939a4182cda71eaeb153d4b 03-Apr-2012 Glenn Kasten <gkasten@google.com> AudioFlinger normal mixer uses FastMixer

Change-Id: I3131bb22d2d057e9197a2ebfa6aa1cfaab9e5321
/frameworks/av/services/audioflinger/AudioFlinger.h
3acbd053c842e76e1a40fc8a0bf62de87eebf00f 28-Feb-2012 Glenn Kasten <gkasten@google.com> Configure policy of mediaserver threads

Change-Id: Ifd825590ba36996064a458f64453a94b84722cb0
/frameworks/av/services/audioflinger/AudioFlinger.h
0ca3cf94c0dfc173ad7886ae162c4b67067539f6 18-Apr-2012 Eric Laurent <elaurent@google.com> rename audio policy output flags

Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
/frameworks/av/services/audioflinger/AudioFlinger.h
1c345196edc61694f29307a1826a64a0d26028dc 27-Mar-2012 John Grossman <johngro@google.com> TimedAudio: Track of the number of pending frames.

This is a manual merge from ics-aah

> TimedAudio: Track of the number of pending frames.
>
> Keep track of the number of frames pending in the timed audio queue so
> we can implement framesReady in O(1) time instead of O(N). This
> change partially addresses bug 6020970; the bug will be completely
> addressed once this change has been up-integrated into master.
>
> Change-Id: I599eb15ea1f6d715b97b30e65214fb6fadd169df
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: I6cbbbc3afc8efd066fe94865326ede0c6b3db2bd
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
9fbdee13d09447550dd22ae72c2dbabdce7f0a80 27-Mar-2012 John Grossman <johngro@google.com> TimedAudio: Fix a cause of audio popping.

This is a manual merge from ics-aah

> TimedAudio: Fix a cause of audio popping.
>
> Fix an issue with buffer lifecycle management which could cause audio
> pops on timed outputs. There were two issues at work here.
>
> 1) During trim operations for the queued timed audio data, buffers
> were being trimmed based on their starting PTS instead of when the
> chunk of audio data actually ended. This means that if you have a
> very large chunk of audio data (larger than the mixer lead time),
> then a buffer at the head of the queue could be eligible to be
> trimmed before its data had been completely mixed into the output
> stream, even though the output stream was fully buffered and in no
> danger of underflow.
> 2) The implementation of getNextBuffer and releaseBuffer for timed
> audio tracks was not keeping anything like a reference to the data
> that it handed out to the mixer. The original architecture here
> seemed to be expecting a ring buffer design, but timed audio tracks
> use a packet based design. Pieces of packets are handed out to the
> mixer which then frequently will hold onto that chunk of data
> across two mix operations, using the first part of the chunk to
> finish a mix buffer and then using the end of the chunk for the
> start of the next mix buffer. If the buffer that the mixer is
> holding a piece of got trimmed before the start of the next mix
> operation, it would return to its heap and could be filled with who
> knows what by the time it actually got mixed. On debug builds,
> they seem to get zero'ed out as they go back to the heap causing
> obvious pops in presentation.
>
> This change addresses both issues. Trim operations are now based on
> ending presentation time for a chunk of audio, not the start. Also,
> when the head of the queue is in flight to the mixer, it can no longer
> be trimmed immediately, merely flagged for trim by the mixer when the
> mixer finally does call releaseBuffer.
>
> Signed-off-by: John Grossman <johngro@google.com>
> Change-Id: Ia1ba08cb9dea35a698723ab2d9bcbf804f1682fe

Change-Id: I2c5e2f0375c410f0de075886aac56ff6317b144c
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
7d5b26230a179cd7bcc01f6578cd80d8c15a92a5 05-Apr-2012 Jean-Michel Trivi <jmtrivi@google.com> AudioMixer uses downmix effect for multichannel content

In the AudioMixer structure associated with each track, add an object
that acts as the buffer provider when the track has more than two
channels of input in the mixer. This object, DownmixerBufferProvider,
gets audio from the actual buffer provider of the track, and applies
a downmix effect on it.
The downmix effect is created and configured when the track gets
created in AudioFlinger, which causes AudioMixer::getTrackName()
to be called with the new track's channel mask. It is released
when the track is disabled in the mixer.

Change-Id: I05281ed5f61bef663a8af7ca7d5ceac3517c82db
/frameworks/av/services/audioflinger/AudioFlinger.h
a4c5a550e2a3bc237179b8684e51718e05894492 29-Mar-2012 Eric Laurent <elaurent@google.com> audio policy: load audio hw modules.

Audio HW modules are now loaded upon request from audio policy manager
according to the configuration in audio_policy.conf.
Removed hard coded HW module loading by AudioFlinger at init time.
Added methods to IAudioFlinger and AudioPolicyInterface
to control the loading of audio HW modules.
Added methods to open an output or input stream on a specific hw module.

Change-Id: I361b294ece1a9b56b2fb39cc64259dbb73b804f4
/frameworks/av/services/audioflinger/AudioFlinger.h
1a9ed11a472493cac7f6dfcbfac2064526a493ed 21-Mar-2012 Eric Laurent <elaurent@google.com> audio policy: add configuration file

removed outputs to stream mapping cache in audio system: the output for a
given stream type must always be queried from audio policy manager as the cache
is not always updated fast enough by audioflinger callback.

removed AudioFlinger::PlaybackThread::setStreamValid() not used anymore if
stream to output mapping is not cached.

Change-Id: Ieca720c0b292181f81247259c8a44359bc74c66b
/frameworks/av/services/audioflinger/AudioFlinger.h
73d227557ba5192735356bacab9f77b44980793b 19-Mar-2012 Glenn Kasten <gkasten@google.com> AudioFlinger track flags and server's fast policy

Change-Id: I72358c8e6829d173b3e60ced8a8babc089869fac
/frameworks/av/services/audioflinger/AudioFlinger.h
0bf65bdde04b8e66c998ff37e2b2afafddddfa33 29-Feb-2012 Glenn Kasten <gkasten@google.com> const methods and comments

Change-Id: Ifd16750174fdb15b72507787502b587562ffc99e
/frameworks/av/services/audioflinger/AudioFlinger.h
a011e35b22f95f558d81dc9c94b68b1465c4661d 30-Mar-2012 Eric Laurent <elaurent@google.com> implemented synchronous audio capture

Added the infrastructure to support the synchronization of playback and
capture actions on specific events.
The first requirement for this feature is to synchronize the audio capture
start with the full rendering of a given audio content.
The applications can further be extended to other use cases
(synchronized playback start...) by adding new synchronization events and
new synchronous control methods on player or recorders.

Also added a method to query the audio session from a ToneGenerator.

Change-Id: I51f1167290d9cafdf2fbcdf9e4785156973af44c
/frameworks/av/services/audioflinger/AudioFlinger.h
b83d38feeeb88a8a2a6219e1fca2480b5a14fb0d 26-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "IAudioFlinger::createTrack and openRecord flags"
c5c49398584f2399af905a931e556ed6e0a29cd4 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up Track constructor"
f99590187e2e3f1cf6f093063170edec269cac5d 19-Mar-2012 Glenn Kasten <gkasten@google.com> Clean up Track constructor

The 'thread' parameter can never be NULL.
Use constructor initialization list when possible.
Make more members const.
Only put the relevant code under "if (mCblk != NULL)".
Add comment about track name leak.

Change-Id: Ib963390a69bed1999638cc982a759edd1d5f4712
/frameworks/av/services/audioflinger/AudioFlinger.h
17a736c3e1d062d7fc916329eb32aef8935614af 14-Feb-2012 Glenn Kasten <gkasten@google.com> Update comments

Change-Id: I327663a020670d0a72ff57bd0b682e2ce0528650
/frameworks/av/services/audioflinger/AudioFlinger.h
a075db4ff9b086ac2885df77bb6da0869293df92 06-Mar-2012 Glenn Kasten <gkasten@google.com> IAudioFlinger::createTrack and openRecord flags

createTrack and openRecord don't need the "old" flags parameter,
which was either audio_policy_output_t or audio_in_acoustics_t
shifted left by 16 bits. But they do need "new" flags, which
are defined by the application use case. Initially, the only
application use case flag is timed output, but others are planned.

For output, the audio_policy_output_t flags are passed to
AudioSystem::getOutput, which returns an audio_io_handle_t, and that
handle is then passed to createTrack. So createTrack doesn't need the
old flags parameter.

For input, the audio_in_acoustics_t flags are passed to
AudioSystem::getInput, which returns an audio_io_handle_t, and that
handle is then passed to openRecord. So openRecord doesn't need the
old flags parameter.

Change-Id: I18a9870911846cca69d420c19fe6a9face2fe8c4
/frameworks/av/services/audioflinger/AudioFlinger.h
e53b9ead781c36e96d6b6f012ddffc93a3d80f0d 13-Mar-2012 Glenn Kasten <gkasten@google.com> Whitespace and indentation

Fix indentation to be multiple of 4.
Make it easier to search:
sp< not sp < to
"switch (...)" instead of "switch(...)" (also "if" and "while")
Remove redundant blank line at start or EOF.
Remove whitespace at end of line.
Remove extra blank lines where they don't add value.

Use git diff -b or -w to verify.

Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
/frameworks/av/services/audioflinger/AudioFlinger.h
73f4bc33e0d458933460250a47c64aa868c05f97 09-Mar-2012 Glenn Kasten <gkasten@google.com> Inline applyVolume() into threadLoop_mix()

Also the declaration of applyVolume in PlaybackThread was dead.

Change-Id: I4b1a9848d07d3d7f340baea05b17f667c78df868
/frameworks/av/services/audioflinger/AudioFlinger.h
470aa50c36089fbe0427557f7cf4464dd26a1c52 12-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Remove unnecessary friend declarations"
2d6ef93773465cd3e66146fac35050a472c589f7 12-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Remove virtual from methods that don't need it"
66fcab972e9218d47c58a915f391b2f48a09903a 24-Feb-2012 Glenn Kasten <gkasten@google.com> Merge dup code at thread entry and param change

This CL is mostly just cleanup, but there are a couple of fixes marked
"FIX" below.

Merge the duplicate code that was at the beginning of threadLoop() and
after a parameter change. cacheParameters_l() is now called at entry to
threadLoop() and after any parameter change. It re-calculates all values
that are derived from parameters, and caches them in instance variables.

updateWaitTime_l():
- FIX activeSleepTime depends on mWaitTimeMs, which was initially set
to infinity. updateWaitTime_l() was not called at entry to
threadLoop(), so activeSleepTime was not set correctly before the
first parameter change.

- FIX reversed the order of calls after parameter change
for the same reason so that updateWaitTime_l() is called before
calculating values that are derived from wait time.

- marked it private since now it's only called from DuplicatingThread

Change-Id: If2607d2ed66c6893d910433e48208a93c41fb7e9
/frameworks/av/services/audioflinger/AudioFlinger.h
18868c5db2f90309c6d11e5837822135e4a0c0fa 07-Mar-2012 Glenn Kasten <gkasten@google.com> Use audio_policy_output_flags_t consistently

This affects:
- IAudioFlinger::openOutput
- AudioTrack::AudioTrack
- AudioTrack::set
- apps that call these

Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
/frameworks/av/services/audioflinger/AudioFlinger.h
688aac7675f18bdd7bff13334759e20bc4e6c390 09-Mar-2012 Glenn Kasten <gkasten@google.com> Remove virtual from methods that don't need it

Change-Id: I30e17e61aae25b036436c0e270313c80c43e5f06
/frameworks/av/services/audioflinger/AudioFlinger.h
1998661fdb6b0b5ae103e047e3d653c5da1b99e3 09-Mar-2012 Glenn Kasten <gkasten@google.com> Remove unnecessary friend declarations

Add comments to the remaining friends, so we know what is left if we
decide to remove them later.

Change-Id: I1de929257dc4700960f77902cda3d303177c72cf
/frameworks/av/services/audioflinger/AudioFlinger.h
53d76dbe7c55821e89d9da02e7a563f7fb45de87 08-Mar-2012 Glenn Kasten <gkasten@google.com> Replace hard-coded 3 by FCC_2 to simplify searches

Change-Id: I92881d04e8378307f849fb343071a58d181a68b4
/frameworks/av/services/audioflinger/AudioFlinger.h
fec279f5a0bfaa2a42e91ab6dfa0282baeee308b 08-Mar-2012 Glenn Kasten <gkasten@google.com> Mixer status cleanup

Use mPrevMixerStatus for DirectOutputThread also.
Remove the MIXER_CONTINUE logic and use MIXER_IDLE instead.
Rename the field mixerStatus to mMixerStatus.
Rename local variable back to mixerStatus.

Change-Id: I0a8145fc856c6c5ff8b784b6176ef3c4d8eb7408
/frameworks/av/services/audioflinger/AudioFlinger.h
b071e9bc248865ef87a339044c0c5cbabfac175c 08-Mar-2012 Glenn Kasten <gkasten@google.com> Cleanup DirectOutputThread::mActiveTrack

Rename activeTrack to mActiveTrack.
Release the reference earlier, at the end of threadLoop_mix().
This allows the field to be made private and to
move the declaration from PlaybackThread to DirectOutputThread.

Change-Id: I02be7a254638f7d85e92aaf0002d20ca0092a5c3
/frameworks/av/services/audioflinger/AudioFlinger.h
b279312a9038b9c5b9b05b31b1b1db86f748efd8 08-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "IAudioFlingerClient::ioConfigChanged param2 const"
fa26a859bacb597587a8f49acfc3127351fa688c 06-Mar-2012 Glenn Kasten <gkasten@google.com> Isolate references to outputTracks/mOutputTracks

Move all references to DuplicatingThread::outputTracks and
DuplicatingThread::mOutputTracks from the common threadLoop() into
virtual methods. This allows them to be moved from PlaybackThread to
DuplicatingThread, and to be marked private.

Also use vector assignment to copy mOutputTracks to outputTracks.

Change-Id: Ieb1cf1ad36b8a65143e61e6c92a65fb43427e5e2
/frameworks/av/services/audioflinger/AudioFlinger.h
a13ad6e84db128eadf23b154d3346f0bb473a5f7 07-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Make applyVolume private to DirectOutputThread"
d4513b09123deebf8023b73a82d2d46d35806cea 07-Mar-2012 Glenn Kasten <gkasten@google.com> Make applyVolume private to DirectOutputThread

Change-Id: I7ca4a59505857cbd106b6f274c66e9580dead271
/frameworks/av/services/audioflinger/AudioFlinger.h
a3707a280177e934a1e0a15660d9176663b7fc17 07-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Add comments about sequence for setting parameters"
1465f0c3df04c3166155a852a6a5c10069c1fd0a 06-Mar-2012 Glenn Kasten <gkasten@google.com> Merge the calls to prepareTracks_l

Change-Id: I1dd759581333e2908d980180d44db7bf5ed6591d
/frameworks/av/services/audioflinger/AudioFlinger.h
b81cc8c6f3eec9edb255ea99b6a6f243585b1e38 01-Mar-2012 Glenn Kasten <gkasten@google.com> IAudioFlingerClient::ioConfigChanged param2 const

The 3rd parameter (param2) to AudioFlingerClient::ioConfigChanged
is used as an input. So changed it from void * to const void *.
It is then cast to const OutputDescriptor *
or const audio_stream_type_t * depending on the event.

Change-Id: Ieec0d284f139b74b3389b5ef69c7935a8e5650ee
/frameworks/av/services/audioflinger/AudioFlinger.h
f8edf68a1e39da273eafe8c85bdbedc26636c4ec 07-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Rename fields of AudioSessionRef"
cbc52bfb3b51c81c945b1e35990324bde892829a 01-Mar-2012 Glenn Kasten <gkasten@google.com> Add comments about sequence for setting parameters

Change-Id: Iffa59a34c3c47bdc1d3234cdcb4d8ff99c102825
/frameworks/av/services/audioflinger/AudioFlinger.h
438b036deaf4413503567a75a2861c000d21da5b 06-Mar-2012 Glenn Kasten <gkasten@google.com> Rename updateWaitTime since a lock is held

Change-Id: I9bb978cbd0debf5b21676467060f72eebafea3e6
/frameworks/av/services/audioflinger/AudioFlinger.h
012ca6b4f69fb24385025c0e84b8f816525a3032 06-Mar-2012 Glenn Kasten <gkasten@google.com> Rename fields of AudioSessionRef

Change-Id: I9f2a66094135c4ac6bec2d3e9db3ac5fbf988ede
/frameworks/av/services/audioflinger/AudioFlinger.h
000f0e39b4d0c88441297a05ab5f8da6832c1640 02-Mar-2012 Glenn Kasten <gkasten@google.com> threadLoop merge

Change-Id: Id8e6330ac6be76f9c2debba94f856de87e2d98f7
/frameworks/av/services/audioflinger/AudioFlinger.h
e8286332f3817a8b7cc4cfd8f6450a3913533660 29-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Shorten thread names"
3e07470f3b122097cacfe5b85cdb1359279a2f33 29-Feb-2012 Glenn Kasten <gkasten@google.com> Prepare for threadLoop merge - active tracks

Continued work on making the copies of threadLoop more similar:
- Remove alias for mActiveTracks in MixerThread and DuplicatingThread.
- Pull in declaration of activeTrack in DirectOutputThread.
- Remove redundant parameter of prepareTracks_l().
- Comment prepareTracks_l().

Change-Id: If1087c1902b454acec01ddfdd9f055f0ca7abf04
/frameworks/av/services/audioflinger/AudioFlinger.h
bc4b08ba67a0245e092aee8f08ba30ef22d421bf 29-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Update AudioFlinger comments"
c455fe9727d361076b7cead3efdac2d32a1a1d6d 29-Feb-2012 Glenn Kasten <gkasten@google.com> mSuspend comments and usage

Emphasize that playbackthread::mSuspend is a counter, not a bool

Change-Id: I7188e56814e1c54dbc65e560f3627f138257d644
/frameworks/av/services/audioflinger/AudioFlinger.h
d805b718b1fd2d5407ef665c8d4bb42e63dc71a9 25-Feb-2012 Glenn Kasten <gkasten@google.com> Update AudioFlinger comments

Add comments to enum mixer_state
Note side-effect of lockEffectChains_l
Fix a typo

Change-Id: Ibd51678bac2193201cbcbe081ff5664046fbc494
/frameworks/av/services/audioflinger/AudioFlinger.h
480b46802bef1371d5caa16ad5454fce04769c57 28-Feb-2012 Glenn Kasten <gkasten@google.com> Shorten thread names

prctl(PR_SET_NAME) limits to 15 characters. Before we had names like
"Binder Thread #" and the counter was cut off :-( Also remove redundant
"thread" at end of name; it's always a thread.

Change-Id: I1f99c2730ba0787ed9b59c15914356cddf698e2f
/frameworks/av/services/audioflinger/AudioFlinger.h
a17c820c556fddf7ddd96b82b3e9874e340ffafd 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "AudioFlinger const methods and parameters"
fadb2c73fce479205432652530663e1e90fd546c 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "AudioBufferProvider comments and cleanup"
843a12d146bd64642bf85a4e56c274246e3893a6 27-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix tracking of hardware state for dump"
02fe1bf923bbe5789202dbd5810e2c04794562e6 25-Feb-2012 Glenn Kasten <gkasten@google.com> AudioFlinger const methods and parameters

Change-Id: I93ec28024005ed23aa141518092a012a4a7c44c5
/frameworks/av/services/audioflinger/AudioFlinger.h
37d825e72a6c606553a745da1212590a425996d3 24-Feb-2012 Glenn Kasten <gkasten@google.com> Pull out duplicated copies of silent mode check

Also fix the error handling for the property_get.

This is part of preparation for the threadLoop() merge.

Change-Id: I6405190ea18146d1271575e1dfe9f279e8f36b17
/frameworks/av/services/audioflinger/AudioFlinger.h
01c4ebf6b794493898114a502ed36de13137f7e5 22-Feb-2012 Glenn Kasten <gkasten@google.com> AudioBufferProvider comments and cleanup

Add comments about which methods implement the AudioBufferProvider interface.

Simplified the definition of kInvalidPts. <stdint.h> is very hard to work
with, there seems to be no way to use it reliably to get INT64_MAX without
having a separate source file, which is ugly because it means kInvalidPts
is not a compile-time constant. So I just deleted AudioBufferProvider.cpp
and used a hard-coded constant instead.

Added a default constructor for Buffer so that the fields aren't random
(especially .raw which is used to determine if the buffer is valid).

Make the pts for getNextBuffer default to kInvalidPTS so code that
doesn't need a pts doesn't have to specify a value.

Rename the parameter to AudioMixer::setBufferProvider to make it clearer.

Change-Id: I87e7290884d4ed975b019f62d1ab6ae2bc5065a5
/frameworks/av/services/audioflinger/AudioFlinger.h
8abf44d2f2bcd20a2835570efe89d89c19db426a 02-Feb-2012 Glenn Kasten <gkasten@google.com> Fix tracking of hardware state for dump

At end of AudioFlinger::onFirstRef(), the hardware status was being left
in wrong state. It should be AUDIO_HW_IDLE but was AUDIO_HW_INIT.

mHardwareStatus was being set to AUDIO_HW_OUTPUT_OPEN too early, and so
a return would leave it in the wrong state until next hardware operation.

Take the hardware lock for dev->get_parameters, and update mHardwareStatus
before and after.

Keep hardware lock only for the duration of the dev->set_parameters.

Rename two constants in enum hardware_call_state to have the prefix
AUDIO_HW so they follow the naming conventions.

Add comments.

Change-Id: I6c7450b11f9b13adaeef9cec874333e478a58fc0
/frameworks/av/services/audioflinger/AudioFlinger.h
5cf034d92d901169ca6e36c90475f40715827fcd 21-Feb-2012 Glenn Kasten <gkasten@google.com> Remove TrackBase::mFlags

The bit-field TrackBase::mFlags was supposed to have track-specific
flags in the upper 16 bits, and system flags in the lower 16 bits.

The upper 16 bits of mFlags were initialized in the TrackBase
constructor from the flags parameter of IAudioFlinger::createTrack()
and IAudioFlinger::openRecord(), and the lower 16 bits were cleared.

However, the upper 16 bits of mFlags were never acccessed again.
So really there are no track-specific flags. I left the flags
in the parameter list of createTrack() and openRecord() but made a
note that these should be removed eventually as they are dead.

This leaves only the one system flag "step server failed". I replaced
the bit-field mFlags by bool mStepServerFailed, which is simpler and
slightly faster.

Change-Id: I6650f5487be72791b4a67d73adcd10ffa04e2aa5
/frameworks/av/services/audioflinger/AudioFlinger.h
9eaa55756c5b245970447019250ce852f5189525 20-Jan-2012 Glenn Kasten <gkasten@google.com> Avoid wp<>::unsafe_get() with a few exceptions

Avoid using wp<>::unsafe_get() except in a log, and other specific cases
when it's known to be safe.

Use more specific subclass types for parameters to avoid down-casts.

When a constructor or method parameter is "this" of an object that is
currently being constructed, it's better to use a raw pointer rather
than either sp<> or wp<>.

Using the raw pointer is safe, provided either:
- it is "this" of an object being constructed (which has sp<> refcount of 0),
- or the caller already holds an sp<>

The raw pointer is simpler and faster, and it avoids the problem of the
sp<> reference count being incremented and then decremented to zero on
scope exit, which would cause the object's destructor to run while the
object is still being constructed.

Also removed some dead code per a review comment.

Change-Id: I7375f64da3aec11b928c33cb01faff186252ef5e
/frameworks/av/services/audioflinger/AudioFlinger.h
a111792f1314479c649d1d44c30c2caf70c00c2a 26-Jan-2012 Glenn Kasten <gkasten@google.com> Simplify code

Use DefaultKeyedVector::valueFor to avoid extra test
Make local variables as local as possible
No double parentheses
No typedef for single use
No parentheses around indirect function call
No AudioFlinger:: prefix when not needed
Remove unnecessary casts
Remove block with only one line

Saves 128 bytes

Change-Id: I3a87430eeb01b81e7b81a1c38f6fdd3274ec48f3
/frameworks/av/services/audioflinger/AudioFlinger.h
4ff14bae91075eb274eb1c2975982358946e7e63 09-Feb-2012 John Grossman <johngro@google.com> Upintegrate Audio Flinger changes from ICS_AAH

Bring in changes to audio flinger made to support timed audio tracks
and HW master volume control.

Change-Id: Ide52d48809bdbed13acf35fd59b24637e35064ae
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
6dad4378f2a78d967defc8912ecf47f6ed117584 14-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix races related to volume and mute"
99e53b86eebb605b70dd7591b89bf61a9414ed0e 19-Jan-2012 Glenn Kasten <gkasten@google.com> Update comments

We no longer put the filename at start of file.

Change-Id: Ic435b159a23105681e3d4a6cb1ac097bc853302e
/frameworks/av/services/audioflinger/AudioFlinger.h
6dbc1359f778575d09d6da722b060a6d72c2e7c5 02-Feb-2012 Glenn Kasten <gkasten@google.com> AudioRecord and AudioTrack client tid

Inform AudioFlinger of the tid of the callback thread.

Change-Id: I670df92dd06749b057238b48ed1094b13aab720b
/frameworks/av/services/audioflinger/AudioFlinger.h
2b213bc220768d2b984239511cd4554a96bc0079 02-Feb-2012 Glenn Kasten <gkasten@google.com> mAudioHwDevs and related cleanup

Inline AudioFlinger::initCheck and remove unnecessary lock.

Remove redundant check of mAudioHwDevs.size().

No need to lock mHardwareLock for each device separately
during initialization.

Use size_t not int to loop through Vector, since size() returns size_t.

Add missing hardware lock for get_mic_mute() and get_input_buffer_size().

Add comments.

Change-Id: Iafae78ef78bbf65f703d99fcc27c2f4ff221aedc
/frameworks/av/services/audioflinger/AudioFlinger.h
b6333aa8317ce5162ab006c4baed6b0890936dc7 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify ThreadBase::exit() aka requestExitAndWait"
0d9302d7830b46542821b3e5f3e4f96942bd3cb3 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Move header declarations around for clarity"
858df80948ee64f478782a6a6c06533ba1651ef1 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Camel case readability & private disconnect(bool)"
b28686f95daee16edeb5f39af2cd5274ac3dc99f 06-Jan-2012 Glenn Kasten <gkasten@google.com> Simplify ThreadBase::exit() aka requestExitAndWait

We can remove mExiting and use Thread::exitPending() instead.

The local sp<> on "this" in exit() is not needed, since the caller must
also hold an sp<> in order to be calling us. (Unless it was using a raw
pointer, but that would be dangerous for other reasons.)

Add comment explaining the mLock in exit().

Change-Id: I319e5107533a1a7cdbd13c292685f3e2be60f6c4
/frameworks/av/services/audioflinger/AudioFlinger.h
12018d80add66f5558675614d73fa6549150806e 10-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Move declaration of stream_type_t up earlier"
2f732eb768004c6362fae8a02c60b69c9400b032 26-Jan-2012 Glenn Kasten <gkasten@google.com> Move header declarations around for clarity

Put IAudioFlinger methods in binder opcode order.
Move hardware call state closer to where it is used.
getMode() and btNrecIsOff() are private.

Change-Id: Ie50340b396c39c763f2b155cbc08da8a0d0f2424
/frameworks/av/services/audioflinger/AudioFlinger.h
58123c3a8b5f34f9d1f70264a3c568ed90288501 03-Feb-2012 Glenn Kasten <gkasten@google.com> Camel case readability & private disconnect(bool)

Change-Id: If66516ed2703e048c5e6ccc6cd431446a024f4a1
/frameworks/av/services/audioflinger/AudioFlinger.h
6637baae4244aec731c4014da72418d330636ae1 09-Jan-2012 Glenn Kasten <gkasten@google.com> Fix races related to volume and mute

Fix race conditions when setting master volume, master mute, stream
volume, stream mute for a playback thread, and when reading stream
volume of a playback thread. Lock order is AudioFlinger, then thread.

Rename streamVolumeInternal to streamVolume_l, comment, and use it to
implement streamVolume().

Code size reduction:
- Remove dead code: AudioFlinger::PlaybackThread::masterVolume, masterMute, streamMute.
- Change return type of non-binder methods that always succeed from status_t to void.
- Remove virtual from volume and mute methods that don't need it.

This change saves 228 bytes but decreases performance of binder operations
due to the added locks.

Change-Id: Iac75abc1f54784873a667d1981b2e08f8f31e5c9
/frameworks/av/services/audioflinger/AudioFlinger.h
b7bf796b758e144f94f6ed4d16c21bf22a118fb3 08-Feb-2012 Glenn Kasten <gkasten@google.com> Move declaration of stream_type_t up earlier

stream_type_t is used by AudioFlinger class, so it should be declared there.
This way we don't have to peek into PlaybackThread to get the declaration.

Change-Id: Ie08bab1604699214d1e8df2d48d3fbfbbc436e96
/frameworks/av/services/audioflinger/AudioFlinger.h
02bbd20cece1785c223ac4ca2ddc635931a80673 08-Feb-2012 Glenn Kasten <gkasten@google.com> Rename type() to streamType()

This avoids possible confusion with thread's type().
Also remove redundant cast "(audio_stream_type_t)".

Change-Id: I320b9177b6c267a102d215f002228bcf988c437a
/frameworks/av/services/audioflinger/AudioFlinger.h
98ec94c5854daccc3474758524e7f4adfe535ce0 25-Jan-2012 Glenn Kasten <gkasten@google.com> Combine duplicate code & document wp<> in mClients

Change-Id: Iea8cfe8e57563337fb2484a1246ef79d6ad3db18
/frameworks/av/services/audioflinger/AudioFlinger.h
72ef00de10fa95bfcb948ed88ab9b7a177ed0b48 17-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_io_handle_t consistently instead of int

Other:
- add a comment to nextUniqueId
- made ThreadBase::mId const, since it is only assigned in constructor.

Change-Id: I4e8b7bec4e45badcde6274d574b8a9aabd046837
/frameworks/av/services/audioflinger/AudioFlinger.h
5e92a7861196ddae14638d4b7a63fc4892b7ef59 30-Jan-2012 Glenn Kasten <gkasten@google.com> Effect UUID inputs passed by pointer are const

Change-Id: I1f5c338bcb7368e3dd8cd5f804b2e6d9fbe087f8
/frameworks/av/services/audioflinger/AudioFlinger.h
63d2daed17ab749baa80bc808fb5083b688b771b 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "AudioFlinger methods const and inline"
86feafe15b3f9609e1e9f64184688c2b6f2e4834 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use virtual destructors"
e98bbd36d67243fe987b09904956550a68af1cc7 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Declare more IAudioFlinger methods const"
d5e54f7a36daedc3b2a642d1499c262da04e6280 26-Jan-2012 Glenn Kasten <gkasten@google.com> Remove dead code

mFormat is unused in resampler
mClientTid is unused
local variable pid is unused in dump

Change-Id: Ib156e38029366620bfeff2a13e73471867155a5b
/frameworks/av/services/audioflinger/AudioFlinger.h
f587ba5b991c7cd91e4df093d0d796bd419e5d67 27-Jan-2012 Glenn Kasten <gkasten@google.com> Declare more IAudioFlinger methods const

This is just documentation, as C++ method const-ness doesn't mean anything
for a binder API. Instead, here const means "no side effects".

Change-Id: Iaa9cd2fe477db10ae9a40cac4f79f0faa9b4e5e6
/frameworks/av/services/audioflinger/AudioFlinger.h
c59c004a3a6042c0990d71179f88eee2ce781e3c 02-Feb-2012 Glenn Kasten <gkasten@google.com> AudioFlinger methods const and inline

This saves 1063 bytes and probably improves performance.

Change-Id: I11cf0dfd925fbaec75e3d1b806852a538eae5518
/frameworks/av/services/audioflinger/AudioFlinger.h
c19e22450e6e3d07594c935c7a9522e85e909e82 30-Jan-2012 Glenn Kasten <gkasten@google.com> Use virtual destructors

It turns out to be just a comment, as all except AudioMixer are RefBase.

There are only a few performance-sensitive cases where it's worth thinking
about whether you need a virtual destructor, and the headache usually
outweighs the benefit.

Change-Id: I716292f9556ec17c29ce8c76ac8ae602cb496533
/frameworks/av/services/audioflinger/AudioFlinger.h
787bae0578fbaab6219ebf23494866b224d01438 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_in_acoustics_t consistently"
87f155d6655b2d3b27e69281a29e85c6407e4d26 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "For performance, return large objects by reference"
84afa3b51ac48f84ed62489529ce78cba7fca00e 26-Jan-2012 Glenn Kasten <gkasten@google.com> Constructor initialization and const fields

In constructors, initialize member fields in the initialization list
rather than constructor body where possible. This allows more fields
to be const, provided they are never modified.

Also initialize POD fields in constructor, unless it's obvious they
don't need to be initialized. In that case, put a comment instead.

Remove explicit clear() in destructors on fields that are now const.

Give AudioSessionRef a default constructor, so it's immutable fields can
be marked const.

Add comment about ~TrackBase() trick.

Initialize fields in declaration order to make it easier to confirm that
all fields are set.

Move initialization of mHardwareStatus from onFirstRef() to constructor.

Use NULL not 0 to initialize raw pointers in initialization list.

Rename field mClient to mAudioFlingerClient, and getter from client()
to audioFlingerClient().

Change-Id: Ib36cf6ed32f3cd19003f40a5d84046eb4c122052
/frameworks/av/services/audioflinger/AudioFlinger.h
5c0ad10b14ec2287f90f95912d98e66eef006e2a 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Cleanup thread types"
d05397144be774f2f3623c754e865f51753e4e31 30-Jan-2012 Glenn Kasten <gkasten@google.com> For performance, return large objects by reference

Change-Id: Ibf737018ef1d3c7d717584615dcb2d4ecdb50c99
/frameworks/av/services/audioflinger/AudioFlinger.h
435dbe6c3ecd04bcb4bd80584064e287ebccd720 30-Jan-2012 Glenn Kasten <gkasten@google.com> Fix const sp<>& in parameter list and return value

EffectModule::addHandle and Client::heap() were declared incorrectly.

As a parameter, an sp<> should be & for efficiency, and for input
parameters it should also be const to protect the caller's value.

But as a return value, an sp<> should have neither const or &. The "e"
in "return e;" might be located on the stack, and if there is "&" then
the caller would see the address of a variable which no longer exists.
Also, an & would make it hard to do "return 0;".
A "const" without & is meaningless in the return type.
(In this particular case, the "e" is a member field, so it was safe.)

Change-Id: I3df5f294214eb15a9d4d596c6d5ef29de97b5c27
/frameworks/av/services/audioflinger/AudioFlinger.h
de9719b3ec71472e6bf75117152176af51d1a515 27-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_in_acoustics_t consistently

Change-Id: I0a9dd668fb2e57b1c3ece3190588194974b99062
/frameworks/av/services/audioflinger/AudioFlinger.h
a3a2cd4072aaa2d93c91251a786eb7323f8d2c27 27-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "AudioStreamIn and AudioStreamOut"
6f5980b75df837231365d238c1b0d6f386363fbb 27-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Declare methods in binder opcode order"
28f52c84c22e129063a576e1269a39ae0cc0bfb3 27-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use enum effect_state consistently"
114c458f2b80a252ec627add1d5fda2093c79068 27-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use enum track_state consistently"
aed850d0d3b3c8cf3feaf1438076f33db2a60946 26-Jan-2012 Glenn Kasten <gkasten@google.com> AudioStreamIn and AudioStreamOut

These are immutable, so make the fields const.
getOutput() and getInput() methods are now const.

Change-Id: I128246ebd56ea50b3e542be43f2aa1bcb55f1373
/frameworks/av/services/audioflinger/AudioFlinger.h
23bb8becff20449a9b1647d5a1a99b14c83f0cce 26-Jan-2012 Glenn Kasten <gkasten@google.com> Cleanup thread types

Use type_t instead of int for thread types.
Initialize ThreadBase::mType in constructor and make it const.

Change-Id: I43d141388b9639e4783c30b97dbda5688bf7555f
/frameworks/av/services/audioflinger/AudioFlinger.h
90716c5728b37637b2d0a730a721bfc9fad299e0 26-Jan-2012 Glenn Kasten <gkasten@google.com> Declare methods in binder opcode order

This makes it easier to compare interface and implementation.

Change-Id: Ie060e43dec348902abcf40f5a610cec639d6d0d3
/frameworks/av/services/audioflinger/AudioFlinger.h
29c23c3aee5ae799b3480dc6876a46c46b019710 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum mixer_state consistently

Change-Id: I5b71ed20f939dfc4b98143334b7aa064d282f584
/frameworks/av/services/audioflinger/AudioFlinger.h
28243dd563fee1c82f0fff6cc27b5cbf21fa2585 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum effect_state consistently

Also fix indentation

Change-Id: I393ef9e37ffceed5ad4a78df439726ae1fe139df
/frameworks/av/services/audioflinger/AudioFlinger.h
b853e986caf43408ad95b9014f194aadff385e3c 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum track_state consistently

Change-Id: Ie5ebb7befa092e1de1e4df9c6e2d51e6bcfd176a
/frameworks/av/services/audioflinger/AudioFlinger.h
335787fe43596f38ea2fa50b24c54d0823a3fb1d 21-Jan-2012 Glenn Kasten <gkasten@google.com> Remove AudioFlinger dependencies on client

Change-Id: Ibb591e41a3ca5d7015e2b66b98b8fef5f415fb37
/frameworks/av/services/audioflinger/AudioFlinger.h
58f30210ea540b6ce5aa6a46330cd3499483cb97 12-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_format_t consistently, continued

Was int or uint32_t.

When AudioFlinger::format can't determine the correct format,
return INVALID rather than DEFAULT.

Init mFormat to INVALID rather than DEFAULT in the constructor.
Subclass constructors will set mFormat to the correct value.

Change-Id: I9b62640aa107d24d2d27925f5563d0d7407d1b73
/frameworks/av/services/audioflinger/AudioFlinger.h
aeeb7e219e34d2d657d829913659a4e10e976375 19-Jan-2012 Eric Laurent <elaurent@google.com> resolved conflicts for merge of 05683c85 to master

Change-Id: I7846b7da8c5813b7a9b1f3f71aede0229689ff0d
2774144fa8283f1a7b43e17a53c97dec0c366dd3 18-Jan-2012 Eric Laurent <elaurent@google.com> AudioFlinger: mix track only when really ready (2)

This problem due to the way audio buffers are mixed when
low power mode is active was addressed by commits 19ddf0eb
and 8a04fe03 but only partially. As a matter of fact, when more
than one audio track is playing, the problem is still present.
This is most noticeable when playing music with screen off
and a notification or navigation instruction is played: in this case,
the music or notification is likely to skip.

The fix consists in declaring the mixer ready if all active tracks
are ready. Previous behavior was to declare ready if at least one track was
ready. To avoid that one application failing to fill the track buffer blocks other
tracks indefinitely, this condition is respected only if the mixer was ready
in the previous round.

Issue 5799167.

Change-Id: Iabd4ca08d3d45f563d9824c8a03c2c68a43ae179
/frameworks/av/services/audioflinger/AudioFlinger.h
ad0f6cc5e115ca167ff122c83451b46d85c590ac 17-Jan-2012 Glenn Kasten <gkasten@google.com> Remove dead setVolume() and mVolume[2]

Change-Id: I94b835434093e920432614eb5007101e87758f32
/frameworks/av/services/audioflinger/AudioFlinger.h
0696400a6bb9abbed62b3b9c6aa105495dc600a2 17-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_mode_t consistently"
263709e7be37c7040aaef385bc5c9389a9b5f514 06-Jan-2012 Glenn Kasten <gkasten@google.com> Check stream type in AudioFlinger::createTrack

A bad parameter to AudioFlinger::createTrack could cause mediaserver to crash.

Other AudioFlinger stream type cleanup:
- Simplify range check for audio_stream_type_t
- Add comment about mStreamTypes array initialization.

Change-Id: Ia33aa1cce0fdd694b08d9288816ffc097a9543d0
/frameworks/av/services/audioflinger/AudioFlinger.h
3944e0326a286bcb931551e61e79c033b10d09d4 17-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Fix locking for mMasterVolume and mMute"
613882293184e575a44bff681a3decaefe889e69 17-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use size_t for frame size"
9806710f5d6722cfc5783c7eca3512451a0f2035 13-Dec-2011 Glenn Kasten <gkasten@google.com> Fix locking for mMasterVolume and mMute

mMasterVolume and mMute are both protected by mutex in AudioFlinger class, but
there were two places where they were accessed without a mutex.

Also make AudioFlinger::mMasterMute private not protected.

Change-Id: Ia3897daeb5c50313df5bcc071824357526237f3e
/frameworks/av/services/audioflinger/AudioFlinger.h
b9980659501d0428d65d8292f3c32da69d37fbd2 11-Jan-2012 Glenn Kasten <gkasten@google.com> Use size_t for frame size

except in the control block, where we don't have room.

In AudioFlinger::ThreadBase::TrackBase::getBuffer,
read the frame size from control block only once.

Change-Id: Id6c4bccd4ed3e07d91df6bbea43bae45524f9f4e
/frameworks/av/services/audioflinger/AudioFlinger.h
fff6d715a8db0daf08a50634f242c40268de3d49 13-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_stream_type_t consistently

At native level it was a mixture of audio_stream_type_t, int, uint32_t,
and uint8_t. Java is still int. Also fixed a couple of hard-coded -1
instead of AUDIO_STREAM_DEFAULT, and in startToneCommand a hard-coded 0
instead of AUDIO_STREAM_VOICE_CALL.

Change-Id: Ia33bfd70edca8c2daec9052984b369cd8eee2a83
/frameworks/av/services/audioflinger/AudioFlinger.h
f78aee70d15daf4690de7e7b4983ee68b0d1381d 04-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_mode_t consistently

It was int or uint32_t.
Also make getMode() const.

Change-Id: Ibe45aadbf413b9158e4dd17f2b3bcc6355288d37
/frameworks/av/services/audioflinger/AudioFlinger.h
c40256146bee58bff09e1c16ef99ea06d31f89f9 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use correct type for hardware call state"
5f29ca38b71506ad7c7cb9925efbddf588e9655b 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "By convention const goes before the type specifier"
a4454b4765c5905f14186893b0688be375642283 04-Jan-2012 Glenn Kasten <gkasten@google.com> Use correct type for hardware call state

Change-Id: Ic6d98b129e3ec653df1d8f7e829adf8dccb4f378
/frameworks/av/services/audioflinger/AudioFlinger.h
54c3b66444ebfb9f2265ee70ac3b76ccefa0506a 06-Jan-2012 Glenn Kasten <gkasten@google.com> By convention const goes before the type specifier

Change-Id: I70203abd6a6f54e5bd9f1412800cc01212157e58
/frameworks/av/services/audioflinger/AudioFlinger.h
a3a854868a80fd9b9b8720e06a172754943f9417 04-Jan-2012 Glenn Kasten <gkasten@google.com> suspended() and isSuspended() are const

Change-Id: I04b95970b5a645b64e7e64fffd46d868354dda66
/frameworks/av/services/audioflinger/AudioFlinger.h
f6b1678f8f508b447155a81b44e214475ab634a8 15-Dec-2011 Glenn Kasten <gkasten@google.com> Use the standard CC_LIKELY and CC_UNLIKELY macros

Several source files privately defined macros LIKELY and UNLIKELY in terms
of __builtin_expect. But <cutils/compiler.h> already has CC_LIKELY and
CC_UNLIKELY which are intended for this purpose. So rename the private
uses to use the standard names.

In addition, AudioFlinger was relying on the macro expanding to extra ( ).

Change-Id: I2494e087a0c0cac0ac998335f5e9c8ad02955873
/frameworks/av/services/audioflinger/AudioFlinger.h
079123ee3d2e20bbc17a7ddbd96ca46bed27898f 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Improve resistance to leaks for ConfigEvent"
f3990f2cc8fd824ae52a880a7b22248e1bdfb192 13-Dec-2011 Glenn Kasten <gkasten@google.com> Improve resistance to leaks for ConfigEvent

A Vector of pointers is risky, as there is no ownership (and the
ThreadBase destructor was not deleting them, so if there were any left
over at end it would leak). Replaced by a Vector of values.

Change-Id: Iddde72dc30134adfcf724dec26cbe0a742509b8c
/frameworks/av/services/audioflinger/AudioFlinger.h
e0feee3da22beeffbd9357540e265f13b2119cbb 13-Dec-2011 Glenn Kasten <gkasten@google.com> Use NULL not 0 for pointers

Change-Id: Iab3f9abbdab617dc5a599e657ec46a0b0a002eef
/frameworks/av/services/audioflinger/AudioFlinger.h
162b40bbaf3c3a24f61a6636bef6f80a9c0a31dd 05-Dec-2011 Eric Laurent <elaurent@google.com> audioflinger: fix audio skipping over A2DP

The maximum sleep time allowed in the mixer thread when audio tracks
are enabled but not ready for mixing is derived from the latency
reported by the output stream.
This does not work for A2DP where the latency also reflects encoding, decoding
and transfer time.

Modified activeSleepTimeUs() to take A2DP case into account.

Issue 5682206.

Change-Id: I3784ac01fb6f836b5a6ce6f764fb15347586de35
/frameworks/av/services/audioflinger/AudioFlinger.h
544fe9b6e9325701df4ab8c1d29774fc13c4cf6c 12-Nov-2011 Eric Laurent <elaurent@google.com> audioflinger: fix noise when skipping to next song

When audio effects are enabled, a noise can be heard at the
beginning of the new song when skipping to next song in music app.

This is because some effects (especially virtualizer) have a tail.
This tail was not played when previous song was stopped because effects were
not processed when no tracks were present on a given session. This is to
reduce CPU load when effects are enabled but no audio is playing.
The tail was then rendered when the new song was started.

Added a delay before stopping effect process after all tracks have been removed from a session.

Issue 5584880.

Change-Id: I815e0f7441f9302e8dfe413dc269a94e4cc6fd95
/frameworks/av/services/audioflinger/AudioFlinger.h
a85a74a8219c03f2b1d1ef98f3f02e55f89f89a3 19-Oct-2011 Eric Laurent <elaurent@google.com> Fix issue 381905: BassBoostTest CTS tests fail...

When AudioEffectTest is executed, an Equalizer is created
and enabled on a MediaPlayer session. Effects on the output
mix are therefore suspended.
Then the MediaPlayer is released with the effect still enabled.
In this case, Audioflinger::purgeStaleEffects_l() fails to restore
the suspended effects when the effect attached to the released audio session
is removed.
When subsequent tests are executed on output mix effects, these effects cannot be
enabled as they are still suspended.

Fixed purgeStaleEffects_l() to restore suspended effects if the effect removed is enabled.

Also fixed EffectHandle::disconnect() to only restore suspended effects if the disconnected
handle actually has control over the effect.

Change-Id: I67232e7c34680b0cc01abfd57d5d510a524e5d4f
/frameworks/av/services/audioflinger/AudioFlinger.h
ec35a1416472865dbebc22b10199ad718ed2cc95 06-Oct-2011 Eric Laurent <elaurent@google.com> Fix issue 5381089: problem with A2DP music volume

This problem only occurs when audio effects are present and
the music volume is applied by one effect engine.
When connecting or disconnecting A2DP, audio effects are moved from
one mixer thread to another. When removed from the source thread,
the effect is stopped but it is not restarted when added to the
destination thread.
This regression was introduced by commit 21b5c47e.

Change-Id: I4cc578d8d760ec65b185032b6fda98c739d331bc
/frameworks/av/services/audioflinger/AudioFlinger.h
b76e90de3c64626fe07a68469d0a59a31c8efb6b 30-Aug-2011 Eric Laurent <elaurent@google.com> Merge "226483: A2DP connected, but music out to speaker"
9f6530f53ae9eda43f4e7c1cb30d2379db00aa00 30-Aug-2011 Eric Laurent <elaurent@google.com> 226483: A2DP connected, but music out to speaker

When the A2DP headset is connected, there is a possible
race condition when the audio tracks are moved from
the mixer thread attached to the speaker output to the thread
attached to A2DP output.
As the request to clear the stream type to output mapping cache in
the client process is asynchronous, it is possible that the flag
indicating to the client audio track to re-create the IAudioTrack
on the new thread is processed before the cache is invalidated.
In this case, the track will be attached to the old thread and
music will continue playing over the device speaker instead of being
redirected to A2DP headset.

Change-Id: Ib2ce1eb5320eaff83287b93779061bf4e7a330df
/frameworks/av/services/audioflinger/AudioFlinger.h
bee5337da7659b3b7128622ba1f42618b11df5be 29-Aug-2011 Eric Laurent <elaurent@google.com> Audioflinger: reverse logic of BT NREC indication

The interpretation of BT NREC by AudioFlinger to enable
or disable AEC and NS was wrong: NREC to ON (default) means
the phone (Audio Gateway) must enable local AEC and NS.

Change-Id: I88a264e7fc9831c43bbace4f6b585baec73f2006
/frameworks/av/services/audioflinger/AudioFlinger.h
db7c079f284f6e91266f6653ae0ec198b1c5006e 10-Aug-2011 Eric Laurent <elaurent@google.com> Audio effects: track CPU and memory use separately

Before this change, CPU and memory usage for an audio effect were
registered and checked against the limit by audio policy manager
upon effect instantiation. Even if an effect was not enabled
it would prevent another effect to be created if the CPU load budget
was exceeded, which was too restrictive.

This change adds a method to register/unregister CPU load only when
an effect is enabled or disabled.
It also adds a mechanism to place all effects on the global output mix
in suspend state (disabled) when an effect is enabled on a specific session.
This will allow applications using session effects to have the priority
over others using global effects.

Also fixes some issues with suspend/restore mechanism:
- avoid taking actions when an effect is disconnected and was not enabled.
- do not remove a session from the suspended sessions list when corresponding
effect chain is destroyed.

Change-Id: I5225278aba1ae13d0d0997bfe26a0c9fb46b17d3
/frameworks/av/services/audioflinger/AudioFlinger.h
3a34befc6fb04a4945a849e8bda8b84e4bf973fe 02-Aug-2011 Marco Nelissen <marcone@google.com> Keep effects sessions active when the caller dies.

Don't remove effects until the session they are in goes away or all
AudioEffects have been explicitly released. This allows the control
panel process to die without stopping the effects.

Change-Id: I4496e5df080230ca1af149dec95c1309ab8ea888
/frameworks/av/services/audioflinger/AudioFlinger.h
c3e6572e0ff535932b1f6ffb7bcf5acd891675fb 08-Aug-2011 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: protect input/output stream access"
b8ba0a979067a4efb0b3819bf17770793e41c15e 08-Aug-2011 Eric Laurent <elaurent@google.com> AudioFlinger: protect input/output stream access

Some methods would not check that the output orinput stream of a thread
was still valid before calling functions on its interface.
This could cause a crash if those methods where called while the output or
input was being closed by another thread.

Make sure that the output or input stream pointer is cleared before closing the
stream.
Always check that the output or input pointer is not null before calling
functions at the stream interface.
Generalize the use of initCheck() method to verify that the output or input
stream is not null.

Change-Id: I9d9ca6b744d011bcf3a7bbacb4a581ac1477bfa5
/frameworks/av/services/audioflinger/AudioFlinger.h
59bd0da8373af0e5159b799495fda51e03120ea4 01-Aug-2011 Eric Laurent <elaurent@google.com> AudioFlinger: disable AEC and NS with BT headsets

Disable AEC and NS when the Bluetooth SCO headset in use indicates it
implements those pre processings.

Change-Id: I93f3d10b0a27243d5dbff7182639576fc0c6d862
/frameworks/av/services/audioflinger/AudioFlinger.h
59255e4fc7d8ff52874b85b1988dc0785140cf81 28-Jul-2011 Eric Laurent <elaurent@google.com> Audio Effect Framework: add effect suspend/restore

Add the possibility for the effect framework to suspend
(temporarily disable process) and restore audio effects.
This feature will be usefull to disable pre processing under certain
conditions and better control coexistence of audio effects
on output mix and specific sources.

Change-Id: I79b195982cc48748d5708308fb1647b9c3c34cc6
/frameworks/av/services/audioflinger/AudioFlinger.h
a7280a59259018d997896c043fd2db95f631f12e 27-Jul-2011 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix crash when deleting pre process."
ec437d8d3db79459d7b19e1734e6fe309bd621e8 27-Jul-2011 Eric Laurent <elaurent@google.com> AudioFlinger: fix crash when deleting pre process.

If a pre processing effect is detroyed while enabled and capture is active,
there was a possibility that the effect engine is released by the framework
while still processed by the audio HAL.

The fix consists in not releasing the engine in EffectModule::removeHandle()
but just flag the effect as being detroyed to avoid further calls to functions
on the engine effect interface.
The effect interface is then removed from the audio HAL safely in
EffectChain::removeEffect_l() while holding the EffectChain mutex.

Change-Id: I71fab30d9145062af8644f545a1f1d4d3e7e7f02
/frameworks/av/services/audioflinger/AudioFlinger.h
feb0db689c17dced50afaee54c659f1676e2d505 22-Jul-2011 Eric Laurent <elaurent@google.com> Fix issue 4604090: notification sound interrupted.

The problem is that the audio HAL fails to acquire the wake lock when playing the notification.
This is because of a change that removed the mediaserver process form the system group for honeycomb.

The fix consists in requesting the wake lock from PowerManagerService when AudioFlinger mixer
wakes up.

A consequence of this change is that audio HALs or pcm drivers do not have to hold wake locks
anymore as in the past.

Change-Id: I4fb3cc84816c9c408ab7fec75886baf801e1ecb5
/frameworks/av/services/audioflinger/AudioFlinger.h
1d2bff0e588afe183a1baaae731519b4e957bbdb 25-Jul-2011 Eric Laurent <elaurent@google.com> AudioFlinger: add dump of audio pre processing.

Dump of media.audio_flinger service was only listing effects on output threads.
Moved the dump of effect chains from PlaybackThread to ThreadBase class so that
pre processings on RecordThread are also listed.

Change-Id: If8bc74023c12b9c2371f1b300743b156ceca7b87
/frameworks/av/services/audioflinger/AudioFlinger.h
7c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745 18-Jun-2011 Eric Laurent <elaurent@google.com> Audio framework: support for audio pre processing

Audio effect framework is extended to suport effects on
output and input audio path.

AudioFlinger: Support for audio effects and effect chains is
moved from PlaybackThread class to ThreadBase class so that
RecordThread can manage effects.
Effects of type pre processing are allowed on record thread
only. When a pre processing is enabled, the effect interface handle is
passed down to the input stream so that the audio HAL can call the
process function. The record thread loop calls the effect chain process
function that will only manage the effect state and commands and skip the
process function.

AudioRecord: The audio session is allocated before calling getInput() into
audio policy serice so that the session is known before the input theead is
created and pre processings can be created on the correct session.

AudioPolicyService: default pre processing for a given input source are
loaded from audio_effects.conf file.
When an input is created, corresponding effects are created and enabled.

Change-Id: Id17119e0979b4dcf189b5c7957fec30dc3478790
/frameworks/av/services/audioflinger/AudioFlinger.h
7394a4f358fa9908a9f0a7c954b65c399f4268e6 14-Jun-2011 Dima Zavin <dima@android.com> audio: update for audio/audio_policy header names/locations

Change-Id: I36c49352eee57559403cd1597f56a8485a360289
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
0d255b2d9061ba31f13ada3fc0f7e51916407176 25-May-2011 Jean-Michel Trivi <jmtrivi@google.com> Use channel mask instead of channel count for track creation

Record and playback objects (resp AudioRecord and AudioTrack)
are created using a channel mask, but this information is lost
in the mixer because only the channel count is known to
AudioFlinger. A channel count can always be derived from a
channel mask.

The change consists in:
- disambiguiting variable names for channel masks and counts
- passing the mask information from the client to AudioFlinger
and the mixer.
- when using the DIRECT ouput, only verifying the format of
the track is compatible with the output's for PCM.

Change-Id: I50d87bfb7d7afcabdf5f12d4ab75ef3a54132c0e
/frameworks/av/services/audioflinger/AudioFlinger.h
65580f9adf6c4d98449ad0716488f9fe3869aa5a 28-May-2011 Eric Laurent <elaurent@google.com> Removed interface to load audio effects libraries

Removed unused functions allowing dynamic loading of audio effects libraries
from effects factory API.

Change-Id: I06cc5a51dc10aca87c7a8687bbb874babd711eca
/frameworks/av/services/audioflinger/AudioFlinger.h
e1315cf0b63b4c14a77046519e6b01f6f60d74b0 18-May-2011 Eric Laurent <elaurent@google.com> New effect library API

Moved and renamed media/EffectApi.h to hardware/audio_effect.h
Modified the effect library API to expose a library info structure
containing an interface functions table.
Also removed enums for audio channels, audio format and devices
from effect API and use values from system/audio.h instead.

Modified effects factory to support new library interface format and
load libraries and efffects listed in audio_effects.conf file.
The file audio_effects.conf is first loaded from /vendor/etc and
then from /system/etc/audio_effects.conf if not found.

Modified existing effect libraries to implement the new library interface.

Change-Id: Ie52351e071b6d352fa2fbc06c3846686f8c45df9
/frameworks/av/services/audioflinger/AudioFlinger.h
6708b9a3fb654f5623ba5a696288fdba310a5e1a 13-May-2011 Eric Laurent <elaurent@google.com> Merge "Fix audio effect framework issues"
b469b9490b3cd9e0f0466d9b9ab228f6c793b82e 09-May-2011 Eric Laurent <elaurent@google.com> Fix audio effect framework issues

Fix two issues in audio effect framework reported by partners.

1 - Fixed duplicated audio buffer sent to effect process function when
pausing a track.
Modified Effectchain::process_l() function to clear the effect chain
input buffer before calling the effect process functions when no track
is active on the session. Previous code was clearing the buffer after
calling the process functions and when transitioning from active
to inactive, the last processed buffer was passed again once to effect
process function before being cleared.

2 - Fixed potential mutex cross deadlock when disconnecting an effect
while playback is active. This is because EffectChain::process_l()
was calling PlaybackThread::hasAudioSession() thus creating an inversion
in the mutex lock order (EffectChain mutex locked before ThreadBase mutex).
The fix consists in removing the call to hasAudioSession() from process_l()
and requires each effect chain to keep count of the number of audio tracks
attached to it (previously only the active tracks were accounted for).

Change-Id: Iee4246694ea8c7a66c012120c629d72dd38f9c35
/frameworks/av/services/audioflinger/AudioFlinger.h
64760240f931714858a59c1579f07264d7182ba2 11-May-2011 Dima Zavin <dima@android.com> update for new audio.h header location

Change-Id: Ic4c62c4037800802427eb7d3c7f5eb8b25d18876
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
5a61d2f277af3098fc10b2881babca16391362da 20-Apr-2011 Dima Zavin <dima@android.com> audioflinger: don't do work in constructor, instead do it in onFirstRef

Change-Id: I22d9e01821816c3beb52b014330386c7fd2f0411
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
799a70e7028a4d714436c3a744a775acfbd31aae 19-Apr-2011 Dima Zavin <dima@android.com> audioflinger: enumerate all the possible audio interfaces

Keep track of the primary interface that handles the master volume,
etc.

Change-Id: Ib0701fccff8d8783a99035a241ab7c8ec75c00ac
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
fce7a473248381cc83a01855f92581077d3c9ee2 20-Apr-2011 Dima Zavin <dima@android.com> audio/media: convert to using the audio HAL and new audio defs

Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/services/audioflinger/AudioFlinger.h
117cd9286424888c1c5bf202ebf1e08ae1e6affe 04-Feb-2011 Glenn Kasten <gkasten@google.com> Merge "Bug 3366885 Remove LVMX switch"
db130fbd3ccd37e247e49494a84f8a9841ecd593 04-Feb-2011 Glenn Kasten <gkasten@google.com> Bug 3366885 Remove LVMX switch

Change-Id: I0bf98c6f85f00b3296874571e1c049dcc4e2fcca
/frameworks/av/services/audioflinger/AudioFlinger.h
eda6c364c253ba97ee45a3adeb8c2b45db1f81db 02-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3371080

Modified default volume control logic in AudioService:
1 IN_CALL volume if in video/audio chat
2 NOTIFICATION if notification is playing or was playing less than 5s ago.
3 MUSIC

Modified silent mode:
- now also affect MUSIC stream type
- entering silent mode when VOL- hard key is pressed once while selected
stream volume is already at 0 (except for VOICE_CALL stream).
- exiting silent mode when pressing VOL+ hard key while in silent mode

Play sound FX (audible selections, keyboard clicks) at a fixed volume.

Modified audio framework:
- isStreamActive() method now implemented in AudioPolicyManagerBase (previously AudioFlinger)
- iStreamActive() now specifies a time window during which the stream is considered
active after it actually stopped.

Change-Id: I7e5a0724099450b9fc90825224180ac97322785f
/frameworks/av/services/audioflinger/AudioFlinger.h
f5aafb209d01ba2ab6cb55d1a12cfc653e2b4be0 18-Nov-2010 Eric Laurent <elaurent@google.com> Fix issue 3157123.

Use a Mutex wherever atomic operations were used in AudioTrack,
AudioRecord, AudioFlinger and AudioEffect classes.

Change-Id: I6f55b2cabdcd93d64ef19446735b8f33720f8dbc
/frameworks/av/services/audioflinger/AudioFlinger.h
8f45bd725549436eeacd12ee69349e2332ed8da5 31-Aug-2010 Eric Laurent <elaurent@google.com> Audio Effects: fix problems in volume control.

- Fixed click when re-enabling effect during the turn off phase:
make sure the effect states where effect is processed are the same
where volume control is delegated to effect.
- Fixed click when effect is deleted while still active: do not apply
volume ramp if an effect having volume control was just removed from the
effect chain.

Also fixed a crash when PCM dump is enabled in effect bundle wrapper.

Change-Id: Ib562f5cf75c69af75df0e862536262e2514493e4
/frameworks/av/services/audioflinger/AudioFlinger.h
25cbe0ecd6df8be7e40537c5d85c82f105038479 19-Aug-2010 Eric Laurent <elaurent@google.com> Fix issue 2929440

Fixed regression introduced by change a54d7d3d7dd691334189aab20d23c65710092869 in audioflinger mixer thread:
When the output stream is suspended, the sleep time between two writes must match the actual duration
of one output stream buffer otherwise the playback rate is not respected.

Change-Id: Ic5bebe890290d1f44aeff9dd3c142d18e26fff2a
/frameworks/av/services/audioflinger/AudioFlinger.h
39e94f8f723d445447fdee0822291e664b631f60 28-Jul-2010 Eric Laurent <elaurent@google.com> Allow creation of an audio effect on a session with no audio tracks.

This is necessary to allow creating and enabling an effect attached to a particular player
session before the playback is started. As a matter of fact, the implementation of the mediaplayer
does not create the AudioTrack before playback starts.

Change-Id: I1266e8885f9d756acc949303321aaac0fbf83e34
/frameworks/av/services/audioflinger/AudioFlinger.h
25f4395b932fa9859a6e91ba77c5d20d009da64a 28-Jul-2010 Eric Laurent <elaurent@google.com> Audio effects: modified command() parameter types.

The type of the cmd, cmdSize and *pReplySize parameters of the effect control interface command()
function have been modified from int to uint32_t. This is more consistent with their role.

Change-Id: I84d289fc262d6753747910f06f485597dfee6591
/frameworks/av/services/audioflinger/AudioFlinger.h
de070137f11d346fba77605bd76a44c040a618fc 13-Jul-2010 Eric Laurent <elaurent@google.com> Audio policy manager changes for audio effects

Added methods for audio effects management by audio policy manager.
- control of total CPU load and memory used by effect engines
- selection of output stream for global effects
- added audio session id in parameter list for startOutput() and stopOutput().
this is not used in default audio policy manager implementation.

Modifications of audio effect framework in AudioFlinger to allow moving and reconfiguring
effect engines from one output mixer thread to another when audio tracks in the same session
are moved or when requested by audio policy manager.
Also fixed mutex deadlock problem with effect chains locks.

Change-Id: Ida43484b06e9b890d6b9e53c13958d042720ebdb
/frameworks/av/services/audioflinger/AudioFlinger.h
f997cabca292d70d078ae828e21c28e6df62995f 19-Jul-2010 Eric Laurent <elaurent@google.com> Fixed problems in audio effect volume control.

Fixed the following problems in audio effect volume control in AudioFlinger:
- Make sure that the volumes returned by EffectChain::setVolume_l() are correct even is
no change is detected since last call
- Do not use isEnabled() to validate volume control but mState >= ACTIVE instead as the volume control
must be also active in STOPPING and STOPPED states.

Change-Id: Id62da3164fad500ee8a5efd6cd78c77e8fdcb541
/frameworks/av/services/audioflinger/AudioFlinger.h
cab112421da6e8eac19ffddbbe3d76067cffee78 15-Jul-2010 Eric Laurent <elaurent@google.com> Several improvements in audio effects volume control.

- Fixed crash when deleting an effect chained before an effect having volume control
- Changed EFFECT_FLAG_VOLUME_CTRL to implicitely include EFFECT_FLAG_VOLUME_IND
(not need to set both in effect descriptor).
- Volume control changes from one effect to another if needed according to effect enable state
- EFFECT_CMD_SET_VOLUME is only sent when their is an actual change in volume

Change-Id: Ieebaf09157e2627366023569d95516646e03e26c
/frameworks/av/services/audioflinger/AudioFlinger.h
5462fc9a38fa8c9dff434cd53fa5fb1782ae3042 15-Jul-2010 Mathias Agopian <mathias@google.com> added BinderService<> template to help creating native binder services

Change-Id: Id980899d2647b56479f8a27c89eaa949f9209dfe
/frameworks/av/services/audioflinger/AudioFlinger.h
65ab47156e1c7dfcd8cc4266253a5ff30219e7f0 15-Jul-2010 Mathias Agopian <mathias@google.com> move native services under services/

moved surfaceflinger, audioflinger, cameraservice

all native services should now reside in this location.

Change-Id: Iee42b83dd2a94c3bf5107ab0895fe2dfcd5337a8
/frameworks/av/services/audioflinger/AudioFlinger.h