• Home
  • History
  • Annotate
  • only in /frameworks/av/services/audioflinger/
History log of /frameworks/av/services/audioflinger/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
cfa5bf04ff250a14b11a75bcfa35ee2d6dbab4e9 07-Jan-2015 Chong Zhang <chz@google.com> Merge "make libserviceutility a shared lib" into lmp-mr1-dev
5db7897ddd32e3ec3ab45ecdb6f21b6265e7e14a 07-Jan-2015 Chong Zhang <chz@google.com> make libserviceutility a shared lib

so that we have only one getpid_cached in mediaserver process

bug: 18919657

Change-Id: Iff3cd932c9110e874b3885f79705f49bf3e3f1fc
ndroid.mk
610255e8f2d02cb3513695eacf1c37d66b3553d6 07-Jan-2015 Eric Laurent <elaurent@google.com> Merge "audioflinger: pause HW A/V sync output when AudioTrack underruns" into lmp-mr1-dev
e443ffac2a09b69470c4663ee031a527c53738d9 05-Jan-2015 soon1.choi <soon1.choi@lge.com> DO NOT MERGE - fix memory leak in PatchPanel

Before the audio patch is created, audio patch with same handle is
removed from vector for patches. At this time, Patch allocated in the
heap is not freed. This causes memory leaks in the mediaserver.

Bug: 18904322.

Change-Id: Id0d28c36a7e7fbf473753bf4ead7518f28c1b998
atchPanel.cpp
0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d 19-Dec-2014 Eric Laurent <elaurent@google.com> audioflinger: pause HW A/V sync output when AudioTrack underruns

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

Bug: 17883772.

Change-Id: I11e6c97ec24360d75f9b602814d40a54b60cb7a7
hreads.cpp
hreads.h
145cf5d885c238b690ab8240137934327b85c427 17-Dec-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: implement pause/resume for direct outputs" into lmp-mr1-dev
97bb33f58d742539f3382583d7978fca71ffa2d5 13-Dec-2014 Jean-Michel Trivi <jmtrivi@google.com> Fix permission check for audio recording

Define input types covering the different usecases for audio
recording, and check the corresponding permissions when
starting to record.
Move the permission check from audio flinger to audio policy,
as only the policy has the information to determine which
permission to enforce.
Fix missing permission when an application records audio
and the audio is injected by an external policy.

Bug 18736417

Change-Id: If7ec040502242c990ac8ea464db484339bdce573
udioFlinger.cpp
d1f69b0b17acbd96987ecb2f3378abd394d05903 15-Dec-2014 Eric Laurent <elaurent@google.com> audioflinger: implement pause/resume for direct outputs

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

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

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

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

Bug: 17883772.
Change-Id: I89b360d69818f7a9204bd36e3ec63a79e106ecf1
hreads.cpp
hreads.h
racks.cpp
94a92c69af528edf6ec17d7978a0c3bb6ab51e63 11-Dec-2014 Phil Burk <philburk@google.com> Merge "[audio][audioflinger] Consume all frames when a DirectThread is done." into lmp-mr1-dev
99adee3c3d9cde6819741a38163954808fea270a 11-Dec-2014 Phil Burk <philburk@google.com> [audio][audioflinger] Consume all frames when a DirectThread is done.

This bug was causing movies to think there was still data left to play so they never finished.

Bug: 18360054
Change-Id: If7aee81d62b7af8532abd14579677848a06fe2b1
Signed-off-by: Phil Burk <philburk@google.com>
hreads.cpp
275e8e9de2e11b4b344f5a201f1f0e51fda02d9c 01-Dec-2014 Eric Laurent <elaurent@google.com> audio policy: add support for custom mixes

Add support for custom mixes in AudioPolicyManager.

Two methods are added to register or unregister a list of custom mixes
with their attributes and format.

getOutputForAttr() and getInputForAttr() first look for a match in
registered mixes before defaulting to normal output/input selection

Remote submix device connection disconnection now takes address into
account to identify the correspnoding custom mix.

Bug: 16009464.

Change-Id: I3f1c2a485a0fb71b1f984ed0adc9b68aa971e408
hreads.cpp
9a1c8892f6835325db6931529dc74bf98cf0aee8 03-Dec-2014 Andy Hung <hunga@google.com> Fix getTimestamp if offload thread is not initialized.

Returns INVALID_OPERATION.

Bug: 18605649
Change-Id: I440fb687fbf9249098e049982fa83bcd1515fd80
hreads.cpp
e83b55dc29ca16092ba02f36f55fa6e0e37fd78c 14-Nov-2014 Eric Laurent <elaurent@google.com> audio policy: new getOutputForAttr() prototype.

Update getOutputForAttr() prototype and group all logic
dealing with audio attributes to stream type conversion in
audio policy manager.

getOutputForAttr():
- specifies the audio session (for future use)
- returns a status code
- receives either stream type (for legacy) or audio attributes
- returns an updated streamtype

Remove logic dealing with legacy stream types to attributes conversion
from AudioTrack.

Use correct type for audio sessions in other APIs (startOutput() ...).

releaseOutput() specifies the audio session (for future use).

Bug: 18067208.

Change-Id: I1bfbe9626c04c7955d77f8a70aecfad2cb204817
hreads.cpp
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
racks.cpp
ec0eeafa8a7fd882e8206e9cf8c4c7e1db81857b 20-Nov-2014 Haynes Mathew George <hgeorge@codeaurora.org> Fix format conversion in DuplicatingThread

DuplicatingThread converts PCM data from the format of the source thread
to PCM_16BIT before writing to all connected output tracks.
This needs to be done just once before writing to all tracks.

Bug: 18461844
Change-Id: If05254f87f9198e09a0fa3c4e857afbb53ae7073
hreads.cpp
27876c02c21cd3ab7ef01bdd1fc5400c5143584a 10-Sep-2014 Andy Hung <hunga@google.com> Prevent stopped audio tracks from mixing data

Static tracks should have zero framesReady when stopping or stopped,
to prevent mixer from running potentially indefinitely with loop mode.

Bug: 16070883

Change-Id: Iab9968044d1a6f8543bbcbfb246f49f27d68cace
racks.cpp
02b5708776ba2a9b4ff8c09008483aef7dbe38c7 08-Nov-2014 Eric Laurent <elaurent@google.com> audioflinger: fix duplicating thread output buffers clear

Also clear mix buffer in DuplicatingThread::threadLoop_mix()
instead of just sink buffer when output threads are not
ready.

Bug: 18262127.
Change-Id: I4c22bbeaccdcc8d7c10c5882dde3439eb73d6ede
hreads.cpp
b10352f4bc11ae6f3d93e464074709555ecf9e06 04-Nov-2014 Eric Laurent <elaurent@google.com> remove some restrictions on effect output channels

Do not prevent from attaching effects to a non stereo
output thread, unless the output thread is a mixer thread.

Bug: 18157592.
Change-Id: I6ac3187187a1b8aade7db04ea6dfbc47dacc25c3
udioFlinger.cpp
fd4c14883b268a0bc5514da135fe6b7d1ce2071b 07-Aug-2014 Jean-Michel Trivi <jmtrivi@google.com> Always use an address for remote submix

Usage of remote submix device for audio rerouting (e.g. wifi display)
didn't mandate the use of addresses. Use "0" as the default address
when none is specificed.
In logs, only use hex format for audio devices

Bug 16009464

Change-Id: Ibfb1ce6881eba8b7e34420293b8a7077a6e659e6
udioFlinger.cpp
9d0d5958969cffae5d4305025bc20d05f32e6ff2 22-Oct-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: new HW A/V sync ID allocation flow" into lmp-mr1-dev
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
udioFlinger.cpp
udioFlinger.h
36d9256f956b2ed4d7a221d84ad05bf4ba482958 20-Oct-2014 Marco Nelissen <marcone@google.com> am ac302143: Fix the fix

* commit 'ac302143551a8b964f026385a524dda9ff8ea5ba':
Fix the fix
ac302143551a8b964f026385a524dda9ff8ea5ba 20-Oct-2014 Marco Nelissen <marcone@google.com> Fix the fix

We need to clear the buffer a little more often.

Bug: 18023017
Change-Id: If8a522b9133a4269e2435af8958f6ced322e71e9
hreads.cpp
145a4c679a9ab27aceaa1d386ea9aca1c0cd4d33 20-Oct-2014 Marco Nelissen <marcone@google.com> am 22bc10a3: Merge "Clear effect buffer before sending to chain" into lmp-dev

* commit '22bc10a347569a0ab2980c24783e31aba4d7414d':
Clear effect buffer before sending to chain
57088b5c8e76855b99b3e6b3e410de5b6382670e 18-Oct-2014 Marco Nelissen <marcone@google.com> Clear effect buffer before sending to chain

otherwise the effect might get a buffer with previous data instead
of silence.

Bug: 18023017
Change-Id: Ic6be5ce0e74552aac2a0cce9c660893f9ad27f5c
hreads.cpp
f53eaf49df1e1e1c01708919e9e0a046543de9b6 09-Oct-2014 Hochi Huang <hochi.huang@mediatek.com> fix FM no sound issue

Review: https://partner-android-review.git.corp.google.com/#/c/184276

Signed-off-by: Carson Liao <carson.liao@mediatek.com>

Change-Id: I0847c8a6e6d054a9258b52402c914105d902c573
erviceUtilities.cpp
erviceUtilities.h
2b217bb3aee87ce8486014f261c0f498f6209e80 03-Oct-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix pre processing transfer between record threads." into lmp-dev
1b92868010b5c1409692a86f6b27e4a265b64c1a 03-Oct-2014 Eric Laurent <elaurent@google.com> audioflinger: fix pre processing transfer between record threads.

Fix two problems remaining with pre processing effects transfer from
one record thread to the next in case of tear down due to device connection:
1 - the enabled state of the effects was not communicated to the new HAL
input stream.
2 - the effects saved in orphan chains list were not transfered to the
new thread when a AudioRecord was created.

Bug: 17757378.
Change-Id: I0923c98470db3b51154dc89846157780a4c21e86
udioFlinger.cpp
ffects.cpp
ffects.h
hreads.cpp
4c053ea158b29fa2cdd4c6f39d3c8da4ee5a7a02 28-Sep-2014 Glenn Kasten <gkasten@google.com> Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp

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

Bug: 17531839
Bug: 17669342
Change-Id: I9d50c8c6a5de55a3f4561ac40e20d497376c1257
hreads.cpp
hreads.h
racks.cpp
cb4b6e9f05d1c0b3fcc5be5ebe3f7d6f32669b1a 01-Oct-2014 Eric Laurent <elaurent@google.com> audioflinger: fix failure to indicate volume to effect

If an effect is added and enabled after a track is started
it will not receive current volume information because volume
is indicated only to active effects and if there is a volume change.

Add a flag to force EffectChain::setVolume_l() to pass volume indication
to all effects each time an effect is enabled.

Bug: 17572556.

Change-Id: I6b68488c9aca8b2095fb210aa124d02e4f759660
ffects.cpp
ffects.h
a49c94ea49c8329a1bdefe980e1f7d335c0d1ec5 02-Oct-2014 Glenn Kasten <gkasten@google.com> Merge "Revert "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp"" into lmp-dev
6954127b7ace022677ac407ff943c2793f8a11be 02-Oct-2014 Glenn Kasten <gkasten@google.com> Revert "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp"

This reverts commit 54464ba861aaafd11ee5645f5d1ecd1171c6e9fe.

Bug: 17733142.

Change-Id: I9886d40032b2f7d96bee03e600e14f78943d8052
hreads.cpp
hreads.h
racks.cpp
955e24d3a8e218d4711cabc6558781e095011132 30-Sep-2014 Glenn Kasten <gkasten@google.com> Merge "Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp" into lmp-dev
f71224ce266abb39f83ecba87783c2347631654a 30-Sep-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: forward flush to direct output streams" into lmp-dev
54464ba861aaafd11ee5645f5d1ecd1171c6e9fe 28-Sep-2014 Glenn Kasten <gkasten@google.com> Fix uncertainty of one normal mix buffer in AudioTrack::getTimestamp

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

Bug: 17531839
Bug: 17669342
Change-Id: I96252782911bd42a2534cc4030521b7eeb99a7b9
hreads.cpp
hreads.h
racks.cpp
e659ef420dae0caae84ab78f9df8952acb9ad3a0 29-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: forward flush to direct output streams

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

Bug: 17704953.
Change-Id: Iafc94327fe9aebf1d4eaa97b76c6767b7ac5babe
hreads.cpp
hreads.h
racks.cpp
ba0b34c18da93681c0813ecdab19b0e215b6d261 28-Sep-2014 Glenn Kasten <gkasten@google.com> Fix tee sink

Note: this does not fix the bug below, but it helps to investigate the bug.

Bug: 17578238
Change-Id: I0fd27a477b73ba0e1c5a658bdfad17c500f5dc67
hreads.cpp
80b617cf82e0030deef4f968a6341e2867166135 17-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: remove debug log.

Remove debug log left by commit ab5cdbaf.

bug: 17537746.
Change-Id: I10f672f607f8e87caaa8228fc05eff8aee7dfa15
hreads.cpp
cf7863ea8d9137aadf6bfd9756eb07ebd1c81b5c 15-Sep-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix pre processing effect leak" into lmp-dev
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
udioFlinger.cpp
udioFlinger.h
ffects.cpp
ffects.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
2f035f59d1e28728d38d18a7f0f7a9c6e8b0c11b 14-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: send mic mute command to all audio HALs

Mic mute should be sent to all audio HALs, not
only the primary HAL as telephony can use
capture devices on other HALs (e.g USB)

Bug: 17321604.
Change-Id: I658f6084d5b5cdc5a70784661d5cea0b6f81c3a9
udioFlinger.cpp
f8fd8d6daab5ced86ce950be68070d27c24d487f 10-Sep-2014 Eric Laurent <elaurent@google.com> audioflinger: fix audio patch release

Fix error in PatchPanel:releaseAudioPatch() causing
the wrong patch handle to be passed to the audio HAL.

Bug: 17368621.
Change-Id: I037fd2e6273508c830414b5900d07c0178b96dae
atchPanel.cpp
3abc2ded40066f3b1df23aceb553f22d569c5cd3 06-Sep-2014 Glenn Kasten <gkasten@google.com> Make IPowerManager native conform to .aidl for oneway

But provide a temporary escape hatch for AudioFlinger.
This oneway option will be removed as soon as possible.

Bug: 16408906
Change-Id: I058a50906af810787e444a96819cb781b7f639ad
hreads.cpp
23c8cf958b1a756d5e0c78c46eac676676be4fdd 03-Sep-2014 Glenn Kasten <gkasten@google.com> Merge "Restore the ability to build tee sink for debugging" into lmp-dev
97d547da43c9c41711d1ed1e3f4fa87c2ee3cb9a 02-Sep-2014 Eric Laurent <elaurent@google.com> audio flinger: fix use of global effect buffer

When float mixing format is enabled, audio effects use a specific
buffer in 16 bit format. This buffer was not enabled when only
global effects were present resulting in the mixer accumulating directly
to the output sink buffer.

Bug: 16202259.
Change-Id: I3537d36c63196d97772f0ab22dd31d04dfa7fdd6
hreads.cpp
329f6511ee4e03a4605c70bbda8d3a96d2544884 29-Aug-2014 Glenn Kasten <gkasten@google.com> Restore the ability to build tee sink for debugging

This changelist does not enable tee sink, but makes it possible to do so.
Tee sink had suffered some bit rot since it is not built by default.

Also fixes a crash for > 2 byte per sample or > 2 channels.
Still does not write correct header for floating-point;
that will be best solved by moving to libsndfile.

Bug: 16990102
Change-Id: I8e92c588ccc513d7802d696fcfb324e815772df6
udioFlinger.cpp
astMixer.cpp
racks.cpp
395db4bfa5b43a839f95632676d59cde99a9840d 26-Aug-2014 Andy Hung <hunga@google.com> Fix AudioMixer MONO muted track handling

Incorrect handling caused "stereo" mode to be used.
Augmented error handling to print more debug info.

Bug: 17208475
Change-Id: I5bcaf0ba5bd5a4f7d4885f8cce43bbf42e5f1e6b
udioMixer.cpp
735f45fbc37d7905ffb722f40727edbed82319b7 19-Aug-2014 Glenn Kasten <gkasten@google.com> Fix memory access error due to race during fast track removal

Bug: 16205169
Change-Id: Ie15ec2a737b6ddd16b2d26030d01564ff70177f5
hreads.cpp
49d00ad9164ea5ce48c85765a2b6460d9b457d38 21-Jul-2014 Glenn Kasten <gkasten@google.com> Fix overruns when capturing with resampling

Bug: 16658148
Change-Id: I2dd04b23a143e0948b299d408790e7a46b5a53b0
hreads.cpp
e7a1737c92cf2e84754ffbc52cfec8edeffcbc75 12-Aug-2014 Ricardo Garcia <rago@google.com> Merge "Fix to support mono in effect buffer allocation." into lmp-dev
726b6a7540ac997928df1a14dfede872a82f6210 11-Aug-2014 Ricardo Garcia <rago@google.com> Fix to support mono in effect buffer allocation.

Since effects are now enabled for recording, mono cases are possible
and needed to be correctly allocated.

Bug: 16917961
Change-Id: I760fc421f9f90fabb3f0deadd5f9dc61cd284371
ffects.cpp
cd04484f4837b8ca0041d118286ab6a98e84fc75 07-Aug-2014 Andy Hung <hunga@google.com> Extend downsampling ratios greater than 2:1

Also improve robustness to choice of sampling rate or buffer size
such that increasing either by 10x does not cause overflow.

Bug: 12979141
Bug: 15933066
Change-Id: If7989bd745d1bee3bdf811b8b7c978543ccafb65
udioResamplerDyn.cpp
hreads.cpp
874c4287a4e49c59ac88767751dce00fcd3edb73 09-Aug-2014 Eric Laurent <elaurent@google.com> audio policy: enable more than one sink per audio patch.

Allow creation of audio patches with more than one sink.
More than one sink is enabled when:
- Connecting an input device to output devices on the same audio HW module.
- Connecting an output mix to output devices on the same audio HA module.

All other patches are limited to one sink.

Bug: 16879363.
Change-Id: I95be6948ef29df64e51e5b8ace38c2db7f3e89f2
atchPanel.cpp
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
udioFlinger.h
hreads.cpp
7f04ec2a4ec94ada7ef89db8c50fd1e5c3a93a3b 07-Aug-2014 Eric Laurent <elaurent@google.com> Merge "audio policy: add support for USB devices for voice call" into lmp-dev
c2730ba7c5e9559b7499ef5e0d7742deb18c5110 21-Jul-2014 Eric Laurent <elaurent@google.com> audio policy: add support for USB devices for voice call

Add possibility to use sink and source devices not on
the primary HW module for voice calls (e.g. USB headsets).

Bug: 15520724.

Change-Id: Ib27db4ba759b6d91ea1104dc2e35c87733517b30
racks.cpp
0a0e5f02037f396237461a9840b2fc7271812bdc 06-Aug-2014 Eric Laurent <elaurent@google.com> Merge "AudioSystem: add API to query audio HW sync source" into lmp-dev
7f3f2fa386b8dd917022663bcb01f10ea67061be 06-Aug-2014 Ricardo Garcia <rago@google.com> Merge "MediaServer crashing and audio effects not applied to TTS." into lmp-dev
322bab26dc3fe9bd9c1cbb829dc62ff44f1ae810 06-Aug-2014 Ricardo Garcia <rago@google.com> MediaServer crashing and audio effects not applied to TTS.

A memclear in the EffectChain was out of bounds.

Bug 15432115
Bug 16845751

Change-Id: Ib0adc7fa730d630bb71fb87d51163a26149b16e2
ffects.cpp
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
udioFlinger.cpp
udioFlinger.h
cf817a2330936947df94c11859f48771f5596a59 05-Aug-2014 Eric Laurent <elaurent@google.com> audio: fix crashes upon USB device connection

- Audio policy:
Replace unknown device assertion by debug log in setDeviceConnectionState().
It is possible that some kernels indicate connection of a legacy device type
when a USB audio device is connected.
We should just ignore this device.

- Audio flinger:
Make sure FastMixer thread is idle before exiting the normal mixer thread and
closing the output stream.

Change-Id: Ia10a20176a60a8aa56765538093a555fc998508a
hreads.cpp
7a9b25940309e2967820daa13a7f71e41293d165 05-Aug-2014 Andy Hung <hunga@google.com> Merge "Remove unused TwoTrack process mode from AudioMixer" into lmp-dev
5241b8cacee86e17223695190959f4752910680f 05-Aug-2014 Andy Hung <hunga@google.com> Remove unused TwoTrack process mode from AudioMixer

Legacy code that has not been hooked up.

Change-Id: Ic01a4eddfa1020089d5bc42f58b6a4697698c27a
udioMixer.cpp
udioMixer.h
44622db93a24219123facbbe14259000f90de728 02-Aug-2014 Eric Laurent <elaurent@google.com> audio flinger: fix service fuzz test crash

Bug: 13744704.
Change-Id: I572c89f88dcab2b8b612ec6860983306f9f159ab
udioFlinger.cpp
e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f 16-Jul-2014 Hans Boehm <hboehm@google.com> Remove 64-bit android_atomic uses from StateQueue.

Use stdatomic.h instead. We're trying to remove android_atomic use
wherever possible. The 64-bit uses seem easiest to remove first.
This cleans up the code, though not as much as C++ <atomic> would,
if it worked everywhere.

(cherry picked from commit f39b560952d3706a7ff47ef0d82c1a836daeea42)
Change-Id: I3c29bdbd5915cb9d47118834a3a742fe296cf87f
tateQueue.cpp
tateQueue.h
318be3e7d245aea99efa194a16002395b609ab90 30-Jul-2014 Andy Hung <hunga@google.com> Merge "Enable multichannel in AudioFlinger" into lmp-dev
a4daf0b4f934b800a49f199fb8c09409391c8fc0 29-Jul-2014 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: Ife5e40264f43fb3ccb40830228701003fe106bf5
udioMixerOps.h
udioResamplerDyn.cpp
udioResamplerFirProcess.h
ests/resampler_tests.cpp
ests/test-mixer.cpp
ests/test_utils.h
b1ee3954153e9c40280f68d278526ca43c31fdcf 29-Jul-2014 Andy Hung <hunga@google.com> Enable multichannel in AudioFlinger

Change-Id: Ibdbdc6ea0b87cdcd15432257a3455b11b3ce14b7
udioFlinger.h
4dc680607181e6a76f4e91a39366c4f5dfb7b03e 29-Jul-2014 Eric Laurent <elaurent@google.com> audio policy: pass session ID to capture activity methods

Indicate the audio session ID when calling getInput(),
startInput(), stopInput(), releaseInput().

Bug: 12378680.
Change-Id: I763793752f93e2f4e1445a5ab217c895af011038
hreads.cpp
racks.cpp
d530d415e60373caf875a37d2d747a51470ee45c 29-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "Fix rounding in RecordThread resampler buffer computation" into lmp-dev
8661aaff9e9a4d4c1b57f6a68cdbcab006354ab2 28-Jul-2014 Andy Hung <hunga@google.com> Fix rounding in RecordThread resampler buffer computation

Bug: 16525305
Change-Id: Ie010822b0fa9dec74adde1d1b091ee44c183fc94
hreads.cpp
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
udioFlinger.cpp
udioFlinger.h
03524dcc1215b2c468f5c8c8abe6f1c26239fd71 28-Jul-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: update openInput() and openOutput()" into lmp-dev
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
udioFlinger.cpp
udioFlinger.h
atchPanel.cpp
9f81de3452dfb2385bd57dc05456a045174a1ab1 28-Jul-2014 Glenn Kasten <gkasten@google.com> Enable lower latency audio capture on more devices

Bug: 16601366
Change-Id: I573b98631f81b7768f7cc00aa09e560008dea587
hreads.cpp
9a59276fb465e492138e0576523b54079671e8f4 22-Jul-2014 Andy Hung <hunga@google.com> Add multichannel capability to AudioFlinger

But not enabled (kEnableExtendedChannels == false).

Change-Id: I62f7e31fbd29ad703a9a02f5d1a280b6972dd423
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
astMixer.h
hreads.cpp
e93b6b7347a7846c8fd746542364ec11b0cd5124 18-Jul-2014 Andy Hung <hunga@google.com> Add multichannel capability to AudioMixer

tests/test-mixer updated to handle multichannel.
New mixer path is still disabled (kUseNewMixer = false).
Subsequent CL will enable multichannel capability.

Change-Id: I71dafa94cc1d9af567c285e0ded7c5c94e3ff926
udioMixer.cpp
udioMixer.h
udioMixerOps.h
ests/mixer_to_wav_tests.sh
ests/test-mixer.cpp
ests/test_utils.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
udioFlinger.cpp
udioFlinger.h
atchPanel.cpp
atchPanel.h
laybackTracks.h
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
17d0842cf33464a79a81b0e78e49514c3419d1cf 23-Jul-2014 Andy Hung <hunga@google.com> Merge "Fix multichannel integer resampling and add tests" into lmp-dev
42b011166ece30969667e0ff9dcf4832568c9c1a 20-Jul-2014 Andy Hung <hunga@google.com> Fix multichannel integer resampling and add tests

Change-Id: I384bf8317d4f03616bf9f2b458a8700965d5cf56
udioResamplerFirProcess.h
ests/resampler_tests.cpp
a7e04803ffa0d8d4cc51a122f68bf5038422aabb 21-Jul-2014 Glenn Kasten <gkasten@google.com> Remove execute bit

Change-Id: I1cf0c0d9375779b3074af12f4cbf9c1ec07bf4ff
hreads.cpp
8bce84142802ecdc1794d59488ede629801a5cba 20-Jul-2014 Andy Hung <hunga@google.com> Merge "Add RemixBufferProvider to AudioMixer" into lmp-dev
a08810b2feafeec88870c7c1f01efc39ee8e0d78 17-Jul-2014 Andy Hung <hunga@google.com> Add RemixBufferProvider to AudioMixer

This is used to convert between channel masks for input AudioTrack
data.

Change-Id: Iedffaeccb99c7053992152e7b1cb6b2d33b12eef
udioMixer.cpp
udioMixer.h
34803d594232af5604d893eff7ee40bb57d459a4 17-Jul-2014 Andy Hung <hunga@google.com> Update DownmixerBufferProvider to use CopyBufferProvider

Change-Id: I6b1a8755a1e6c29b916662fd376e9509cda5df55
udioMixer.cpp
udioMixer.h
1b2fdcb005f9fbe5ad465cec46ec5992b718b5e3 17-Jul-2014 Andy Hung <hunga@google.com> Add CopyBufferProvider class for AudioMixer

AudioMixer::ReformatBufferProvider now uses it as a base class.

Fix ReformatBufferProvider object leak.

Change-Id: If196f844eaaa124a173ffa27afe88098023c2ff9
udioMixer.cpp
udioMixer.h
4287942b0d6fabe5f99e15cd70c470b04f345de8 19-Jul-2014 Andy Hung <hunga@google.com> Merge "Update DownmixerBufferProvider to use CopyBufferProvider" into lmp-dev
c60780517a882e0905fd36a06b1c45da12e49557 19-Jul-2014 Andy Hung <hunga@google.com> Merge "Add CopyBufferProvider class for AudioMixer" into lmp-dev
529c61b7e4468a3e21f302f2a92a660249daa722 19-Jul-2014 Glenn Kasten <gkasten@google.com> Fix copy/paste bug

introduced by Change-Id: I4e9b7fa99858b488ac98a441fa70e31dbba1b865

Change-Id: I9a0c8800f5cf3767cc259776f95c96cad972e392
racks.cpp
91be1fbc424035e70688e60306b755893e0fb0ae 17-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "Move AudioRecord frame count calculations to server" into lmp-dev
2e8186a258c934798129847f66171df36e95d23e 17-Jul-2014 Andy Hung <hunga@google.com> Merge "Fix initial audio glitch on startup" into lmp-dev
5567aaf4818007cd8e77329683a91c0f5d7a8837 17-Jul-2014 Andy Hung <hunga@google.com> Fix initial audio glitch on startup

Also happens when restarting AudioFlinger.

Bug: 16322824
Change-Id: I382b20174cb0639e04316130141f2094d7dd0cb3
hreads.cpp
7410591dad836434c72ddee66680802708b70c10 03-Jul-2014 Glenn Kasten <gkasten@google.com> Move AudioRecord frame count calculations to server

Buffer frame count and notification frame count
are now calculated by server instead of by client.
The server has more information and can do a better job.

Also fix a few bugs:

- If a fast track was re-created, even with same pipe depth, it would fail.
Now it can correctly re-create a fast track provided the pipe depth is same.

- Notification frame count for fast tracks was calculated by client
as 1/2 of the total frame count, which is a large value due to the pipe.
Now the notification frame count is set by server to the HAL frame count.
This should reduce latency for fast tracks.

- EVENT_OVERRUN were happening frequently when there was sample rate conversion,
because the client didn't know about the sample rate conversion,
and under-estimated the necessary buffer size. Now since server
calculates the buffer sizes, EVENT_OVERRUN is unlikely.

- RecordThread::createRecordTrack_l was checking for mono and stereo
for fast tracks. This is not necessary, and now we can handle a
multi-channel fast track.

Bug: 7498763
Change-Id: I0c581618e8db33084d5ff9ed50a592990c9749e8
hreads.cpp
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
udioFlinger.cpp
udioFlinger.h
6e6704c06d61bc356e30c164081e5bcffb37920c 03-Jul-2014 Glenn Kasten <gkasten@google.com> Improve dumpsys for capture threads

Show per-track sample rate, and whether there is a fast capture thread

Change-Id: If6a08a40d1eeba0690aa8da3c541f845ec101b7f
hreads.cpp
racks.cpp
da3bd9f12883f8344d2db00ce2fa47511ed9bef6 16-Jul-2014 Glenn Kasten <gkasten@google.com> Add audio_input_flags_t to HAL open_input_stream

For backward compatibility, until flags are added to openInput(),
we will assume that the request is for a low latency input stream.

Change-Id: I5e6f7e574418917ff1b41b0a47199203c69cb40f
udioFlinger.cpp
cd704219d22ec51660103684a680caf2c3a12dad 15-Jul-2014 Glenn Kasten <gkasten@google.com> const correctness on downmix and upmix

Change-Id: I0f51470a6d58a22310ce7cda80afc55e9d6df1dc
hreads.cpp
2829edccd7d2bb8244246f316face82b650b8949 18-Jun-2014 aarti jadhav-gaikwad <agaikwad@nvidia.com> stagefright: Pass audio aac sub formats in offloadinfo

Pass audio aac sub formats in offloadinfo according to
aac profile. Audio HAL can take decision about offload
using DSP capabilities

Change-Id: If269a3654b5d2b09c183212b0646ef03e06f2d8f
udioFlinger.cpp
463be250de73907965faa6a216c00312bf81e049 11-Jul-2014 Andy Hung <hunga@google.com> Return negotiated format with HAL in AudioFlinger

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

Change-Id: I2be9d55d5c87d82e46b5200b07fcdd986ebde08a
hreads.cpp
hreads.h
0dba9b1719a598f5d78cbcef4b0b9e47313f1037 09-Jul-2014 Andy Hung <hunga@google.com> Merge "Add floating point volume handling to AudioMixer"
91848a568e6ef4d6b214b81d3f82b6d49d00ffb6 09-Jul-2014 Andy Hung <hunga@google.com> Merge "Enable extended precision PCM output in AudioFlinger"
5e58b0abe5b6c8f5bd96a8f78bbeeeb4d3892020 24-Jun-2014 Andy Hung <hunga@google.com> Add floating point volume handling to AudioMixer

Use floating point volume in AudioMixer mixing when floating
point input is used with the new mixer engine.
AudioResampler is updated to take floating point volume to match.
Both legacy integer and floating point mixer engines work.

For now, integer volume is used when the new mixer engine
runs in integer input mode, for backward compatibility with
the legacy mixer. The new mixer engine will generally run in
floating point input mode. When the legacy path is removed,
the integer volumes will be removed.

Change-Id: I79e80c292ae7c8b8bdd0aa371a1b2c3a1b618290
ndroid.mk
udioMixer.cpp
udioMixer.h
udioMixerOps.h
udioResampler.cpp
udioResampler.h
udioResamplerDyn.cpp
udioResamplerDyn.h
udioResamplerSinc.cpp
udioResamplerSinc.h
racks.cpp
est-resample.cpp
ests/resampler_tests.cpp
a494e82c3c73508b4d3cfe89e9134de94e12fd31 09-Jul-2014 Andy Hung <hunga@google.com> Enable extended precision PCM output in AudioFlinger

Change-Id: I7c0907c7b2369681975d8ea0192b722d7ed7a867
udioFlinger.h
3d638b30dcc67ef9eaa389160ef285cda055ed64 08-Jul-2014 Andy Hung <hunga@google.com> Merge "Replace int bitDepth with audio_format_t in Resampler"
3348e36c51e91e78020bcc6578eda83d97c31bec 07-Jul-2014 Andy Hung <hunga@google.com> Replace int bitDepth with audio_format_t in Resampler

Remove mBitDepth from class (not used).
Replace with audio_format_t in factory method to distinguish
between float and pcm 16-bit.

Change-Id: I166860796c68285077ef4458d8758d19b82523f9
udioMixer.cpp
udioResampler.cpp
udioResampler.h
udioResamplerCubic.h
udioResamplerDyn.cpp
udioResamplerDyn.h
udioResamplerSinc.cpp
udioResamplerSinc.h
racks.cpp
est-resample.cpp
ests/resampler_tests.cpp
075abae2a954bf3edf18ad1705c2c0f188454ae0 10-Apr-2014 Andy Hung <hunga@google.com> Add and enable multichannel for audio resampler

Change-Id: I2b86fb73d70abc4c456f7567270a888086b301d4
Signed-off-by: Andy Hung <hunga@google.com>
udioResampler.cpp
udioResamplerDyn.cpp
udioResamplerDyn.h
ests/resampler_tests.cpp
68ffa200de7c4662c088851a328923be715c6c24 10-Apr-2014 Andy Hung <hunga@google.com> Add multichannel to audio resample processing

Change-Id: If6bfbf74000520713f9ba19488a475fc2eefc271
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerFirProcess.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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
665470b36f202bcc8ee2f7417f68fd2608dd07c1 04-Jul-2014 Eric Laurent <elaurent@google.com> audio: deprecate audio_stream_frame_size()

Bug: 15000850.
Change-Id: I955a6efa620b8f70fa5193c7853cbe88e879c9c3
hreads.cpp
5ba4440c11eb975ec0e104e0af1981838f42f57c 04-Jul-2014 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete IAudioFlinger::channelCount()"
296b741e8eb38e749e3202182f703a2e30ee5f1f 18-Jun-2014 Andy Hung <hunga@google.com> Add new AudioMixer processing hooks

This change adds new process and thread hooks for
multi-format handling.
It is enabled by setting kUseNewMixer = true.

Change-Id: I262a3d2e4411f8cef7370a497b77a34eb55f1f86
udioMixer.cpp
udioMixer.h
udioMixerOps.h
f92f22becdf7fce1f55d5ebd80ac2caa2ad55602 30-Jun-2014 Andy Hung <hunga@google.com> Merge "Add enabling variable for extended precision audio"
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e 13-May-2014 Glenn Kasten <gkasten@google.com> Use sp<> instead of raw pointer for FastMixer

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

Bug: 15858655
Change-Id: I896d24317bd6f53a574645cdf4cd514eaa205dd5
hreads.cpp
hreads.h
eaf07697a9146d27ca863db5c43da64af4f8c94a 23-Jun-2014 Andy Hung <hunga@google.com> Merge "Add test-mixer AudioMixer test program"
e4fc42359cdd9786e521054a3a0491d6bc3a9e1c 18-Jun-2014 Andy Hung <hunga@google.com> Add test-mixer AudioMixer test program

The shell script mixer_to_wav_tests.sh shows how to use
test-mixer.

Change-Id: Ia7f1a368972c9c33fadc96df4cb1fc8b22446c8c
ests/Android.mk
ests/mixer_to_wav_tests.sh
ests/test-mixer.cpp
9b3cd171710991625a94dea645248f708cb957fb 20-Jun-2014 Andy Hung <hunga@google.com> Merge "Extract out test utility functions from resampler_tests"
ab5cdbaf65ca509681d2726aacdf3ac8bfb6b3fa 10-Jun-2014 Eric Laurent <elaurent@google.com> AudioTrack: add support for compressed audio

Add support for compressed audio playback by use
of an AudioTrack attached to a direct output thread.

Bug: 9428304.

Change-Id: I4a61be9cf0e31003ca85935d6e0ee38ca8192e03
laybackTracks.h
hreads.cpp
racks.cpp
c0e5ec8e2d8db15b97094374d0a248e041304b62 17-Jun-2014 Andy Hung <hunga@google.com> Extract out test utility functions from resampler_tests

These will be used for mixer tests later.

Change-Id: I22b1c89857058cfb2450afe15e80d6c9306a31f1
ests/Android.mk
ests/resampler_tests.cpp
ests/test_utils.h
5094675aa55458414e8b00a86a104a32ea1d55c0 16-Jun-2014 Glenn Kasten <gkasten@google.com> am a3603693: Merge "Fix deadlock" into lmp-preview-dev

* commit 'a3603693fb784d7e1a820ee4629a69730a0bb424':
Fix deadlock
a3603693fb784d7e1a820ee4629a69730a0bb424 16-Jun-2014 Glenn Kasten <gkasten@google.com> Merge "Fix deadlock" into lmp-preview-dev
3d61bc1ffc8afc8d7be3b0d4205c9b5ba6daf2e8 16-Jun-2014 Glenn Kasten <gkasten@google.com> Fix deadlock

Bug: 15591052
Change-Id: I76154e1640646d2ae8fae65e163e1f3ed1be17dc
hreads.cpp
3bcffa136909c1fb6e88ee4efd12ccac18360a85 13-Jun-2014 Eric Laurent <elaurent@google.com> force command flush after releasing a reference to shared memory

After releasing a reference to a shared memory interface,
IPCThreadState::self()->flushCommands() must be called to ensure
that the corresponding reference is also cleared immediately in the
remote process. Otherwise the binder implementaiton will not
push the clear systematically causing the memory region not to be freed.

See issues 10711502 and 2801375.

Bug: 14057166.
Change-Id: If55f36f00d452d6cf00cf83bd2fba1c8f3abcb57
racks.cpp
20d16a8af2dc95e827be693edabde4f09eb90c32 13-Jun-2014 Eric Laurent <elaurent@google.com> am 3bcffa13: force command flush after releasing a reference to shared memory

* commit '3bcffa136909c1fb6e88ee4efd12ccac18360a85':
force command flush after releasing a reference to shared memory
b6be7f22a82ee3bad8bcc709d21e72fc4727da09 12-Jun-2014 Bryant Liu <bryant_liu@htc.com> frameworks: av: fix bug in the volume management

which can cause volume levels to be applied twice. After applying volume
in the effect chain, the remaining volume needs to be converted back to
floating point before providing to mAudioMixer.

Bug: 15583440
Change-Id: I3c884f95b0fa9ad1b554285b069601c850c54776
Signed-off-by: Glenn Kasten <gkasten@google.com>
hreads.cpp
14c403fbab456a4a63586a767fbae498f5f8c260 12-Jun-2014 Glenn Kasten <gkasten@google.com> am 0ac53364: Merge "Fix non-monotonic AudioTrack::getTimestamp after pause" into lmp-preview-dev

* commit '0ac53364b79dc72ee0c09f0efc46a22ab4374dbf':
Fix non-monotonic AudioTrack::getTimestamp after pause
0ac53364b79dc72ee0c09f0efc46a22ab4374dbf 11-Jun-2014 Glenn Kasten <gkasten@google.com> Merge "Fix non-monotonic AudioTrack::getTimestamp after pause" into lmp-preview-dev
ced6e74215937182fe2f9f6b0867f7c28ccd02c1 10-Jun-2014 Glenn Kasten <gkasten@google.com> Fix non-monotonic AudioTrack::getTimestamp after pause

Bug: 15523502
Change-Id: Ifd4aa7fca197bc041c1620fc3f7d953a8902551a
laybackTracks.h
racks.cpp
54188de28dc7766ba578a7ce01c61151c6febdc0 03-Jun-2014 Andy Hung <hunga@google.com> Update resampler to fetch exactly the frames needed

This avoids unnecessary overfetching/releasing, which
could cause problems with the upstream AudioBufferProvider.
A one input sample delay is placed on the stream compared
with the previous implementation.

This change only affects the Dynamic resampler.

Bug: 15548547
Change-Id: Ic7fcff130e0081b4724cfb5a00dc8e8b4a8b1af3
(cherry picked from commit 717007429a50c02d2acc704a8c1ebbe6760a2c22)
udioResamplerDyn.cpp
d8754e07e23eecb68068c0c392aeb0428c529e4e 10-Jun-2014 Eric Laurent <elaurent@google.com> DO NOT MERGE - AudioFlinger: increase per client memory pool

Temporary workaround for issue 14057166 allowing
AudioTracks from a given client to use up to 4MB
of shared memory.

Bug: 14057166.
Change-Id: I19adb8d424ed170df61c1cd706be3d10788edfc1
udioFlinger.cpp
51fabcd581f293db52997b0d43b2ef606d5759ff 09-Jun-2014 Andy Hung <hunga@google.com> Merge "Add tests directory for AudioFlinger"
32ff60c6ec297256b59b6ce4f3cb341a0f4638dd 06-Jun-2014 Eric Laurent <elaurent@google.com> am 45df31f5: Merge "AudioFlinger: fix PatchPanel debug log." into lmp-preview-dev

* commit '45df31f511ba9ae9b45c769fc546eca4bcf4bbdb':
AudioFlinger: fix PatchPanel debug log.
45df31f511ba9ae9b45c769fc546eca4bcf4bbdb 05-Jun-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix PatchPanel debug log." into lmp-preview-dev
c263ca0ad8b6bdf5b0693996bc5f2f5916e0cd49 05-Jun-2014 Glenn Kasten <gkasten@google.com> Squashed commit of the following:

commit 9128d6ffec43731d723f9b394f243d940f4c7e41
Author: Glenn Kasten <gkasten@google.com>
Date: Tue May 13 10:38:42 2014 -0700

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

commit 2e5e0806a5abe7499848358ef5fde5c26405000d
Author: Glenn Kasten <gkasten@google.com>
Date: Mon Jun 2 08:29:22 2014 -0700

Add mPrimaryOutputSampleRate

Change-Id: I46b527fc3f2b5a5720a74b4f0b9a8f2e0d570b09

commit baf1d73467923996d1b1f2a9237260cc5697e050
Author: Andy Hung <hunga@google.com>
Date: Fri May 30 10:42:03 2014 -0700

Change parameter type for volume to float in AudioMixer

Change-Id: I4da1505ce852505f86f8e5b87f60e8edceeb30e0

commit 40fe20fa9760cd03c69778c2021cf7a490d75ece
Author: Andy Hung <hunga@google.com>
Date: Fri May 30 10:35:47 2014 -0700

Rename UNITY_GAIN to UNITY_GAIN_INT in AudioMixer

Change-Id: Ic040311305026f0b4c4280a5b3bef7a447ac1da3

commit 37c9a2b49f876abc5ff537a9ec036d7f0a423775
Author: Andy Hung <hunga@google.com>
Date: Thu May 29 21:33:13 2014 -0700

Refactor setVolumeRampVariables in AudioMixer

Change-Id: I8fcf3101bcea292de7c65433fa578f1c9cdd0974

commit 397070eca31f121d5d3993de1bfea99aaea5d4f3
Author: Andy Hung <hunga@google.com>
Date: Thu May 29 18:52:38 2014 -0700

Fix floating point output from mixer

A buffer pointer was being erroneously reset to buffer start,
potentially causing an audio glitch. The floating point
output mode is not enabled at this time, but will be in
the future.

Change-Id: If8b6414d232f064f3a2e2c5a6da889a91b27fb24

commit 2e61aa5b33b2247bbc5d4eaa0b519df9accd4bbc
Author: Andy Hung <hunga@google.com>
Date: Fri May 23 21:22:17 2014 -0700

Add multiple format capability to FastMixer

Floating point data from MixerThread into FastMixer.
Multiple output format capability from FastMixer to Sink.

Change-Id: I0da17810ee71381a39a006c46faec71108d22c26

commit b9ea653c702a785bbd23a66c5e588d40b4192c4e
Author: Andy Hung <hunga@google.com>
Date: Thu May 29 15:53:09 2014 -0700

Avoid resetting BufferProviders in mixer unnecessarily

Change-Id: Iad85c4dfd21be1dbf89dc11906106b34219376f8

commit 7f1a6d6da21c616f80cf9ba21bea11b419ec561b
Author: Andy Hung <hunga@google.com>
Date: Tue May 27 12:32:17 2014 -0700

Update dynamic resampler buffer fetching

Make the criteria tight for fetching to avoid storing
excessive frame data internal to the resampler.
This should reduce jitter in frame delivery computation.

Bug: 14962343
Change-Id: I7adaf714d11c272696ccdbf218bda994c7217477

commit b5e4aac07b9a02f0c803c090058602b03ac09ebb
Author: Glenn Kasten <gkasten@google.com>
Date: Tue May 27 12:30:54 2014 -0700

Allow kFastTrackMultiplier to be specified per device

Change-Id: I4eaaaf038df720cec4f5d9221d1b632970f9e3dd

commit b93cd97a52af31122df2da2cc0415cda888c8c73
Author: Andy Hung <hunga@google.com>
Date: Fri May 23 21:13:31 2014 -0700

Rename mixBuffer to mMixerBuffer in FastMixer

Likewise mixBufferState becomes mMixerBufferState.
This harmonizes with the naming in AF::MixerThread.

Change-Id: I1255d7c07cc2c6ee925d7430925236d2bd163122

commit 8340758622b9711365a8801806cbdf934803c63f
Author: Andy Hung <hunga@google.com>
Date: Mon May 12 16:51:41 2014 -0700

Add multiple format capability to AudioMixer

Change-Id: I04ac1cafd90b6ed652f8d51888ad07576678f0bc
Signed-off-by: Andy Hung <hunga@google.com>

commit 6b695b9d094820c232a897a3fabbe83d2b7193fe
Author: Glenn Kasten <gkasten@google.com>
Date: Thu Mar 13 14:59:31 2014 -0700

Start adding FastCapture based on FastThread WIP

This version supports at most one fast capture client.

Change-Id: Idf609bfc80ae22433433d66a5232c043c65506df

commit e951ad05a2c388471d7e2806d91e7d51325a150a
Author: Glenn Kasten <gkasten@google.com>
Date: Mon May 12 11:06:26 2014 -0700

Move validation of frameCount from set to openRecord_l

This move is needed because frameCount is validated on server side for
fast tracks (as should be done for normal tracks too).

Change-Id: I6d99e80869fd90fab373cf60ef348c01f075fbca

commit 73e76992dbba794894837c38e5472312ea829cf3
Author: Glenn Kasten <gkasten@google.com>
Date: Tue May 13 10:41:52 2014 -0700

Allow track buffer "allocation" to be from pipe

Change-Id: Ib9ac170f8e8b7746b3588157a56cbee3b753a1cb

commit 60de1d7ded05c6304037d4858b401094b1d2b4d3
Author: Andy Hung <hunga@google.com>
Date: Fri May 9 15:02:21 2014 -0700

Add format parameter to getTrackName() and track_t

Change-Id: Ia152a839014e235fbfb656104c15d7c1b456d02e
Signed-off-by: Andy Hung <hunga@google.com>

Change-Id: Ied0ade8b25d23e89bb03319a7e3135c238f735b9
ndroid.mk
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioResamplerDyn.cpp
astCapture.cpp
astCapture.h
astCaptureState.cpp
astCaptureState.h
astMixer.cpp
astMixer.h
astMixerState.cpp
astMixerState.h
tateQueueInstantiations.cpp
hreads.cpp
hreads.h
rackBase.h
racks.cpp
24478d47fc631ab33208f4dd9d034abb6839c992 05-Jun-2014 Eric Laurent <elaurent@google.com> AudioFlinger: fix PatchPanel debug log.

Bug: 14815883.
Change-Id: I71cf2ef74a96d3cdb27f2beb1b76b8979c738335
atchPanel.cpp
f1caa55fbe2a32a27968d7be2f0cd134e412db4d 05-Jun-2014 Andy Hung <hunga@google.com> Merge "Update resampler to fetch exactly the frames needed"
aaaea95d23b78313b7ddf1f8f670c9b0110474ed 04-Jun-2014 Eric Laurent <elaurent@google.com> am 83438ce6: Merge "audio policy: add permission for routing APIs." into lmp-preview-dev

* commit '83438ce6cbbff49ca26d4bd694ffdad4842ded5a':
audio policy: add permission for routing APIs.
717007429a50c02d2acc704a8c1ebbe6760a2c22 03-Jun-2014 Andy Hung <hunga@google.com> Update resampler to fetch exactly the frames needed

This avoids unnecessary overfetching/releasing, which
could cause problems with the upstream AudioBufferProvider.
A one input sample delay is placed on the stream compared
with the previous implementation.

This change only affects the Dynamic resampler.

Change-Id: Ic7fcff130e0081b4724cfb5a00dc8e8b4a8b1af3
udioResamplerDyn.cpp
8f415570afb174f0781d8bf6b1c0fa6bdecca7cd 03-Jun-2014 Andy Hung <hunga@google.com> Merge "Change parameter type for volume to float in AudioMixer"
93f87fe162f6c18a296451d388ea68e76fd67fb6 03-Jun-2014 Andy Hung <hunga@google.com> Merge "Rename UNITY_GAIN to UNITY_GAIN_INT in AudioMixer"
9dc6699fd613c29fe08ef7bc0d32052c8ce297c1 03-Jun-2014 Glenn Kasten <gkasten@google.com> Merge "Use of fast capture by normal capture"
740a5ca81f6498b34baea04bb0fb3fc29fe1e135 03-Jun-2014 Andy Hung <hunga@google.com> Merge "Refactor setVolumeRampVariables in AudioMixer"
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
udioFlinger.h
hreads.cpp
hreads.h
racks.cpp
4ea00a25cf85877b48ebd1e15a657cfaab29af58 02-Jun-2014 Glenn Kasten <gkasten@google.com> Add mPrimaryOutputSampleRate

Change-Id: I46b527fc3f2b5a5720a74b4f0b9a8f2e0d570b09
udioFlinger.cpp
udioFlinger.h
5284ed53c14cd4d15bd793000ede7166d143e69a 29-May-2014 Eric Laurent <elaurent@google.com> audio policy: add permission for routing APIs.

Add check for signature or system permission
"android.permission.MODIFY_AUDIO_ROUTING" for routing
APIs.

Bug: 14815883.
Change-Id: Iefa0b9d90127a53e03a2e6d50dc93d8f4ae63e2f
erviceUtilities.cpp
erviceUtilities.h
43466a133984182b250453cea244eb146e83c010 02-Jun-2014 Eric Laurent <elaurent@google.com> am 62aaabb3: audio policy: fix unitialized hw module in audio port

* commit '62aaabb3905c61bb7acd6037414c206240a31c32':
audio policy: fix unitialized hw module in audio port
62aaabb3905c61bb7acd6037414c206240a31c32 02-Jun-2014 Eric Laurent <elaurent@google.com> audio policy: fix unitialized hw module in audio port

The hw module handle was not initialized when creating
and audio port configuration from an input stream descriptor.

Bug 15376641.

Change-Id: I6c784cded68a5c665fd22c3643765c63f70eb241
atchPanel.cpp
d28148537693b19320f3c3b5b34816d45542e9bd 02-Jun-2014 Andy Hung <hunga@google.com> Merge "Fix floating point output from mixer"
f947dbce4390f2c3c460325d37002a34f09c0b74 01-Jun-2014 Glenn Kasten <gkasten@google.com> Remove obsolete IAudioFlinger::channelCount()

Change-Id: Ie623edae2e795f9155f1f452fe4e6c7217a4a4c8
udioFlinger.cpp
udioFlinger.h
hreads.h
e28456465fca86ed1b8b2225de073cfba64c7c42 01-Jun-2014 Glenn Kasten <gkasten@google.com> Merge "Start adding FastCapture based on FastThread WIP"
481c8837c7f67852e06137d636915ea6e96247e3 31-May-2014 Eric Laurent <elaurent@google.com> am e1715a46: audio policy: add audio port gain control

* commit 'e1715a465a29db625da9d0ea365edf371e39e201':
audio policy: add audio port gain control
e1715a465a29db625da9d0ea365edf371e39e201 20-May-2014 Eric Laurent <elaurent@google.com> audio policy: add audio port gain control

Implement setAudioPortConfig() API to configure an
audio port.
Currently limited to gain control.

Bug: 14815883.

Change-Id: Ic1b268e5ba5c277e9f5b8fa63c81dd7c0b250024
atchPanel.cpp
6be494077f8d7970f3a88129c5d139c5a0c88f6d 30-May-2014 Andy Hung <hunga@google.com> Change parameter type for volume to float in AudioMixer

Change-Id: I4da1505ce852505f86f8e5b87f60e8edceeb30e0
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
97ae82408469286426d8dc57a361350f74e24a8b 30-May-2014 Andy Hung <hunga@google.com> Rename UNITY_GAIN to UNITY_GAIN_INT in AudioMixer

Change-Id: Ic040311305026f0b4c4280a5b3bef7a447ac1da3
udioMixer.cpp
udioMixer.h
racks.cpp
5866a3b9689035580c31f1a02037b8176d7508a7 30-May-2014 Andy Hung <hunga@google.com> Refactor setVolumeRampVariables in AudioMixer

Change-Id: I8fcf3101bcea292de7c65433fa578f1c9cdd0974
udioMixer.cpp
f8a106ae5c40735de6c75e7c12d5e0e2e22f12cf 30-May-2014 Andy Hung <hunga@google.com> Fix floating point output from mixer

A buffer pointer was being erroneously reset to buffer start,
potentially causing an audio glitch. The floating point
output mode is not enabled at this time, but will be in
the future.

Change-Id: If8b6414d232f064f3a2e2c5a6da889a91b27fb24
udioMixer.cpp
671714b80cad4725d07691fbd8284cb869a0c27f 30-May-2014 Eric Laurent <elaurent@google.com> am 6a94d69d: audio policy: implement routing control

* commit '6a94d69dc4f32abb53c466a96f905bb199be6417':
audio policy: implement routing control
47aaf6da5d7ecc2ad28de004d1820b64b02dd344 30-May-2014 Andy Hung <hunga@google.com> Merge "Add multiple format capability to FastMixer"
1258c1ab592a899fabb1e31eb5db2ef413b6f38a 24-May-2014 Andy Hung <hunga@google.com> Add multiple format capability to FastMixer

Floating point data from MixerThread into FastMixer.
Multiple output format capability from FastMixer to Sink.

Change-Id: I0da17810ee71381a39a006c46faec71108d22c26
astMixer.cpp
astMixer.h
hreads.cpp
6a94d69dc4f32abb53c466a96f905bb199be6417 20-May-2014 Eric Laurent <elaurent@google.com> audio policy: implement routing control

Add implementation of audio routing control via AudioSystem APIs.

The following APIs are implemented:
- listAudioPorts(): return a list of devices and output/input mixers ports
that can be used as sources or sinks for audio patches.
- createAudioPatch()/releaseAudioPatch(): create/release a connection patch between
two audio ports (e.g. to connect input from an HDMI device to a speaker output device).
Only one client application can own a patch from a given source.
When an audio port (device or mix) is part of an application created patch, its routing cannot
not be changed by a policy decision.
- listAudioPatches(): return a list of existing patches.

Each audio port addition/removal and each audio patch creation/release increments a generation count.
This generation count is used to ensure consistency betwen calls to
listAudioPorts() and listAudioPatches().

Bug: 14815883.

Change-Id: I022b638c2f5f0bb41543c7cfca7488fb45cfdd80
atchPanel.cpp
1d26ddf715182d6082804ff70086c47fb8c354b8 30-May-2014 Andy Hung <hunga@google.com> Avoid resetting BufferProviders in mixer unnecessarily

Change-Id: Iad85c4dfd21be1dbf89dc11906106b34219376f8
udioMixer.cpp
7dac33136d71ea566de4531235f5fbbd28048f0c 29-May-2014 Andy Hung <hunga@google.com> Merge "Update dynamic resampler buffer fetching"
951f455566775e5f01e67c5ee26863d7d19209d7 20-May-2014 Eric Laurent <elaurent@google.com> DO NOT MERGE - 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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
atchPanel.cpp
atchPanel.h
hreads.cpp
hreads.h
1cda6afaf6207a41303e653a6ecd7909d73186eb 11-Apr-2014 Eric Laurent <elaurent@google.com> DO NOT MERGE - IAudioFlinger interface extension for patch panel

Change-Id: Iaabe0a7e315d5725e00a74a6ed40339b98f20330
udioFlinger.h
411cb8e45442d16d983a38722c7c7bce487bde6b 27-May-2014 Andy Hung <hunga@google.com> Update dynamic resampler buffer fetching

Make the criteria tight for fetching to avoid storing
excessive frame data internal to the resampler.
This should reduce jitter in frame delivery computation.

Bug: 14962343
Change-Id: I7adaf714d11c272696ccdbf218bda994c7217477
udioResamplerDyn.cpp
fe9adc4850572cb04a9cf7877d0e77d0c1fde84e 27-May-2014 Eric Laurent <elaurent@google.com> DO NOT MERGE - audioflinger: fix deadlock upon AudioRecord creation error

AudioFlinger:openRecord() should not hold mClientLock when
releasing the local reference on AudioRecord as the destructor will
also lock mClientLock.
Same fix for AudioFlinger::createTrack().
Also make sure that AudioFlinger::createEffect() holds mClientLock
when clearing local reference to the Client in case of error.

Regression introduced by 021cf9634ab09c0753a40b7c9ef4ba603be5c3da

Bug: 15118096.
Change-Id: Ie961c398c8e0460bca9b95e2ee4ce6859316c275
udioFlinger.cpp
d6461906586032716fc5ff9970c8c6cacf235a20 22-May-2014 Eric Laurent <elaurent@google.com> DO NOT MERGE - audioflinger: test min HAL version instead of current

Change-Id: Ibce2353b4390329b4c1a453e829178e3986c25a7
udioFlinger.cpp
546734b3ab577d46afe863515104a062e88a109b 02-Apr-2014 Andy Hung <hunga@google.com> Add tests directory for AudioFlinger

Native tests for audio resampler through gtest framework.

Change-Id: Ia340ca51f9b9b78d67e03e3541e4462b98578c95
ests/Android.mk
ests/build_and_run_all_unit_tests.sh
ests/resampler_tests.cpp
ests/run_all_unit_tests.sh
ecc03733bfd3262ffadef3166e6be23b539c505c 28-May-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: first patch panel implementation."
5e49780692b4f23966be89ac32b19c3c1ead4e85 28-May-2014 Eric Laurent <elaurent@google.com> Merge "IAudioFlinger interface extension for patch panel"
c9cd62bf52dd5ea8dc292fb7bc80ff51ed1a79bb 28-May-2014 Glenn Kasten <gkasten@google.com> Merge "Allow kFastTrackMultiplier to be specified per device"
0349009fd19f89f8414c428f6b71b369f7546085 27-May-2014 Glenn Kasten <gkasten@google.com> Allow kFastTrackMultiplier to be specified per device

Change-Id: I4eaaaf038df720cec4f5d9221d1b632970f9e3dd
hreads.cpp
b9e722bdf00333557578497c5abfc77c5d779ecb 28-May-2014 Andy Hung <hunga@google.com> Merge "Rename mixBuffer to mMixerBuffer in FastMixer"
018d324dc599c5f4238a4cd631baac47c28d59fe 27-May-2014 Andy Hung <hunga@google.com> Merge "Add multiple format capability to AudioMixer"
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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
atchPanel.cpp
atchPanel.h
hreads.cpp
hreads.h
1a83b736737e7f625371093519ff7a10b05e0c63 27-May-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix deadlock upon AudioRecord creation error"
4b123406c10c17852734a1b691bb9ce2a4cb7caf 11-Apr-2014 Eric Laurent <elaurent@google.com> IAudioFlinger interface extension for patch panel

Change-Id: Iaabe0a7e315d5725e00a74a6ed40339b98f20330
udioFlinger.h
5912117110ae6efadd862fcb0e395fdcd18aa00c 27-May-2014 Glenn Kasten <gkasten@google.com> Merge "Move validation of frameCount from set to openRecord_l"
fe1a94e68e173fe4dfe7699112422a94eddacb4e 27-May-2014 Eric Laurent <elaurent@google.com> audioflinger: fix deadlock upon AudioRecord creation error

AudioFlinger:openRecord() should not hold mClientLock when
releasing the local reference on AudioRecord as the destructor will
also lock mClientLock.
Same fix for AudioFlinger::createTrack().
Also make sure that AudioFlinger::createEffect() holds mClientLock
when clearing local reference to the Client in case of error.

Regression introduced by 021cf9634ab09c0753a40b7c9ef4ba603be5c3da

Bug: 15118096.
Change-Id: Ie961c398c8e0460bca9b95e2ee4ce6859316c275
udioFlinger.cpp
45d68d366d07b10733c1e8af6a6984befbc08ce1 24-May-2014 Andy Hung <hunga@google.com> Rename mixBuffer to mMixerBuffer in FastMixer

Likewise mixBufferState becomes mMixerBufferState.
This harmonizes with the naming in AF::MixerThread.

Change-Id: I1255d7c07cc2c6ee925d7430925236d2bd163122
astMixer.cpp
astMixer.h
ef7c7fbd0e3fb36af14cd7d39f64c949031516a5 13-May-2014 Andy Hung <hunga@google.com> Add multiple format capability to AudioMixer

Change-Id: I04ac1cafd90b6ed652f8d51888ad07576678f0bc
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioMixer.h
astMixer.cpp
c62476f0c0c1cf9283a38852bde0a4c9434df712 24-May-2014 Andy Hung <hunga@google.com> Merge "Add format parameter to getTrackName() and track_t"
39cf5681975ec9097742c47de7c2d0f8c11248a2 23-May-2014 Glenn Kasten <gkasten@google.com> Merge "Allow track buffer "allocation" to be from pipe"
24ffe7a9161943c8ba2353e956653a71af564b5d 23-May-2014 Elliott Hughes <enh@google.com> am 79262cfc: am 5b756bfd: am 8b187f4a: Merge "Move frameworks/av off <sys/atomics.h>."

* commit '79262cfc14a9d8b5aa29d43e84ea91eedb9492ba':
Move frameworks/av off <sys/atomics.h>.
f91df1b368a140abd37c80b204bd48d78778cc43 13-Mar-2014 Glenn Kasten <gkasten@google.com> Start adding FastCapture based on FastThread WIP

This version supports at most one fast capture client.

Change-Id: Idf609bfc80ae22433433d66a5232c043c65506df
ndroid.mk
astCapture.cpp
astCapture.h
astCaptureState.cpp
astCaptureState.h
tateQueueInstantiations.cpp
29b703eec27b305e7b5b2343bf257643e38f6b68 12-May-2014 Glenn Kasten <gkasten@google.com> Move validation of frameCount from set to openRecord_l

This move is needed because frameCount is validated on server side for
fast tracks (as should be done for normal tracks too).

Change-Id: I6d99e80869fd90fab373cf60ef348c01f075fbca
hreads.cpp
6181ffd90a436f333c43a7f812391eee2c35005a 13-May-2014 Glenn Kasten <gkasten@google.com> Allow track buffer "allocation" to be from pipe

Change-Id: Ib9ac170f8e8b7746b3588157a56cbee3b753a1cb
hreads.h
rackBase.h
racks.cpp
5b756bfdaa27c8b606720544bf507213cf47376d 23-May-2014 Elliott Hughes <enh@google.com> am 8b187f4a: Merge "Move frameworks/av off <sys/atomics.h>."

* commit '8b187f4acea8d7e517ff9ced32fc7368bdbaa6e0':
Move frameworks/av off <sys/atomics.h>.
63492411cf4abff452b47f59ec7ff6f3e9925c84 22-May-2014 Elliott Hughes <enh@google.com> Move frameworks/av off <sys/atomics.h>.

Bug: 14903517
Change-Id: I92cdfc618d83fd914cfb558a07b1deae0255fccb
astMixer.cpp
5806b3533437e3d83208e8e9d6bd74ed304e51ec 22-May-2014 Eric Laurent <elaurent@google.com> audioflinger: test min HAL version instead of current

Change-Id: Ibce2353b4390329b4c1a453e829178e3986c25a7
udioFlinger.cpp
87cebadd48710e42474756fc3513df678de045ce 22-May-2014 Elliott Hughes <enh@google.com> resolved conflicts for merge of f285c91e to master

Change-Id: I4c995e297d09c0854a42142cc57dce8b771acf65
c10b874c4d0d6208fb93a7aa0dc8af4418faad45 22-May-2014 Calin Juravle <calin@google.com> am d5516339: Merge "Move frameworks/av from fdprintf to POSIX dprintf."

* commit 'd551633916d3677da4dda10aba6837bdc6803ee0':
Move frameworks/av from fdprintf to POSIX dprintf.
8b5f642eb2364ea7fe46a5b3af51b48b58f12183 22-May-2014 Elliott Hughes <enh@google.com> Move frameworks/av from fdprintf to POSIX dprintf.

Bug: 11156955
Change-Id: Ia98cd16b4c1f7be87cf060b7456de4f40896bacb
udioFlinger.cpp
udioWatchdog.cpp
astMixer.cpp
tateQueue.cpp
hreads.cpp
9a59d411cbe68d6027c541854c6d7c1348e4ee3d 22-May-2014 Elliott Hughes <enh@google.com> am 85e6e87c: Merge "Restore accidentally-removed NULL timeout."

* commit '85e6e87c41bba51729cee8958a5c30157c8dc674':
Restore accidentally-removed NULL timeout.
e348c5b72ad889389c7c1c900c121f0fbee221b5 22-May-2014 Elliott Hughes <enh@google.com> resolved conflicts for merge of c0bf836f to master

Change-Id: I5cf238fa56d6fff443b212870cf9dd7f1110e7da
22f22ffcb111b38eb7a303bfde39aed108b43e07 22-May-2014 Elliott Hughes <enh@google.com> Restore accidentally-removed NULL timeout.

Change-Id: I933c80fea50950243f109acf8d6350013aaa811f
astMixer.cpp
ad71caf25e31ecfc4ecf2c925e38fd87905fbc8e 22-May-2014 Elliott Hughes <enh@google.com> am 3b6da6bf: Merge "Move frameworks/av off private API."

* commit '3b6da6bfb50a1c0324fb4c87326d3a477944d5fe':
Move frameworks/av off private API.
ee499291404a192b059f2e04c5afc65aa6cdd74c 22-May-2014 Elliott Hughes <enh@google.com> Move frameworks/av off private API.

Bug: 11156955
Change-Id: Ib3bb9d66a2bf92977c2445b62aa074a2d7a45aea
astMixer.cpp
astMixer.h
hreads.cpp
racks.cpp
9382378b6b271949bdce527ea3da748c13c4c692 22-May-2014 Elliott Hughes <enh@google.com> resolved conflicts for merge of b1080917 to master

Change-Id: Iabbe3e95e29f28461ff722b550e8a9f35bd2528f
acbd9492996348bf4565fbaa5a14772f0f4ace38 22-May-2014 Elliott Hughes <enh@google.com> am d084206d: Merge "Move frameworks/av off __futex_syscall3."

* commit 'd084206d5a4a5364211af46e4201311933e83bfc':
Move frameworks/av off __futex_syscall3.
77e1512aee8092069514973379a59a318e721be3 22-May-2014 Elliott Hughes <enh@google.com> Move frameworks/av off __futex_syscall3.

Bug: 11156955
Change-Id: I943080bc51b6efa781059b48b5b5ecc4fa287512
hreads.cpp
racks.cpp
00ddac6f47a066a545342a81c40425e3a153e8a1 20-May-2014 Andy Hung <hunga@google.com> Merge "Update AudioMixer::getTrackName to save channelMask"
b4db73d022f3de3530bc2b3c9c831ccfdd1a2ead 20-May-2014 Andy Hung <hunga@google.com> Merge "Use new channel count functions for audio masks"
1e54e6dfc1bb8d33089ed8857f0f194e696f85e2 19-May-2014 Glenn Kasten <gkasten@google.com> Merge "Pass stereo gains as packed minifloat"
e8a1ced4da17dc6c07803dc2af8060f62a8389c1 10-May-2014 Andy Hung <hunga@google.com> Add format parameter to getTrackName() and track_t

Change-Id: Ia152a839014e235fbfb656104c15d7c1b456d02e
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioMixer.h
astMixer.cpp
astMixerState.cpp
astMixerState.h
hreads.cpp
hreads.h
racks.cpp
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
udioFlinger.h
udioMixer.h
ffects.h
astMixer.cpp
astMixerState.h
laybackTracks.h
hreads.cpp
racks.cpp
5859b98476de3bbb4ae4dc00d4b2f010ca7897d3 19-May-2014 Eric Laurent <elaurent@google.com> am be2664da: am 4c9bde7a: am ce473c32: Merge "Codec Offload: Add NULL check as mCallbackThread is NULL when offloaded HAL is running BLOCKING mode"

* commit 'be2664dac34a6a9d9f754d4097b32158d4947cd2':
Codec Offload: Add NULL check as mCallbackThread is NULL when offloaded HAL is running BLOCKING mode
4c9bde7a3e636d3ecccd7905d142dbbb80e977a0 19-May-2014 Eric Laurent <elaurent@google.com> am ce473c32: Merge "Codec Offload: Add NULL check as mCallbackThread is NULL when offloaded HAL is running BLOCKING mode"

* commit 'ce473c32705e2d1c5fcc817198101e1220b3c8f7':
Codec Offload: Add NULL check as mCallbackThread is NULL when offloaded HAL is running BLOCKING mode
68112fc4f77ab8c4a744782f78e9792afe0cbfc1 14-May-2014 Andy Hung <hunga@google.com> Update AudioMixer::getTrackName to save channelMask

Change-Id: I4fb4abbff1b05bdd0f6e21b5f5f4c3f2a57ae28d
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
astMixer.cpp
e541269be94f3a1072932d51537905b120ef4733 16-May-2014 Andy Hung <hunga@google.com> Use new channel count functions for audio masks

Change-Id: Ia658ab4b6320d19fdb50f123c930918724ff0ef3
Signed-off-by: Andy Hung <hunga@google.com>
udioFlinger.cpp
udioMixer.cpp
hreads.cpp
racks.cpp
deb9081a61b446dbe50461082974a4228899f178 14-May-2014 Glenn Kasten <gkasten@google.com> Merge "Pull up mFlags and isFastTrack from Track to TrackBase"
cbe6fddebe3ec84176037de7f9681d2407fa1113 14-May-2014 Glenn Kasten <gkasten@google.com> Merge "Explicitly include Configuration.h"
2d859b91a59b4f6d63ff2bd93b462cab60f4a8d7 14-May-2014 Glenn Kasten <gkasten@google.com> Merge "Fix memory corruption if increaseSamplingN is not called"
56604aa3a56dc8e15532597a0a74b3c7b165e006 13-May-2014 Uday Gupta <guptau@broadcom.com> Codec Offload: Add NULL check as mCallbackThread is NULL
when offloaded HAL is running BLOCKING mode

b/14897952

Change-Id: I159a33e1181c1a62d80ab4bd3337a35dafaad884
Signed-off-by: Uday Gupta <guptau@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
hreads.cpp
755b0a611f539dfa49e88aac592a938427c7e1b8 13-May-2014 Glenn Kasten <gkasten@google.com> Pull up mFlags and isFastTrack from Track to TrackBase

Change-Id: I6bd48292310be4e05758a11f617f50585904422d
laybackTracks.h
ecordTracks.h
hreads.cpp
rackBase.h
racks.cpp
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
udioFlinger.h
tateQueue.h
963698408b1ce0f2ac7eab1e863dc7271de116a3 13-May-2014 Glenn Kasten <gkasten@google.com> Fix memory corruption if increaseSamplingN is not called

Change-Id: Icbf9aaf68c25ba3330ceb79167bd776cf0342d0d
astThreadState.cpp
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
udioFlinger.cpp
udioFlinger.h
ffects.cpp
hreads.cpp
hreads.h
racks.cpp
110135b9610fee8bfa5bac2d9ef4fc4c24991c36 09-May-2014 Glenn Kasten <gkasten@google.com> Explicitly ignore return value of __futex_syscall3

Change-Id: Ic65f257bfc4a0eff7bdd3c44fab68a3f17e2bd08
hreads.cpp
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
udioFlinger.h
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.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
udioFlinger.cpp
udioFlinger.h
ecordTracks.h
hreads.cpp
rackBase.h
racks.cpp
b880f5e5fc07397ddd09a94ba18bdf4fa62aae00 07-May-2014 Glenn Kasten <gkasten@google.com> Add a per-thread heap that is read-only to clients

Change-Id: I401263566ca20fbfb565689c8fa99458d3b283b2
hreads.cpp
hreads.h
828f883a43f66f77d776a75d0ea2b87c7c826071 07-May-2014 Glenn Kasten <gkasten@google.com> Fix a couple of fast capture typo bugs

AudioRecord constructor was not passing flags through to set().
Server-side check was using wrong kind of channel mask.

Change-Id: Ifaa880ec323771e9fd168262be05f3e539f53390
hreads.cpp
f655acf15e587dbf5d7120e9f2bf4b5bcb89941c 06-May-2014 Eric Laurent <elaurent@google.com> am 8fb04d47: Merge "Fix memory leak when filtering commands in insertCommand_l()"

* commit '8fb04d474ed9e0d1302ae223ee76fafbe5fb41a3':
Fix memory leak when filtering commands in insertCommand_l()
8fb04d474ed9e0d1302ae223ee76fafbe5fb41a3 06-May-2014 Eric Laurent <elaurent@google.com> Merge "Fix memory leak when filtering commands in insertCommand_l()"
d8484dd4cf124854e7ff950da4300887f32fd05b 05-May-2014 Glenn Kasten <gkasten@google.com> Merge "Use audio_is_linear_pcm()"
c4b88a8d0f524666bf0f390075c334d047a104f2 01-May-2014 Glenn Kasten <gkasten@google.com> Fix bug for direct track with PCM != 16-bit

The AUDIO_FORMAT_PCM_8_BIT format was being converted to
AUDIO_FORMAT_PCM_16_BIT on client side even for direct tracks.
That conversion was incorrect; it should only be done for mixed tracks.

Also remove checks for specific PCM formats in the generic part of
server side of createTrack. Those format checks should only be done by
the thread. This will allow direct tracks for PCM 8-bit, PCM 24-bit, etc.

Change-Id: If5b9fd79f8642ed93e2aeabcaf4809b2ed798978
udioFlinger.cpp
993fa0603707e94ce259e95e56838a85b5ccbdc5 02-May-2014 Glenn Kasten <gkasten@google.com> Use audio_is_linear_pcm()

Change-Id: I17b30fdb6dbb6454ad0a20dd703fd603a37a8397
hreads.cpp
1a7be1ec9c769203e6c8e26378de0ab8e2ad493d 29-Apr-2014 Bill Yi <byi@google.com> Merge commit '91820d46b5f3065c2fded3cdf65d305715b33bb1' into HEAD
2234002b0710c8db73f82d397cb945cd541c6bbb 07-Apr-2014 Glenn Kasten <gkasten@google.com> Start pulling bits of FastMixer up to FastThread

Change-Id: I4c6f7b8f88fcf107bb29ee6432feecd4ab6554d2
ndroid.mk
onfiguration.h
astMixer.cpp
astMixer.h
astMixerDumpState.h
astMixerState.cpp
astMixerState.h
astThread.cpp
astThread.h
astThreadState.cpp
astThreadState.h
e273141263e988ab086a8d41e0e4fc75c00f1b86 24-Apr-2014 Glenn Kasten <gkasten@android.com> am 7e5c6351: am 4513aa2c: Merge "AArch64: rewrite audioflinger\'s sinc resample by intrinsics."

* commit '7e5c635114a7762ad44581300021667a0da97389':
AArch64: rewrite audioflinger's sinc resample by intrinsics.
7e5c635114a7762ad44581300021667a0da97389 24-Apr-2014 Glenn Kasten <gkasten@android.com> am 4513aa2c: Merge "AArch64: rewrite audioflinger\'s sinc resample by intrinsics."

* commit '4513aa2cda9e636e4ac675dab9a1353b22e951ae':
AArch64: rewrite audioflinger's sinc resample by intrinsics.
4513aa2cda9e636e4ac675dab9a1353b22e951ae 24-Apr-2014 Glenn Kasten <gkasten@android.com> Merge "AArch64: rewrite audioflinger's sinc resample by intrinsics."
1b24cf32e02a1372e57b3a2a432bc0adfe496e6d 16-Apr-2014 Mark Salyzyn <salyzyn@google.com> am e80631aa: am 839d11d1: Merge changes I0a744dc7,Id993a70d

* commit 'e80631aa1992ca50af679cd6a018c0ffda7f9b17':
media: use size_t for integer iterator to Vector::size()
media: 64 bit compile issues
e80631aa1992ca50af679cd6a018c0ffda7f9b17 16-Apr-2014 Mark Salyzyn <salyzyn@google.com> am 839d11d1: Merge changes I0a744dc7,Id993a70d

* commit '839d11d1f7be9dff2f06c7d30a9eb39cb6782078':
media: use size_t for integer iterator to Vector::size()
media: 64 bit compile issues
3ab368e0810d894dcbc0971350c095049478a055 15-Apr-2014 Mark Salyzyn <salyzyn@google.com> media: use size_t for integer iterator to Vector::size()

Change-Id: I0a744dc7815a86a993df9b0623440be620ec8903
udioFlinger.cpp
racks.cpp
96b0d5ef85d4d71690c41c84456afbf19864c785 15-Apr-2014 Andy Hung <hunga@google.com> Merge "Improve resampler filter computation speed"
c125f38cd0ae35409a01b98a99e483550daa1313 12-Apr-2014 Glenn Kasten <gkasten@google.com> audioflinger: forward device change to effects in direct thread

Device change during offload playback is not informed to effect chain
which causes effects still work on unexpected output devices. Add device
change notification in direct output thread.

Original author wjiang <wjiang@codeaurora.org>

CRs-Fixed: 630408
Bug: 14053172
Signed-off-by: Glenn Kasten <gkasten@google.com>
Change-Id: I094a99bdf540479cee2fca6614ec35c2fa7d6046
hreads.cpp
48412dc92c4cc92a3f4821616e12290f5eeabd07 24-Mar-2014 Jesper Tragardh <jesper.tragardh@sonymobile.com> Fix memory leak when filtering commands in insertCommand_l()

When AudioPolicyService::AudioCommandThread::insertCommand_l filters
a command from the queue, the AudioCommand* is removed from the
vector mAudioCommands by calling mAudioCommands.removeAt(). This will
destroy the pointer and compact the vector, but not delete the
AudioCommand object.

This patch adds code to delete a filtered out AudioCommand and its
data object mParam. However, mParam was void* and deleting a void
pointer is undefined behavior according to the C++
standard. Therefore, the data classes are modified to inherit
from an abstract base class with a virtual destructor.

The deletion of non-filtered commands in
AudioPolicyService::AudioCommandThread::threadLoop() was already
correct, as each case casts mParam to the proper type before
deleting.

This also fixes AOSP issue 36370.

Change-Id: I2b63838aff3608132aa496f964a929f78c4b6267
udioPolicyService.cpp
udioPolicyService.h
df383a5a54582811e5e038efc557172b8ec69dd1 10-Apr-2014 Andy Hung <hunga@google.com> Update test-resample to handle multichannel

Option -c # specifies number of channels (mono default).
Option -s to specify stereo is removed (-c 2 replaces).
Option -h to specify WAV header is removed (WAV is now default).

Change-Id: Iba4b83806028a8a9c1ddba6f555182d214ef73ff
Signed-off-by: Andy Hung <hunga@google.com>
est-resample.cpp
12b44bd5fe3069cd3450d05b6c446b600e0553d3 10-Apr-2014 Zhongwei Yao <zhongwei.yao@arm.com> AArch64: rewrite audioflinger's sinc resample by intrinsics.

Pass conformance test on armv7 and aarch64, performance test is done on armv7.
Compared with original armv7 assembly version, this version has similar
result. Here is performance data on pandaboard android4.4 (input: random wave
file, unit: Mspl/s, toolchain:gcc 4.8):

| | origin(assembly) | current(intrinsics) | C version |
|----------------+------------------+---------------------+-----------|
| single channel | 6.17 | 7.14 | 3.43 |
| double channel | 5.24 | 5.63 | 3.50 |

Change-Id: If5670218e1586e9dfd2b8d9c66a6880f3e4808ca
udioResamplerSinc.cpp
771386e6e6e79697e2d839ef0f25a242946ba1e5 09-Apr-2014 Andy Hung <hunga@google.com> Add and enable floating point option for audio resampler

Can be tested with test-resample.

Change-Id: I8339846d7c647444b6025d33cfa145d5d3658121
Signed-off-by: Andy Hung <hunga@google.com>
udioResampler.cpp
udioResamplerDyn.cpp
udioResamplerDyn.h
d549139155b20d7cbf6a4326133e06def465ef54 09-Apr-2014 Andy Hung <hunga@google.com> Add floating point to audio resample processing

Add template type parameters for input, output data type.
Minor change in non-NEON mono channel handling.
Minor fixup on comments.

Change-Id: I7dc9972d130913718b62f32c02d31f99c06682f2
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerDyn.cpp
udioResamplerFirProcess.h
430b61c72094882bc48693dfc10c256a6ae36ee9 09-Apr-2014 Andy Hung <hunga@google.com> Add capability for floating point Kaiser window filters

Change-Id: Idbb33248bbab2300c2650a4657d8fbc482a5d46c
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerFirGen.h
781366833a12877b8d5ad4aa081114e30f799319 09-Apr-2014 Andy Hung <hunga@google.com> Update test-resample to handle floating point

Change-Id: Ib34d716fbabcd5eb70f8a5ffcf362e242671d916
Signed-off-by: Andy Hung <hunga@google.com>
est-resample.cpp
0d521d91154fe0199181c845b6dc70faf38ca8fb 08-Apr-2014 Glenn Kasten <gkasten@google.com> Merge "Fix 64-bit build warnings"
1e4e4f40b4e2c655ca377adbba53df897545c3ae 08-Apr-2014 Glenn Kasten <gkasten@google.com> Fix 64-bit build warnings

Change-Id: I667401522cb4ccd41013e2883a4c75ddeca08ef6
est-resample.cpp
bc6ae9bd4ee93e91e212ad35be038f21797ef31e 07-Apr-2014 Glenn Kasten <gkasten@google.com> Fix regression in FastMixer statistics

At some point, the mSampleRate in FastMixerDumpState stopped being
initialized correctly. I'm not sure when this happened, it doesn't seem to
be introduced in recent CLs. This lack of initialization caused
some of the FastMixer statistics based on sample rate to be useless.

Change-Id: Id2a96d606130a90c4c4f1bddd59778f6c6428a9c
astMixer.cpp
84a0c6e87c48f58a0d3be71961432c086a4d24cc 02-Apr-2014 Andy Hung <hunga@google.com> Change references of Q19.12 to Q4.27 for clarity

Change-Id: I5beb7daf6ff9bc123ff3582f7c294edcaf8652f6
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioResampler.h
ecordTracks.h
hreads.cpp
est-resample.cpp
bafa561d0c9363c5307b6b1daa498bd3ae36089d 02-Apr-2014 Andy Hung <hunga@google.com> Improve resampler filter computation speed

Approximate speed improvement is 10-15% for filter computation,
which is floating point intensive. This will be important
for devices without hw floating point support.

Change-Id: I10b4e778c8d632b52218a777504b092c189e437f
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerFirGen.h
2ade30003882f0c3782d68018d06cb81b99dfeb2 01-Apr-2014 Glenn Kasten <gkasten@google.com> Merge "FastMixer use FastThread and FastMixerState use FastThreadState"
1e0c8cd8fad2108c8ea085748fcca2059e3ce4ab 01-Apr-2014 Glenn Kasten <gkasten@google.com> Merge changes I5748f47d,I3f074933

* changes:
Add FastThread.h
Add FastThreadState
f7160b5dc3091fd9624f25d534c6848ee831b706 19-Mar-2014 Glenn Kasten <gkasten@google.com> FastMixer use FastThread and FastMixerState use FastThreadState

Change-Id: I594c973e9f575113bdefee6f4cf8c29d8beac1f3
astMixer.h
astMixerState.cpp
astMixerState.h
4cd161b5bf7a8008d684db4b217ed84d1704e683 19-Mar-2014 Glenn Kasten <gkasten@google.com> Add FastThread.h

Change-Id: I5748f47dbfa42c14cc93973742e05ac963bf3ba8
astThread.h
a18f644ce5eb4ab876b343e24ea613566c00058f 19-Mar-2014 Glenn Kasten <gkasten@google.com> Add FastThreadState

Change-Id: I3f07493375ace6e5cfdcd02ad90c4b6fad543b0c
ndroid.mk
astThreadState.cpp
astThreadState.h
3a6c90aa0617666d9abc94c02b752d9eb3d64772 13-Mar-2014 Glenn Kasten <gkasten@google.com> Add FIXMEs to createRecord for fast capture

Change-Id: I759be200fae32969212c52a409f46f2e704081e3
hreads.cpp
hreads.h
1490d5142d8d485ea0d56a9974726fb6dff0a62d 28-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Mark the logging heap read-only to media.log service"
c9b8d90dabdf1234be0117c592f635a92c4eb0d9 27-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>"
5c4fa907328c8ee586367272c7525cb87742f14d 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use LOG_ALWAYS_FATAL instead of LOG_FATAL"
142f519aa1acd5804d111e60d100f170fed28405 26-Mar-2014 Glenn Kasten <gkasten@google.com> Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>

Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
udioFlinger.cpp
adad3d7d935da176ff24941b4ae9edf7340e9b96 21-Feb-2014 Glenn Kasten <gkasten@google.com> Use LOG_ALWAYS_FATAL instead of LOG_FATAL

LOG_FATAL is compiled out in most builds, so the
assertion checks were not being performed.

Change-Id: I774f0985ab9c5ccecd8989a0f1c940386b73fc35
udioMixer.cpp
astMixer.cpp
hreads.cpp
racks.cpp
ecdca392ed40e89a6ef14b86446e952c35497ac4 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use symbolic constants from <system/audio.h>"
51beebba9d4989d05831a13bbe5cdf53ecac1bf5 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use symbol AUDIO_DEVICE_NONE from <system/audio.h>"
73ec11738cd4399c55d4905665a14a7c4cd42cbf 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Fix uses of KeyedVector"
45faf7e02791993a487d6e038d16ff46395f1975 17-Jan-2014 Glenn Kasten <gkasten@google.com> Use symbol AUDIO_DEVICE_NONE from <system/audio.h>

Change-Id: I61f882c5e7c949bf00d3bfc745ebf3b5e1c42a58
udioFlinger.cpp
66e4635cb09fadcaccf912f37c387396c428378a 17-Jan-2014 Glenn Kasten <gkasten@google.com> Use symbolic constants from <system/audio.h>

AUDIO_INTERLEAVE_*
AUDIO_STREAM_MIN
AUDIO_SESSION_ALLOCATE

Change-Id: I31dd6f327204685e50716079ce21c4ba206dff11
hreads.cpp
9ea65d0f4a564478343b1a722fae4ce5883670c3 17-Jan-2014 Glenn Kasten <gkasten@google.com> Fix uses of KeyedVector

Constructor for AudioFlinger::mAudioHwDevs was missing, and so
AudioFlinger::findSuitableHwDev_l() could return an undefined pointer
if a non-0 module wasn't found.

A KeyedVector of Plain Old Data (POD) element type must specify the
default value in the constructor, or else the default will be undefined.

Minor:
- Parameter had wrong type in constructor for AudioSystem::gOutputs.
- Remove obsolete AudioSystem::gStreamOutputMap.

Change-Id: I9841493e018440e559d8b8b0e4e748ba2b2d365b
udioFlinger.cpp
bcefec31bd1346133052356ffc8d7ac8a5b13fab 17-Jan-2014 Glenn Kasten <gkasten@google.com> Document AudioFlinger::nextUniqueId()

Change-Id: Iafe96f1c10bd85cb23a2553945ca68aa601dc2eb
udioFlinger.cpp
udioFlinger.h
46d1b4ab7e83c677532587c7c8bd46eb8b30fc67 19-Mar-2014 Glenn Kasten <gkasten@google.com> resolved conflicts for merge of f40c4c56 to master

Change-Id: Ifd5385ad42a81e02e6a6afc6281f09fbff361671
d09ec3b22013ef43d422c916dfd44bab9101a659 19-Mar-2014 Glenn Kasten <gkasten@android.com> am 36817364: Merge "Add libaudioresampler"

* commit '36817364738d4c45adc3e448fbec02a9611bfeda':
Add libaudioresampler
f40c4c561151ae93595e8fab5dcaaa1c69df74ef 19-Mar-2014 Glenn Kasten <gkasten@android.com> am 36817364: Merge "Add libaudioresampler"

* commit '36817364738d4c45adc3e448fbec02a9611bfeda':
Add libaudioresampler
ddf887c08b58382920effb7f0b2049e471960b4a 19-Mar-2014 Glenn Kasten <gkasten@android.com> Add libaudioresampler

libaudioresampler is available in both 32-bit and 64-bit,
unlike libaudioflinger which is currently 32-bit only.

Bug: 8141282
Change-Id: I839f7b4e6aaed6984012ca6d514323f927669df6
ndroid.mk
cf515ab0030cf5e0bef843638af7c989a8f6843a 15-Mar-2014 Glenn Kasten <gkasten@google.com> Mark the logging heap read-only to media.log service

Change-Id: Ie26a9e7e37c951774c71d2c53886db52dd5479aa
udioFlinger.cpp
d8590167fec151cc2e8f6e28e406c99882f40884 18-Mar-2014 Glenn Kasten <gkasten@android.com> am 77658a06: Merge "AudioPolicyService: malloc/delete pair"

* commit '77658a069c81a0d5b4a1b81443b470a3ea64cab0':
AudioPolicyService: malloc/delete pair
0c282de73240b1efce64558ab2fa0a8be1f4292b 18-Mar-2014 Glenn Kasten <gkasten@android.com> am 77658a06: Merge "AudioPolicyService: malloc/delete pair"

* commit '77658a069c81a0d5b4a1b81443b470a3ea64cab0':
AudioPolicyService: malloc/delete pair
77658a069c81a0d5b4a1b81443b470a3ea64cab0 18-Mar-2014 Glenn Kasten <gkasten@android.com> Merge "AudioPolicyService: malloc/delete pair"
2d3ca68363f723fbe269d3ce52dab4985dfc7154 07-Mar-2014 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: OffloadThread fix for resume underrun

AudioFlinger can miss resuming h/w on a pause->resume transition
if sufficient data isn't available

Bug: 11358524.
Change-Id: Ic3c75256290d3515fd4a96dfcc900909fbe5bc15
hreads.cpp
racks.cpp
164985121796cf214c7a83d32005d9b01125b558 18-Mar-2014 Eric Laurent <elaurent@google.com> AudioFlinger: Change track ready condition in STOPPING_1 state

Set FS_FILLED only if framesReady() > 0

Change-Id: Ibb1d2e988ff17fcf3a7ab61031a3f85df82f18d5
racks.cpp
8d6c292a0bed3d63b5b7297d09a604af6327c663 05-Feb-2014 Krishnankutty Kolathappilly <kkolat@codeaurora.org> audioflinger: Handle pause /resume in stopping state

-Pre-requisite:
Perform seek on the clip. After seek the data remaining till EOS
is little more than the driver and common block buffering.
-Framework state:
Offload thread is waiting for signal from the HAL for a free
buffer. Audio Player calls sink stop on reaching EOS. Audio
track is waiting on obtain buffer for a free space in common
block to send the last buffer. The track is moved to stopping
state as input EOS is reached.
-Issue:
Perform pause/ resume in this state(STOPPING), Audio playback
does not resume.
-Fix
Ensure resume is called in stopping state if frames ready is
greater than zero.

Bug: 12870871

Change-Id: Ib1378c4ee5ce4bea655691e93de0775f7b1d2804
Signed-off-by: Glenn Kasten <gkasten@google.com>
laybackTracks.h
hreads.cpp
racks.cpp
314869117d5e3365fc3e43fee01209d18515ca42 18-Mar-2014 Eric Laurent <elaurent@google.com> Merge "move audio policy service to a separate library"
3ef14ef30359376006a233f6a21a165d4b65a7df 13-Mar-2014 Glenn Kasten <gkasten@google.com> Make error handling more similar for output and capture

And simplify error case

Change-Id: I0bb1ec252945d672cc4cef137977b912f1b23d51
udioFlinger.cpp
racks.cpp
15e5798908ccac14e10c84834eaf08c42931bd06 24-Sep-2013 Glenn Kasten <gkasten@google.com> Make error handling for audio driver initCheck more similar

Change-Id: I8222f00f7ac89d52235af0f64f3fee7a8c471e1e
hreads.cpp
570f633e0b02d1bc25f3312b92e72cc29a40ca38 13-Mar-2014 Glenn Kasten <gkasten@google.com> Make session ID code similar between output and capture

Change-Id: I873a97d0e36e1a452421df4f749d51e1916797a5
udioFlinger.cpp
e848bd9abb3bbbd4c66f9fb9d1442f7663d7ba40 13-Mar-2014 Glenn Kasten <gkasten@google.com> Move declarations to where needed

Also remove unnecessary ALOGV and dead variable inFrameCount

Change-Id: I34547fb0fd2ff142fc60277bedfa4064e7356611
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
c3df838434b37d8400eea2438083cc01a4c1cc71 13-Mar-2014 Glenn Kasten <gkasten@google.com> Replace if/else by switch

Change-Id: Ibe96c8fb1f0ba7f850c0561f60769ce63aceba5d
hreads.cpp
05997e21af6c4517f375def6563af4b9ebe95f39 13-Mar-2014 Glenn Kasten <gkasten@google.com> Whitespace and comments

Change-Id: I99752cca74a459c4746ea4718acb0115439e50bd
udioFlinger.cpp
hreads.cpp
racks.cpp
0e0e846f3d86906ff990025981e514d6bcf44d8e 13-Mar-2014 Glenn Kasten <gkasten@google.com> Prepare for additional capture formats

Change-Id: Ib10b004f0029191b33a97671e41b0d86ebfbe0b9
udioFlinger.cpp
758799cef41fc5495f59eeb6249d02ce9154cde8 14-Mar-2014 Glenn Kasten <gkasten@google.com> resolved conflicts for merge of 3c780188 to master

Change-Id: Ic579d346c27ff05ea6444faaa60fa6caaec86fbf
236104afb2300b7d969b1dc786f14b5f912df1cf 14-Mar-2014 Glenn Kasten <gkasten@android.com> am 089affb6: Merge "mediaserver and associated services are 32-bit only"

* commit '089affb6c2d9ed1e2d49df4be02d30dc490506f9':
mediaserver and associated services are 32-bit only
3c7801882bbb6d5f3cc641525a54cb8a6c4aca34 14-Mar-2014 Glenn Kasten <gkasten@android.com> am 089affb6: Merge "mediaserver and associated services are 32-bit only"

* commit '089affb6c2d9ed1e2d49df4be02d30dc490506f9':
mediaserver and associated services are 32-bit only
5b10a2037a835e790994b9ebec3c2e55052f1f3b 13-Mar-2014 Andy Hung <hunga@google.com> Fix Offload playback in AudioFlinger

This fixes Offload playback regression introduced by adding
flexible format to mSinkBuffer. Test case is AAC file playback.

Bug: 13450717
Change-Id: I0fa11978295ed4793be90c565e5b8abedf156914
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
010a1a1a552cdaad362cea8a0333b8906402dbcb 13-Mar-2014 Andy Hung <hunga@google.com> Revert "Revert "Convert AudioFlinger mSinkBuffer to flexible format""

This reverts commit e2a9c29f35e0c09782558542fc4cf9823779590e.
hreads.cpp
hreads.h
e2a9c29f35e0c09782558542fc4cf9823779590e 13-Mar-2014 Eric Laurent <elaurent@google.com> Revert "Convert AudioFlinger mSinkBuffer to flexible format"

This reverts commit e7e676fd2866fa4898712c4effa9e624e969c182.

Bug: 13450717.
Change-Id: Ib80b0d14428fecce33c62003a1fcf83f71cee03b
hreads.cpp
hreads.h
af783aa91f7a279153fb8bab8d0d6b9f737996e9 03-Mar-2014 Glenn Kasten <gkasten@android.com> mediaserver and associated services are 32-bit only

also 32-bit only command-line apps

Change-Id: I9ac557a8d02bbf6986a9b5c3cdce23d400b306a3
ndroid.mk
c7e5040aa8b8e4da86814bf560346c7571e48087 06-Mar-2014 Eric Laurent <elaurent@google.com> move audio policy service to a separate library

Change-Id: Ibc3ef07aa9860b7fd4f9aaff27b0dbe0dcbf1cbf
ndroid.mk
udioPolicyService.cpp
udioPolicyService.h
e7e676fd2866fa4898712c4effa9e624e969c182 05-Mar-2014 Andy Hung <hunga@google.com> Convert AudioFlinger mSinkBuffer to flexible format

Change-Id: I618d9c99a5f6f8c8d6a9f4b2d19e82c9ddc3b06e
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
hreads.h
98ef978df4e928f486d244c4d7f7ad9f13111e98 04-Mar-2014 Andy Hung <hunga@google.com> Add mEffectBuffer to AudioFlinger

Change-Id: Icf97c50040bc127723d56eb4d2fb6e790a7253d9
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
hreads.h
f69f9869514730aebe5724c461768507084dfff7 07-Mar-2014 Glenn Kasten <gkasten@google.com> NBAIO::Format_from_SR_C requires audio_format_t parameter

Change-Id: I4b65f6ed2f6ca3608b3a5f88f52a93af0b9b1f4a
hreads.cpp
e857b65c1d3aa055281cb48f59c9b5eb4a062dd0 07-Mar-2014 Narayan Kamath <narayan@google.com> am 3c9130a8: Merge "Make frameworks/av 64-bit compatible"

* commit '3c9130a8a12ce962dc8d22e04243b135b9e98b01':
Make frameworks/av 64-bit compatible
10ac79930120efea20b125f5faedfe89e8674676 07-Mar-2014 Glenn Kasten <gkasten@android.com> am 5930e8eb: Merge "AudioFlinger: Remove code for supporting resampling in fast tracks"

* commit '5930e8ebdacf3a59c13eef11fd03658ba58b443e':
AudioFlinger: Remove code for supporting resampling in fast tracks
32fbb48de0248518fc5a14099b32fe4b8e9fc102 07-Mar-2014 Glenn Kasten <gkasten@android.com> am 4361749d: Merge "AudioTrack: Never try to use the fast path if resampling is required"

* commit '4361749d74113069aafb0620a1189404205c58d0':
AudioTrack: Never try to use the fast path if resampling is required
396a2bc8d1934ccea6159dfcee88e47f0c3c21aa 07-Mar-2014 Glenn Kasten <gkasten@android.com> am d66cd743: Merge "audioflinger: conform inline ASM to UAL"

* commit 'd66cd743525cc049033caa3e81cbdf74c72a4556':
audioflinger: conform inline ASM to UAL
55fbfbbbf00722dac3f789be69138445b771a1e1 06-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use larger capture pipe since we support resampling by 6:1"
6cbccee701e74fa43a5ea49c15af7dd3267b6699 14-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: Fix for a deadlock in track creation

AudioFlinger enters a deadlock (with itself) on trying to free a
RecordTrack or Track object that failed initialization. Clear this
bad object from the caller instead.

Bug: 12423233
Change-Id: I926f2beb922a70f6924e593e2bbf1a5b5df85b16
udioFlinger.cpp
hreads.cpp
4f4c9a22f4676c65bcae77f0805dcd699b3ba475 06-Mar-2014 Eric Laurent <elaurent@google.com> am 281dd4e1: audioflinger: fix static track end detection

* commit '281dd4e13309973dbb85bce531f884237e0d8fb0':
audioflinger: fix static track end detection
0c937b4946fae178447d9f8d29200fa2798c05f9 05-Mar-2014 Eric Laurent <elaurent@google.com> am eb16bb5d: am 7028a2c8: am 7e92abea: audioflinger: fix offload write buffer offset

* commit 'eb16bb5dcecf430bfec1c2a4bd15851c83b9c3cc':
audioflinger: fix offload write buffer offset
7028a2c8106ee5a22db88da5dad581820ee07254 05-Mar-2014 Eric Laurent <elaurent@google.com> am 7e92abea: audioflinger: fix offload write buffer offset

* commit '7e92abeafb184e8a34213d7149592e95a72601b0':
audioflinger: fix offload write buffer offset
281dd4e13309973dbb85bce531f884237e0d8fb0 21-Dec-2013 Eric Laurent <elaurent@google.com> audioflinger: fix static track end detection

If a static track is not a fast track,
prepareTracks_l() must rely on framesReady() to
detect end of buffer and remove the track from the active
track list.
Failing to do so results in the track staying active but
not processed by the mixer because in underrun. This leaves the
mix buffer content uninitialized and causes the effect process
function to accumulate its output onto undefined data.

Bug: 12013676.
Change-Id: I4b0819a9d93141ac3307b8786fc6a451dd585220
hreads.cpp
abab1c33caf0982c11713e6d64d60105dcbc8ab7 06-Jan-2014 Gaurav Kumar <gaurav.kumar@broadcom.com> AudioMixer: Remove tracks from enabledTracks after reseting outTemp

If any track goes through AudioMixer::process__genericNoResampling, and
its getnextbuffer returns NULL, Then that track is removed by AudioMixer
from enabledTracks.

Thus if all tracks getnextbuffer return NULL, Then this function doesn't
reset outTemp and last buffer in AudioFlinger's mMixBuffer will be
repeated and noise is observed.

Remove tracks from enabledTracks after reseting outTemp to zero, so that
process__genericNoResampling will reset outTemp and noise won't appear.

Bug: 12450065

Change-Id: I28996d425838728955f01eb1a00acf6e6dc2dea1
Signed-off-by: Gaurav Kumar <gaurav.kumar@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
udioMixer.cpp
7e92abeafb184e8a34213d7149592e95a72601b0 22-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: fix offload write buffer offset

Fix current audio HAL write buffer offset calculation
which assumes that the frame size is a multiple of 2.
'
Bug: 12823725.

Change-Id: I0195ed5cfef225a6f114e7dd405a02680bb7254e
hreads.cpp
0504a198d6595e29e58d1d66ae59fac1d662384a 05-Mar-2014 Haynes Mathew George <hgeorge@codeaurora.org> am 632c3790: am 7c206e5b: am e0cd1051: audioflinger: update track ready condition

* commit '632c3790523896260dc43fd6cd40a158765cdb15':
audioflinger: update track ready condition
d384a2c44810ce1b51277cc4ab4c5415ff7de6ee 05-Mar-2014 Haynes Mathew George <hgeorge@codeaurora.org> am 4f9e38c6: am 21e81bca: am e010f65e: audioflinger: Fix for a deadlock in track creation

* commit '4f9e38c60cc79407a8b2966b3b9780a3e395b017':
audioflinger: Fix for a deadlock in track creation
7c206e5bd24b5ae4565d0e60b637458a1054dfcf 05-Mar-2014 Haynes Mathew George <hgeorge@codeaurora.org> am e0cd1051: audioflinger: update track ready condition

* commit 'e0cd1051ed9fea0629745c29020516ae62298461':
audioflinger: update track ready condition
21e81bca4d1e6f7d1ccac61b65da7c7a4a121064 05-Mar-2014 Haynes Mathew George <hgeorge@codeaurora.org> am e010f65e: audioflinger: Fix for a deadlock in track creation

* commit 'e010f65e6337267cb15f8894c950a3f64370dd36':
audioflinger: Fix for a deadlock in track creation
50c3157c5a3e0617be77716beff1ae8801d8a72f 04-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: check for condition before waiting

AsyncCallbackThread must check for any condition that
was already been satisfied before waiting.

Bug: 11824817
Change-Id: I04683a1f355de4f440106cab47fd916aa39d5e35
hreads.cpp
e0cd1051ed9fea0629745c29020516ae62298461 28-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: update track ready condition

Signal track ready if the track isStopping().

Bug: 12423190
Change-Id: I95e14905df10ebf301e398263478c8ca25d7e2ce
racks.cpp
e010f65e6337267cb15f8894c950a3f64370dd36 14-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: Fix for a deadlock in track creation

AudioFlinger enters a deadlock (with itself) on trying to free a
RecordTrack or Track object that failed initialization. Clear this
bad object from the caller instead.

Bug: 12423233
Change-Id: I926f2beb922a70f6924e593e2bbf1a5b5df85b16
udioFlinger.cpp
hreads.cpp
788207057ed4b8df4719ed8089f376ef52de9ca1 01-Mar-2014 Andy Hung <hunga@google.com> Rename mSinkFormat to mMixerFormat for AudioMixer::track_t

AudioMixer::SINK_FORMAT also changes to AudioMixer::MIXER_FORMAT

Change-Id: Ic3f8be77d2c75c082c4fd140bc907e30c304d285
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioMixer.h
hreads.cpp
7ed1873acbf43280c5afe51833c3d628fe34e258 01-Mar-2014 Andy Hung <hunga@google.com> Merge "Use float_from_q19_12 conversion in AudioMixer"
3375bde6c6c1821fca3eeb4840774112e26c9a68 01-Mar-2014 Andy Hung <hunga@google.com> Use float_from_q19_12 conversion in AudioMixer

Change-Id: Idbe84fb9610c7e636a84468f2e2402a913435ca9
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
e842614837e5401adf77e90485300c288b9a7876 01-Mar-2014 Glenn Kasten <gkasten@google.com> Use larger capture pipe since we support resampling by 6:1

This avoids overruns on the client AudioRecord side,
without requiring client to use a large buffer.
It should not increase input latency, since a newly started AudioRecord
always joins the stream starting at the latest data.

Change-Id: Ib2b8de75cc40a6a3d493a1f8b46b41220f69264f
hreads.cpp
b442921146664fba77b91f221e9b1997ffb8170e 01-Mar-2014 Andy Hung <hunga@google.com> Merge "Add MixerBuffer for accumulation of float audio"
3c35c48a47e9cfbc25778652ff8423f905271a19 28-Feb-2014 Andy Hung <hunga@google.com> Merge "Rename mixBufferSize to mSinkBufferSize in AudioFlinger"
eafbe37da9a08f7599281bc19e000cdf70ae08b6 28-Feb-2014 Andy Hung <hunga@google.com> Merge "Rename constants for MixBufferSize to SinkBufferSize"
625b57c5ab5fefde1547d89a061420be733fb7dd 28-Feb-2014 Andy Hung <hunga@google.com> Merge "Rename mMixBuffer to mSinkBuffer in AudioFlinger"
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
69aed5f0f4a3be3996d1e78a0473e1a72c1547da 26-Feb-2014 Andy Hung <hunga@google.com> Add MixerBuffer for accumulation of float audio

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

Change-Id: I9d50752607d22dd2a3d9cc7e053babf8dfb22958
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
hreads.h
25c2dac12114699e90deb1c579cadebce7b91a97 27-Feb-2014 Andy Hung <hunga@google.com> Rename mixBufferSize to mSinkBufferSize in AudioFlinger

Change-Id: I4d1d18d716fa3ad8c0e7cc87f5a2823422f504eb
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
hreads.h
09a5007b17acb49d25cfa386a2e2534d942e8854 27-Feb-2014 Andy Hung <hunga@google.com> Rename constants for MixBufferSize to SinkBufferSize

Updated variable names are
kMinNormalSinkBufferSizeMs
kMaxNormalSinkBufferSizeMs

Change-Id: I91969eae3f8c10275db8778634cbf05fdec0712b
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
2098f2744cedf2dc3fa36f608aa965a34602e7c0 27-Feb-2014 Andy Hung <hunga@google.com> Rename mMixBuffer to mSinkBuffer in AudioFlinger

Change-Id: I1f55630425b8ce36e9df2aaf64e06a8960b69a47
Signed-off-by: Andy Hung <hunga@google.com>
hreads.cpp
hreads.h
8897759002677a7072a51a7f0b7cc63761c5f2d4 27-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Move up AudioFlinger::createTrack and openRecord parameter checks"
53b5d098b7d5d4412b9b9fe08daaf84c56b716e9 05-Feb-2014 Glenn Kasten <gkasten@google.com> Move up AudioFlinger::createTrack and openRecord parameter checks

Perform the basic sample rate, format, and channel masks tests as
early as possible. Now the thread methods only need to do the thread
type-specific checks.

Change-Id: I57d8319a228dda0446ca9b3ddcb7c9f67f28238c
udioFlinger.cpp
4d3c5bde85c5404d7927a770da90a5c9d09fb6a7 27-Feb-2014 Andy Hung <hunga@google.com> Merge "Add Track Sink Format to AudioMixer"
a1ab7cc8611c83427b57f6d4d4ce7aad9d1c0330 25-Feb-2014 Andy Hung <hunga@google.com> Add Track Sink Format to AudioMixer

Track Sink Format now allows both AUDIO_FORMAT_PCM_FLOAT and
AUDIO_FORMAT_PCM_16_BIT (default). The float case is not
enabled now.

Change-Id: Ibee70cab4725c8bc9905e49f1f9a9c2448f76e00
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioMixer.h
b78d804b1090a430a126a6c356037ded96ffd91a 25-Feb-2014 Andy Hung <hunga@google.com> Merge "Fix 1:1 dynamic resampler rate setting"
9d518f1aa50da9c3dfadb97090fb79aac886da12 25-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "The -O option now takes a CSV instead of a single value"
323da1015a758243c2c43017b026a01c6cf0c6f2 22-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Account for unreleased frames when predicting resampler needs"
d0e0cfa58a35508c14818b88804845194b5d80e1 22-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Make tee sink work again"
607fa3e928de696eba49f198af72d68e4591ca1b 21-Feb-2014 Glenn Kasten <gkasten@google.com> Account for unreleased frames when predicting resampler needs

Other changes related to resampling:
- improve logs
- use correct form of assert
- don't round up max usable circular buffer sizes to power of 2;
this gives more predictable results
- add some FIXMEs

Bug: 13133176
Change-Id: I8d3c90eed4eb0c0c1fbac3c864e179a2806c2301
hreads.cpp
c52b033f0be38ca915d389b672bcf9c46b4c78ef 21-Feb-2014 Glenn Kasten <gkasten@google.com> The -O option now takes a CSV instead of a single value

Also added -P option to provide a CSV list of provided values.

Change-Id: I4e0d6fe8b062d27d95d33493f80bd8f1c510d2c8
est-resample.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
1af34085e18c4d5ab297232f167a71e89ff7f65d 20-Feb-2014 Andy Hung <hunga@google.com> Fix 1:1 dynamic resampler rate setting

Change-Id: Id69e98ebaaca8dd8c976eb823f1cc1024b0eddf5
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerDyn.cpp
56df9ff31d583ad3eae4f279a3df550273c58e1e 17-Feb-2014 Glenn Kasten <gkasten@google.com> Allow specifying frames per call to resample()

Bug: 13073201
Change-Id: Id2f0fcd7562d9ba5a58c128d71bbba42dfea86cc
est-resample.cpp
d20db4c4d8eb2593b5d0214890420a49e0b01796 20-Feb-2014 Andy Hung <hunga@google.com> Merge "Fix resampler to allow output of single frame"
24781fff62a4cf7279d3dac83c33e2ac612712ba 19-Feb-2014 Andy Hung <hunga@google.com> Fix resampler to allow output of single frame

Bug: 13073201
Change-Id: If7818a3389a191a37277bbd8e96a59ef8ce68509
Signed-off-by: Andy Hung <hunga@google.com>
udioResampler.cpp
udioResampler.h
udioResamplerCubic.cpp
udioResamplerDyn.cpp
udioResamplerSinc.cpp
4cc0a6a835c806d200ef83ef31fe5bef327c355c 17-Feb-2014 Glenn Kasten <gkasten@google.com> Multi-client recording continued

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

Change-Id: I3aa54b862843d518b6e4ece9a7f52fd27d741629
udioFlinger.cpp
hreads.cpp
hreads.h
25f4aa83efaa9179e65a20583a6d441de2c3ff3f 07-Feb-2014 Glenn Kasten <gkasten@google.com> Move handleSyncStartEvent and clearSyncStartEvent to RecordTrack

Change-Id: I611a63e63acf3eb17e2072c1a77b91fe9e62e36a
ecordTracks.h
hreads.cpp
hreads.h
racks.cpp
deca2ae0a7cf8bc54ff3f30b7dc39bbc78b94c0d 07-Feb-2014 Glenn Kasten <gkasten@google.com> Add _l suffix to readInputParameters/OutputParameters

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

Change-Id: I56df71563a52a5cd6cea6fc0914df993519e1b74
ecordTracks.h
hreads.cpp
hreads.h
6dd62fb91d82dedcfa3ab38c02eb0940b4ba932a 06-Dec-2013 Glenn Kasten <gkasten@google.com> Multi-client recording

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

Change-Id: Icea55b4fd30751761b7debaa3ce016c79e712d8d
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
c940c38242e8e0265db25a646ad63263934f2bb9 13-Feb-2014 Marco Nelissen <marcone@google.com> Merge "Track pid for each session"
c6d7ab74962bfd24d105277b28248b4819763abd 12-Feb-2014 Andy Hung <hunga@google.com> Merge "Proper adjustment of filterlength for downsampling"
a3bb9a3a25b58669d75da4f73764ac4c2bf34158 11-Feb-2014 Andy Hung <hunga@google.com> Proper adjustment of filterlength for downsampling

Bug: 12963040
Change-Id: I772b8efd3f7eae6d075994b210dd0168f5365f4d
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerDyn.cpp
d457c970c8d08519cd77280a90b61ae1e342cfe3 11-Feb-2014 Marco Nelissen <marcone@google.com> Track pid for each session

so they can be properly freed.

Change-Id: I6f389035bc29e74e7c367c1c6d0252b180f666b3
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
ffects.cpp
astMixer.cpp
tateQueue.cpp
hreads.cpp
hreads.h
racks.cpp
b1f5b0dd237c2767ad7bc0b081d03aafc87589ea 10-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix clang warnings in AudioFlinger"
4b76d27d6c4751b31a1cb8ac5e6da1d4b7724a7b 10-Feb-2014 Glenn Kasten <gkasten@android.com> am 5a458ede: am 5930e8eb: Merge "AudioFlinger: Remove code for supporting resampling in fast tracks"

* commit '5a458ede3b7d303723fde4b856532bdc3b94971b':
AudioFlinger: Remove code for supporting resampling in fast tracks
3523e8c40bc60af0c95d1aa71a51a13d69ec80a2 10-Feb-2014 Glenn Kasten <gkasten@android.com> am 4e12dade: am 4361749d: Merge "AudioTrack: Never try to use the fast path if resampling is required"

* commit '4e12dadeec10993d2f77cce96600e73ca0dd86e2':
AudioTrack: Never try to use the fast path if resampling is required
5930e8ebdacf3a59c13eef11fd03658ba58b443e 10-Feb-2014 Glenn Kasten <gkasten@android.com> Merge "AudioFlinger: Remove code for supporting resampling in fast tracks"
4361749d74113069aafb0620a1189404205c58d0 10-Feb-2014 Glenn Kasten <gkasten@android.com> Merge "AudioTrack: Never try to use the fast path if resampling is required"
9601c6efcb2552960d6f125d073525b581c1b7ec 10-Feb-2014 Marco Nelissen <marcone@google.com> Merge "Pretty up audioflinger dumpsys"
01d3acba9de861cb2b718338e787cff3566fc5ec 06-Feb-2014 Glenn Kasten <gkasten@google.com> Fix clang warnings in AudioFlinger

Change-Id: I0fa61025c979709ad7d655bc717df5f194b6089e
udioFlinger.h
udioMixer.h
udioPolicyService.cpp
udioResampler.cpp
udioResampler.h
ffects.cpp
ffects.h
ec95f0e82a680931e9c7c9011dbbd68d5ab484c8 10-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Use printf format %#x for audio_format_t in logs"
b220884bf3129253cc5bc8d030bc475411ea4911 07-Feb-2014 Marco Nelissen <marcone@google.com> Pretty up audioflinger dumpsys

Change-Id: I57e44b4c36b99f7149542bbcf9645521c6152dfa
udioFlinger.cpp
udioFlinger.h
ffects.cpp
astMixer.cpp
laybackTracks.h
ecordTracks.h
hreads.cpp
racks.cpp
8f762d577f2dcf34357eb8731070ae465649ec9a 08-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix whitespace"
a793625031a3e326a261a0843598c35a5784bbde 07-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Use Format_isValid() and Format_isEqual() instead of direct comparison"
4944acb7355b3aa25748fd25945a363a69d65444 19-Aug-2013 Glenn Kasten <gkasten@google.com> Fix whitespace

Change-Id: I9add0872030a26933f6b6dad1be299154611cc56
udioPolicyService.cpp
hreads.cpp
hreads.h
racks.cpp
cac3daa6332bf6d1f7d26adc4a9915f3d7992dd9 07-Feb-2014 Glenn Kasten <gkasten@google.com> Use printf format %#x for audio_format_t in logs

Change-Id: I1c611d1037685d52ccc84efe0fccd6413ec938e9
udioFlinger.cpp
hreads.cpp
f74f213c0cd0612101e00a73704429dac1a92fe3 07-Feb-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: Offload track transition fix"
d9a4783985203c759ddcca784798ef395668fe05 07-Feb-2014 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: Modify flush handling for offload path"
c9583cba9913682e1c181675c6d0066292fb719d 07-Feb-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: OffloadThread state fix"
010c4c8ec50eb04ece15f792c508a3b869749310 07-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix IoConfigEvent constructor initializer list"
4c6a433d74d5ae8b9bc0557207e3ced43bf34a25 15-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> AudioFlinger: Offload track transition fix

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

Bug: 12530661
Change-Id: I95b62764c7ac041d470702e86b951f812eb0e70f
hreads.cpp
hreads.h
7844f679be8d94c5cdf017f53754cb68ee2f00da 15-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> AudioFlinger: Modify flush handling for offload path

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

Bug: 12530661
Change-Id: Ib33f023c942f6c091b618004136b153c38a6eef6
laybackTracks.h
hreads.cpp
hreads.h
racks.cpp
0f02f265123b7ef2fd6ac09ff70cde26eb5559ad 11-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: OffloadThread state fix

When switching from one offload session to another that
reuses the same offload output, audio HAL is paused & flushed in
preparation for the new track

OffloadThread must reset mHwPaused to allow proper state transitions
for the second track. In addition, Offload thread need not
explicitly call resume on HAL while handling a flush.

Bug: 12530661
Change-Id: I8173845e1782b5a8b372a82c7d337299a61e0efe
hreads.cpp
3ce28aa3cb5262775180a8b423cfb4a5670ebc59 05-Feb-2014 Martin Storsjo <martin@martin.st> AudioFlinger: Remove code for supporting resampling in fast tracks

This isn't used at the moment.

Change-Id: I4e0fb2af5f7d959dbafd5ddb7defa1c6b8e8636a
astMixer.cpp
astMixerState.cpp
astMixerState.h
hreads.cpp
4a25471795b05ffcfcc079e9f9cb5ed549023d14 05-Feb-2014 Glenn Kasten <gkasten@android.com> am 5ef74dce: am d66cd743: Merge "audioflinger: conform inline ASM to UAL"

* commit '5ef74dce64a1b70534547c044a6d15533f4a9dca':
audioflinger: conform inline ASM to UAL
7332c37c459f5f382a9e4105d522d1c5a7f6f0b5 05-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "audioflinger: Fix for a deadlock in track creation"
2a16afb8dc056877f34124ba5befe75171de930f 05-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Fix unused parameter warnings in audio"
5f51ade2c290e239a125dc88943b240e1105fd97 04-Feb-2014 synergy dev <synergye@codefi.re> audioflinger: conform inline ASM to UAL

Clang requires some inline ASM to conform to the UAL standards (Unified Assembler Language).
This fixes a small issue in this inline asm to allow building.

Change-Id: Ifd9b1814343ab5ade636b9401a21d575559dac16
udioResampler.cpp
6e0d67d7b496ce17c0970a4ffd3a6f808860949c 31-Jan-2014 Glenn Kasten <gkasten@google.com> Use Format_isValid() and Format_isEqual() instead of direct comparison

Change-Id: Ie87607aa514976947540a77775e6425c4e56e7d9
udioFlinger.cpp
astMixer.cpp
racks.cpp
a98a58ce32f4ad1bdb7692184eb17622fb11e397 04-Feb-2014 Andy Hung <hunga@google.com> Merge "Fix dynamic resampling for non-NEON devices"
83be2560d9396b3bd32919123bd67a783e6aaf7c 03-Feb-2014 Andy Hung <hunga@google.com> Fix dynamic resampling for non-NEON devices

The stride by 16 code template automatically falls back to stride by 2
(as the NEON code template override does not occur).
As such the stride by 2 (in the switch) was removed as it was unnecessary.
Removing the if() causes the fall back to happen properly for non-NEON
compilation.

Change-Id: Ia7aec6ae1d88eb54377e56e2fb57f2ae5b74cf1b
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerDyn.cpp
0f11b51a57bc9062c4fe8af73747319cedabc5d6 01-Feb-2014 Glenn Kasten <gkasten@google.com> Fix unused parameter warnings in audio

Change-Id: I665ba3358dd9502f0adec70d486e7bf8a2e1b0fe
udioFlinger.cpp
udioPolicyService.cpp
ffects.cpp
hreads.cpp
hreads.h
racks.cpp
49debee5bdddd7a1e0742a3ab66d4630bbe25ca2 01-Feb-2014 Glenn Kasten <gkasten@google.com> Fix IoConfigEvent constructor initializer list

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

Change-Id: I2b36e2b7e1dcc2039c494fc5ea4994d262435aac
hreads.h
398f21348e5100289f6e5be30c8b5257fa04aaf9 31-Jan-2014 Martin Storsjo <martin@martin.st> AudioTrack: Never try to use the fast path if resampling is required

Unless AudioFlinger was built with FAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE
enabled, AudioFlinger would deny using the fast path (and internally
fall back to the normal codepath) when it realized that resampling
was required. Since the buffer size calculations within AudioFlinger
don't take resampling into account properly (see the calculation
below "AUDIO_OUTPUT_FLAG_FAST denied" in audioflinger/Threads.cpp,
just below the hunk that this patch changes), make sure AudioTrack
doesn't try to use the fast path if resampling is required.

This removes the possibility to enable
FAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE in AudioFlinger since it
AudioTrack now won't even try to use the fast path for content
that requires resampling, regardless of the AudioFlinger configuration.

Change-Id: Icf0f8ad50bf0fdb84657f518c0120aa0535f23f9
onfiguration.h
hreads.cpp
9e0308c03d4e76d3146cbb6e30aeb3ac03f05cf5 30-Jan-2014 Andy Hung <hunga@google.com> Enable new dynamic audio resampler as default

The default may still be overridden by af.resampler.quality
in the local or build properties file. For the build properties
check the relevant device.mk files.

In the absence of being overridden, the 44.1 to 48kHz and
48 to 44.1kHz conversion will use the DYN_MED_QUALITY resamplers
and other conversion will use the DYN_LOW_QUALITY resamplers.

Change-Id: Icf9a4af5422cddc445e1904eef93984b0abe6a44
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioResampler.cpp
745e9a8283b56c7772ee7d72383a3f2e012e1ef9 21-Dec-2013 Eric Laurent <elaurent@google.com> audioflinger: fix static track end detection

If a static track is not a fast track,
prepareTracks_l() must rely on framesReady() to
detect end of buffer and remove the track from the active
track list.
Failing to do so results in the track staying active but
not processed by the mixer because in underrun. This leaves the
mix buffer content uninitialized and causes the effect process
function to accumulate its output onto undefined data.

Bug: 12013676.
Change-Id: Iad72c921fa18d34811abf7d1073890c093a27725
hreads.cpp
e983e0a0017fce81dc3d9bea36f5abb7b7bce40b 30-Jan-2014 Andy Hung <hunga@google.com> Merge "Remove warnings in Audio mixer resampler compilation."
03e9e83c47ab4a518da0a1f36b8f702f59221c95 14-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: Fix for a deadlock in track creation

AudioFlinger enters a deadlock (with itself) on trying to free a
RecordTrack or Track object that failed initialization. Clear this
bad object from the caller instead.

Bug: 12423233
Change-Id: I926f2beb922a70f6924e593e2bbf1a5b5df85b16
udioFlinger.cpp
hreads.cpp
ee931ff7d6620e5705f4dfba901fdb03fa4a35fd 28-Jan-2014 Andy Hung <hunga@google.com> Remove warnings in Audio mixer resampler compilation.

Change-Id: Ie68766142796772a54a90afdea188d0a5a78d4ac
Signed-off-by: Andy Hung <hunga@google.com>
udioMixer.cpp
udioResampler.cpp
000a4193dd82549192277fd4b9bb571d8a4c262f 30-Jan-2014 Eric Laurent <elaurent@google.com> audioflinger: fix record thread exit pending check

RecordThread loop must not release the mutex after checking for
exitPending and before waiting for a new wake up condition.
This can happen under the hood when methods like processConfigEvents_l()
or checkForNewParameters_l() are called. So exitPending() must
be checked after calling these functions.

Bug: 12787961.
Change-Id: Ia18c518bd5344fbb2401067303fcfe76a86879c4
hreads.cpp
0eed5ac1a14067d0fd51282e97b43b4fd9121842 29-Jan-2014 Glenn Kasten <gkasten@google.com> Merge commit 'adf3f9b9' into manualmerge

Change-Id: Icdef7d075b160eb2a5ced7c57f90c6a6a4b4c64a
1bf0eecd2ec6a3b3e29ad2c91bcefda76abef2fe 29-Jan-2014 Glenn Kasten <gkasten@android.com> Merge "AudioMixer: Remove tracks from enabledTracks after reseting outTemp"
7e79cd2d3067cdb7b9daf639cf772d4dd149c934 06-Jan-2014 Gaurav Kumar <gaurav.kumar@broadcom.com> AudioMixer: Remove tracks from enabledTracks after reseting outTemp

If any track goes through AudioMixer::process__genericNoResampling, and
its getnextbuffer returns NULL, Then that track is removed by AudioMixer
from enabledTracks.

Thus if all tracks getnextbuffer return NULL, Then this function doesn't
reset outTemp and last buffer in AudioFlinger's mMixBuffer will be
repeated and noise is observed.

Remove tracks from enabledTracks after reseting outTemp to zero, so that
process__genericNoResampling will reset outTemp and noise won't appear.

Bug: 12450065
Change-Id: I1ccac7ee4a3bf7fd930254356c072099e11e7c19
Signed-off-by: Gaurav Kumar <gaurav.kumar@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
udioMixer.cpp
f0002d142e6d24c5438600b2c259679de710f8ac 24-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Replace control block frameCount_ by explicit in/out parameter"
0ce5ca5e113d58cbcb7cb48615d6dbbf3fbe7c66 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Cleanup createTrack error handling"
6a507298357c9ff869b97db57a890e58bd6bdec0 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "AudioRecord::getInputFramesLost() cleanup"
0cde076ddb283c84c3801a2df4cc3df99bd1577f 17-Jan-2014 Glenn Kasten <gkasten@google.com> Cleanup createTrack error handling

Similar to cleanup done earlier for openRecord in this CL:
> Change-Id: I84897dd7d30b370640b54e928f230604b873cb68

Bug: 10888816
Change-Id: I804a47f898e0319a60a9bd58906bbb037e45cc25
udioFlinger.cpp
hreads.cpp
dbed8955148dd2fe39584007c528e3a532f1a04e 15-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Fix error handling in AudioSystem::getOutputForEffect"
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
5b27ccd67c845aa20a12a1fb58339e7e81e3d536 15-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Use AUDIO_SESSION_ALLOCATE instead of 0"
03f696e3eb89c0642f9a2b761ff2cfc6af003d16 10-Jan-2014 Andy Hung <hunga@google.com> Merge "Improve dynamic audio resampler filter generation"
6340829ffb9ff7586ffb88a214f56340d4c70d60 10-Jan-2014 Glenn Kasten <gkasten@android.com> am 0ba9f9b0: am d8d45edf: am 61540b5f: Merge "Frameworks: AudioFlinger: Fix effects memory leak"

* commit '0ba9f9b07d47e9e6b374798f397fe961256a6029':
Frameworks: AudioFlinger: Fix effects memory leak
61540b5fe82cad1c6baa018f02bd2554e62e4364 10-Jan-2014 Glenn Kasten <gkasten@android.com> Merge "Frameworks: AudioFlinger: Fix effects memory leak"
efa6ea97022780b68e595e5326e30dbe2a799202 08-Jan-2014 Glenn Kasten <gkasten@google.com> Fix error handling in AudioSystem::getOutputForEffect

and AudioPolicyService::getOutputForEffect.
The conventional error value for audio_io_handle_t is 0,
not a status_t cast to audio_io_handle_t.

Change-Id: I34b3fd1a50f3fa1cbf39f32eea1911112a4e094a
udioPolicyService.cpp
6582f2b14a21e630654c5522ef9ad64e80d5058d 03-Jan-2014 Andy Hung <hunga@google.com> Improve dynamic audio resampler filter generation

Improve dynamic audio resampler filter generation speed by 2x.
The resulting filters should be the same (excepting roundoff).

Also added check for upsampling sample rate changes to share
previously generated filters.

Modify the profiling to improve output format and sampling result
reliability.

Change-Id: I9aa6b914fd552a63f79dd4a95945df2f8275772a
Signed-off-by: Andy Hung <hunga@google.com>
udioResamplerDyn.cpp
udioResamplerDyn.h
udioResamplerFirGen.h
est-resample.cpp
0bcfa88149e2404b34d13c622e3921e1b846cdf8 28-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: update track ready condition

Signal track ready if the track isStopping().

Bug: 12423190
Change-Id: Ie279995d5f90fa8211a20dfbeacc1cf9b921d0bf
racks.cpp
67d15f9ab45e7c03b23c871f680b1fae577ac43a 07-Jan-2014 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix static track end detection"
86eae0e5931103e040ac2cdd023ef5db252e09f6 09-Dec-2013 Andy Hung <hunga@google.com> Audio resampler update to add S16 filters

This does not affect the existing resamplers.
New resampler accessed through additional quality settings:

DYN_LOW_QUALITY = 5
DYN_MED_QUALITY = 6
DYN_HIGH_QUALITY = 7

Change-Id: Iebbd31871e808a4a6dee3f3abfd7e9dcf77c48e1
Signed-off-by: Andy Hung <hunga@google.com>
ndroid.mk
udioResampler.cpp
udioResampler.h
udioResamplerDyn.cpp
udioResamplerDyn.h
udioResamplerFirGen.h
udioResamplerFirOps.h
udioResamplerFirProcess.h
udioResamplerFirProcessNeon.h
est-resample.cpp
13e4c960ea3db03a43e084fbd85d52aa77f7b871 21-Dec-2013 Eric Laurent <elaurent@google.com> audioflinger: fix static track end detection

If a static track is not a fast track,
prepareTracks_l() must rely on framesReady() to
detect end of buffer and remove the track from the active
track list.
Failing to do so results in the track staying active but
not processed by the mixer because in underrun. This leaves the
mix buffer content uninitialized and causes the effect process
function to accumulate its output onto undefined data.

Bug: 12013676.
Change-Id: Iad72c921fa18d34811abf7d1073890c093a27725
hreads.cpp
aea7ea06394bcb155972d82055d4ea59962e4051 26-Jun-2013 Glenn Kasten <gkasten@google.com> Use AUDIO_SESSION_ALLOCATE instead of 0

Also fix a couple of places where we were using AUDIO_SESSION_OUTPUT_MIX,
which happens to also be equal to 0, but has a different meaning.

Change-Id: I90e39be3b89f5021a96d9e3b8d10929013ca977f
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
racks.cpp
47f3f5a119194d4c06815453be9950ba112c8e3e 18-Dec-2013 Glenn Kasten <gkasten@google.com> Fix bug in test-resample's AudioBufferProvider

The contract for AudioBufferProvider::releaseBuffer() was missing.

Bug: 12194314
Change-Id: I2fcf75e7b8eaf6db34f360206d79457a04a73565
est-resample.cpp
bd72d22097f78f5bd668b223bc8c94e351311e31 18-Dec-2013 Glenn Kasten <gkasten@google.com> Add ability to read .wav files to test-resample

Previously test-resample could only read .raw files, and the input
sample rate had to be specified. Now the input sample rate is derived
from the input file. This also allows us to read 8-bit PCM files,
and other formats such as floating-point in the future.

However, the ability to read raw files is lost.
A workaround is to use sox or equivalent on the host.

Change-Id: Icd06b4d02482b3ad07bf03979f46860e68d38ad9
est-resample.cpp
f5293648b727fb3909cd2300a73377f032f8b050 17-Dec-2013 Glenn Kasten <gkasten@google.com> Use libsndfile to write .wav files

This will reduce code duplication, and allow us take advantage of more
advanced capabilities of libsndfile in the future.

Change-Id: I25fa2b6d0c21e325aeaf05bda62cf7aab0c5deb4
ndroid.mk
est-resample.cpp
9a1c785c019bdb25fefa7d1c0e50862ddc0e4e21 18-Dec-2013 Glenn Kasten <gkasten@google.com> Merge "Fix several test-resample BufferProvider bugs"
e00eefe64e3bad166c672db96c9c35992766e819 17-Dec-2013 Glenn Kasten <gkasten@google.com> Fix several test-resample BufferProvider bugs

Previously getNextBuffer always returned the same data address over
and over. Now it correctly returns the right portion of the input buffer.

Previously getNextBuffer always returned the total number of frames in
the input, which might be larger than the size requested by the caller,
and/or larger than the number of remaining input frames. It also always
returned successfully, even when there should be no frames available.
This violates the contract for getNextBuffer. Now getNextBuffer will
return the maximum of the number of frames requested, and the number of
remaining frames available. If that maximum is zero, getNextBuffer will
return an error instead.

Previously releaseBuffer would silently allow releasing more frames than
were actually gotten, which violates the contract for releaseBuffer.
Now releaseBuffer checks for this and logs a message if it happens.

Add 'v' (verbose) option to log buffer provider calls.

Bug: 12194314
Change-Id: I9b915e954b3612a07ef271da8652486b8875e0fd
est-resample.cpp
c95616357a911e5c1c55873492b05ebfa3cf1894 04-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: check for condition before waiting

AsyncCallbackThread must check for any condition that
has already been satisfied before waiting.

Bug: 11824817
Change-Id: Ic8c2090d521ecd6a30b76ee75635258d35eb1eff
hreads.cpp
688ca6330a5e7d072f67a1791e464fa7dec08b72 17-Dec-2013 Glenn Kasten <gkasten@google.com> am 5c474238: am 5893736d: am a67c7653: Merge "Increase kFastTrackMultiplier from 1 to 2"

* commit '5c474238bc579224ec8f7267d05651b0aa934100':
Increase kFastTrackMultiplier from 1 to 2
a67c76538fff102cd44b2f38dd073df5f2a33605 17-Dec-2013 Glenn Kasten <gkasten@google.com> Merge "Increase kFastTrackMultiplier from 1 to 2"
24a325d6f8c4bbf9330e6ce0c769d46e04266ffc 04-Dec-2013 Haynes Mathew George <hgeorge@codeaurora.org> audioflinger: check for condition before waiting

AsyncCallbackThread must check for any condition that
was already been satisfied before waiting.

Bug: 11824817
Change-Id: Ic8c2090d521ecd6a30b76ee75635258d35eb1eff
hreads.cpp
70aca464f7e39a3b208341f442b6fc2316e17147 05-Dec-2013 Glenn Kasten <gkasten@google.com> Merge "Add RecordThread media.log and deferred deallocation"
0312b69e65e4c8bf6a0c0757d9100dee3651c16e 05-Dec-2013 Glenn Kasten <gkasten@google.com> Merge "Change mActiveTrack to mActiveTracks vector"
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
b5fed68bcdd6f44424c9e4d12bfe9a3ff51bd62e 03-Dec-2013 Glenn Kasten <gkasten@google.com> Increase kFastTrackMultiplier from 1 to 2

Change-Id: I158f147295eebcea96e4047d7618069bc48bdd7d
hreads.cpp
866d90595a177f6027e97161781948baebf2aa68 02-Dec-2013 Glenn Kasten <gkasten@google.com> Merge "Code simplification and movement to prepare for mActiveTracks"
480acec40aa2d96119530c7d451282af8cf07327 23-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Fix bug in creation of EffectHandle when out of memory"
639512ce33fb19c876b1be68555d83ccda6e7ad7 23-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Consistent error checking for sp<IMemory> and pointer()"
04733dbdede313fc5e291070014c1a0641fe6166 22-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: fix offload write buffer offset

Fix current audio HAL write buffer offset calculation
which assumes that the frame size is a multiple of 2.

Change-Id: I0195ed5cfef225a6f114e7dd405a02680bb7254e
hreads.cpp
2b806406ac1ec680b6fe3aaa84c54bdc4e43ad8d 21-Nov-2013 Glenn Kasten <gkasten@google.com> Change mActiveTrack to mActiveTracks vector

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

Change-Id: Ia6b06b25d8c4709f087110ae29c589999407a2a2
hreads.cpp
hreads.h
f10ffec18f930d92e1abe9200d60e746831841a7 21-Nov-2013 Glenn Kasten <gkasten@google.com> Code simplification and movement to prepare for mActiveTracks

Share code to acquire wake lock at entry to loop

Change-Id: I01fb645de9417055c0adfc6a4c4011bf22ea4f94
hreads.cpp
e75da4004b2c814987aa2adf8a76190f92d99c65 20-Nov-2013 Glenn Kasten <gkasten@google.com> Fix bug in creation of EffectHandle when out of memory

If there is insufficient client memory to create the EffectHandle,
it was returning a handle which would be useless. Now it correctly
reports the out-of-memory error back to client.

Change-Id: I894e65d5d17df39383032c1527be6ccd35f578bb
ffects.cpp
ffects.h
hreads.cpp
663c2247b71086e30bfd3192979d1dd7f15c539e 24-Sep-2013 Glenn Kasten <gkasten@google.com> Consistent error checking for sp<IMemory> and pointer()

There have been concerns that an sp<IMemory> could be non-0, but the
associated pointer() still be NULL. There are rumors this may happen
when a non-0 sp<IMemory> is passed in by client but the shared memory cannot
be re-mapped into mediaserver.

There's also evidence in the early (2009/03/03) pre-git code of checking
pointer() for NULL, after a local allocate() returned a non-0 sp<IMemory>.
It's not clear if this is "cargo cult" paranoia, or if there was a
genuine reason for the check.

In any case, we now consistently check pointer() for sp<IMemory>
input parameters in createTrack() and queueTimedBuffer().

We also check after successful allocate(). If allocate() returns a
non-0 sp<> but NULL pointer(), then treat it as if the allocate() had
returned 0.

Change-Id: I3013ac5766b493d443ecef71711ec861076a623e
udioFlinger.cpp
racks.cpp
30ff92cba19c5acd747631365db1e1084e45ab34 20-Nov-2013 Glenn Kasten <gkasten@google.com> Code simplification for timed allocate

Change-Id: I5acccd7418c5b4a4dc0112147c750fef9f74bf33
racks.cpp
731076cc7857fe322eed018569a2a67f6eac0e54 15-Nov-2013 Eric Laurent <elaurent@google.com> am 06d62548: am d7e59228: audioflinger: do not use raw pointer for tracks

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

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

Pointers to tracks should always be weak or strong pointers.

Bug: 11708529.
Change-Id: Ic48632532d186c9be8261f73cefdf824b9fbbd2b
hreads.cpp
hreads.h
561879df42b65f44b83c391d78d351e9ad4cb162 14-Nov-2013 Eric Laurent <elaurent@google.com> am 307aa870: am 4215e616: Merge "audioflinger: fix offload track transition" into klp-dev

* commit '307aa87038017dff8ae1dd0262c0ff87723894d7':
audioflinger: fix offload track transition
b04b25321dd323142eec7c5136c81dea3629cf14 14-Nov-2013 Eric Laurent <elaurent@google.com> am b50fa77b: am 9f357f31: Merge "audioflinger: fix offload resume after drain" into klp-dev

* commit 'b50fa77b2cc7dadae1b8ebb591d42976879ac43c':
audioflinger: fix offload resume after drain
9da3d9573a18ffe08365557c706cf52f09118d1c 13-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: fix offload track transition

Make sure that when transitioning from one active
offloaded track to the next we flush DSP content
if both tracks are not on the same audio session.
This happens when switching between two applications
playing the same type of content (e.g MP3, stereo, 44.1).
In this case, we reuse the same output thread because the track
formats are compatible.

Bug: 11247103.
Change-Id: I2b9031591149adeb70766da5e0d21ff2933a37e8
hreads.cpp
1b9f9b134e732a48198e51f16424f330cbf03143 13-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: fix offload resume after drain

When pausing and resuming during the drain,
the drain sequence number shuold not be modified
otherwise the drain callback will be ignored.
This causes failure to notify end of stream to audio
player and transition to next song.

Bug: 11247103.
Change-Id: I2a35c5cc3fd6aa667cdd257f9e9cc8715cef5159
hreads.cpp
579dd27d96497022e534e859c6ebbec675ee07aa 08-Nov-2013 Glenn Kasten <gkasten@google.com> Fix build

Change-Id: I1ecccada22047d9c828152a53ad68b5599ff8827
hreads.cpp
8594843c15b4722ced39436fe9e64f3e57e7ace4 19-Aug-2013 Glenn Kasten <gkasten@google.com> Pull HAL reads out of RecordThread resample

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

This change will permit some future planned features.

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

Change-Id: I59f5016a2df91078d697c37a7dec2d9d9f44542e
udioFlinger.cpp
hreads.cpp
hreads.h
d8a1de6204829b0379bbd13042f1450bdb203f2b 08-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Channel counts are uint32_t"
f551e9961a6f66d63bb57f288c4be01b00725289 20-Aug-2013 Glenn Kasten <gkasten@google.com> Channel counts are uint32_t

Change-Id: I5676b6a291b72d7db6326f7eaf6d17588de51b05
udioMixer.cpp
hreads.cpp
09faf14b434bec0d184fecec947e3d750bcc64ff 07-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Rename standby methods"
d6fadf0479b489b09b764070974d8a59855ede64 30-Oct-2013 Glenn Kasten <gkasten@google.com> Simplify track 'needs' bits

Use more standard coding convention for bit masks,
and add a FIXME about max channel count.

Change-Id: I856784016703417ee480b92ae73757c472f9cf95
udioMixer.cpp
udioMixer.h
8f32537d028231abed103c68705bc5d07cedf919 30-Oct-2013 Glenn Kasten <gkasten@google.com> Remove redundant this->

Change-Id: Id783201e802b6ce294fa92f4bbe492adfb446686
udioMixer.cpp
e25b778b11183fda65418ab2142873a030521870 30-Oct-2013 Glenn Kasten <gkasten@google.com> Remove dead code

Change-Id: Ide9196aa348cd3846b5c71d51fe6538f38ea8dc2
udioMixer.cpp
5c6ba3ad8eed1d59e5e2ffe6b70ced2d582a9def 06-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Fix race condition in initializing downmix"
49c34acbef91800930b0fe561e0787145a10cfcc 30-Oct-2013 Glenn Kasten <gkasten@google.com> Fix race condition in initializing downmix

The code that initializes downmix GUID searches for an effect of
the right type. If two or more AudioMixers are created, there is a
possibility that the GUID will temporarily have the wrong value.

Now the initialization is only done once, regardless of how many
AudioMixers there are.

Other minor changes:
- use naming convention of leading 's' for static member variables
- log message for no downmix effect is now a warning instead of an error,
since it is not an error until there is actual content to downmix
without a downmix effect

Change-Id: I33ab0e51cf9d24ecaf8ae868883736b0772178c4
udioMixer.cpp
udioMixer.h
0699ed950b307663e0f7e01aecdfb505e62df7d6 06-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Move local declarations to point of first use"
44f412a81dcca8f7149d483eeeee9057ad0101cf 06-Nov-2013 Eric Laurent <elaurent@google.com> am 44dc9155: am 48b6cd98: Merge "audioflinger: fix direct output underrun" into klp-dev

* commit '44dc91554521eaab478674a7f812cb8a4fa4f809':
audioflinger: fix direct output underrun
7bb88779cdc1a1fe1445d6d1691fb7daac932e74 06-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Rename TrackPaused to trackPaused"
1b3ec0f33cbdcac5e148c23abc5bc4f68d780ed4 06-Nov-2013 Glenn Kasten <gkasten@google.com> Merge "Use const more places"
a23f17ac334ff20a11ee63dd177cb1080e44c483 06-Nov-2013 Eric Laurent <elaurent@google.com> audioflinger: fix direct output underrun

Underruns on tracks handled by a direct or offloaded
threads were not properly reported to the applications
causing a failure to automatically recover.

Bug: 11535001.
Change-Id: I7a8696b4d646f78b16710addfe7c108d0dd0038d
hreads.cpp
93e471f620454f7de73d190521568b1e25879767 19-Aug-2013 Glenn Kasten <gkasten@google.com> Rename standby methods

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

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

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

Change-Id: I9196ee12701dd2dccdfaed922af2d7b8e8774676
hreads.cpp
hreads.h
b91aa63779ad1ce1846fbc604f9ec935e0c67852 19-Aug-2013 Glenn Kasten <gkasten@google.com> Move local declarations to point of first use

Change-Id: I8a078386e371caab5174fc07b47f48fb9f21609a
hreads.cpp
e6f35b13567d920af19f0b8dc35f9120b7cf1dc9 19-Aug-2013 Glenn Kasten <gkasten@google.com> Rename TrackPaused to trackPaused

Change-Id: I3b38e0c9a6bbb6e18cb5b1f72670139a3071cb8f
hreads.cpp
b2737d0b33c17e408d96d6f9eeaa3381479c94c7 19-Aug-2013 Glenn Kasten <gkasten@google.com> Use const more places

Change-Id: Ibc068d319d6fff26f2d11248e17481d8f7f027e0
udioFlinger.h
hreads.cpp
1c7258b3c34b5656de92d845f6366a0f3ac1e0c6 31-Oct-2013 Eric Laurent <elaurent@google.com> am 4cf799fb: am 5c7ffaed: Merge "AudioFlinger: fix duplicating thread standby." into klp-dev

* commit '4cf799fbbb74de102d34ccb014ba7fbd9bfa5e14':
AudioFlinger: fix duplicating thread standby.
5c7ffaed6f04b844c2e4e2024bfb0203ac2233dd 31-Oct-2013 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix duplicating thread standby." into klp-dev
2c3740f01acca69c3e0bcc5e01bb0edc51b6777f 31-Oct-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix duplicating thread standby.

Commit fd47797 fixing issue 11247103 introduced a regression
where the duplicating thread does not exit standby state as
expected. This in turn prevents the tracks sending audio to
other threads to complete their activity cycle normally.

The fix conists in clearing mStandby state also in the specialized
threadLoop_write() method of DuplicatingThread subclass.

Bug: 11451415.
Change-Id: Ie8a92c819a56a2834ea25fa70a8b7b2125721775
hreads.cpp
1fc6cb5be26734938b3999e6bf4ce0e625e7d284 30-Oct-2013 Eric Laurent <elaurent@google.com> am ce275b7d: am 1c594b63: Merge "audioflinger: enable effects after registration if needed" into klp-dev

* commit 'ce275b7dd20e3d4781a46126c753e6eb998e6c0f':
audioflinger: enable effects after registration if needed
1c594b637df26499ce1dae2db34f2b3290efd838 30-Oct-2013 Eric Laurent <elaurent@google.com> Merge "audioflinger: enable effects after registration if needed" into klp-dev
d21952fe5bc94f7bb6ee729f806c0e641fdb1a0d 29-Oct-2013 Eric Laurent <elaurent@google.com> am 7f8f7585: am fd477974: AudioFlinger: more fixes for offload audio lost

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

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

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

Bug: 11247103.
Change-Id: I397d011c5afcdd779def3fe25aaae7669a472cfc
hreads.cpp
hreads.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
udioFlinger.cpp
udioFlinger.h
laybackTracks.h
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
laybackTracks.h
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
a153b68f2260a8ed7fbb236fa659b13264ac5ac0 19-Oct-2013 Glenn Kasten <gkasten@google.com> am 77177fa2: am 95c03858: Merge "Allow releaseBuffer after flush" into klp-dev

* commit '77177fa20773d02b4f9c4147ecb98107f019fa7d':
Allow releaseBuffer after flush
95c03858e2ab4fb693a2bfe47b3caa806e43c044 19-Oct-2013 Glenn Kasten <gkasten@google.com> Merge "Allow releaseBuffer after flush" into klp-dev
2e422c472c91aa7912befd0fc038d1e11f354bc1 18-Oct-2013 Glenn Kasten <gkasten@google.com> Allow releaseBuffer after flush

After AudioTrack start checks for pending flush,
allow releaseBuffer on any previously obtained buffer.
For example, this can happen if the resampler has obtained
a buffer but not released the whole buffer yet.
Note that the resampler will be reading obsolete data.

Bug: 11285590
Change-Id: I0614fbb62e43604aac3089cce4b7797c87a306b5
racks.cpp
6a7327f110b86613e6e8c7de105c49803acacc1d 18-Oct-2013 Eric Laurent <elaurent@google.com> am 6edd8ca5: am 6a51d7ed: audioflinger: fix track terminated before playing

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

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

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

Bug: 11247103.
Change-Id: I0a4b47b099204c7c326d45d700234ab8f72d8eae
hreads.cpp
hreads.h
9138d32050411c04cc45c25094352cf8b6e01df9 18-Oct-2013 Glenn Kasten <gkasten@google.com> am e45796de: am dedc7b0f: Merge "Fix flush() followed by start()" into klp-dev

* commit 'e45796dee9c072cdb13a00b407e68be2cd55e2f2':
Fix flush() followed by start()
12022ff8d223ccf4dfae019c81e4a93a3f44985c 17-Oct-2013 Glenn Kasten <gkasten@google.com> Fix flush() followed by start()

Bug: 11259166
Change-Id: I72526cdfd4e3ff4b06e6a317e577f57cc285205d
racks.cpp
3278eed31fcf82045ac00dcd549dda5270c88971 15-Oct-2013 Narayan Kamath <narayan@google.com> am 8580679e: am 014e7fa2: Make Audio wakelock names less unique.

* commit '8580679e1780617d978d28a43e932314b86608ce':
Make Audio wakelock names less unique.
e6056ba0f2399fa3ebea9665e12a8237f99de250 15-Oct-2013 Yu Yezhong <yuyezhong@gmail.com> Frameworks: AudioFlinger: Fix effects memory leak

Patch by: csheng@marvell.com
Change-Id: I4e3032fb34643902f98e8fd7c8e894b6452324c9
Signed-off-by: Yu Yezhong <yuyezhong@gmail.com>
udioPolicyService.cpp
014e7fa2e90827d911c37bb0ce4d2e10e14d0bb3 14-Oct-2013 Narayan Kamath <narayan@google.com> Make Audio wakelock names less unique.

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

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

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

bug: 11200551

Change-Id: Ia1f71b569cb7502d617b77596abc245f461a6ec0
hreads.cpp
hreads.h
d72b7c0180ee83fc3754629ed68fc5887a125c4c 13-Oct-2013 Eric Laurent <elaurent@google.com> audioflinger: enable effects after registration if needed

This fixes a bug where effects were not properly reenabled after
being moved from one playback thread to another. The effect
is enabled but the audio policy manager sees it as disabled.

Bug: 11181933.
Change-Id: I19cac7acbaf61c546e667fd85ed7d4eda1c716d8
udioFlinger.cpp
racks.cpp
35295078ab59c8c5d143a54d5a55557c3ca62c51 07-Oct-2013 Glenn Kasten <gkasten@google.com> resolved conflicts for merge of 9a7d11f0 to master

Change-Id: Ie4d101185a93d37ec280f608813ad62a077a584e
fee4ce338d78eeb58af1f66831ead53322d3859e 07-Oct-2013 Glenn Kasten <gkasten@google.com> Merge "Cleanup openRecord error handling" into klp-dev
61f58c0c8d02970ea6d94ff816c54bf606f755b7 05-Oct-2013 Eric Laurent <elaurent@google.com> am c22a1a49: am ea0fadeb: audioflinger: offload: fix pause/flush/resume

* commit 'c22a1a495c26b8a36fa15233cc136cb6ce6d6bea':
audioflinger: offload: fix pause/flush/resume
ea0fadeb5d81ef3cb7f9db458c9033d628bdb86a 05-Oct-2013 Eric Laurent <elaurent@google.com> audioflinger: offload: fix pause/flush/resume

If a pause/flush/resume sequence is fast enough, resume is received while
we are still in PAUSING state in which case it is a NOP. If this happens,
flush is still forwarded to the audio HAL but is not preceeded by a pause
which can cause problems to the audio DSP.
It is necessary to preserve the flush as this sequence is typical to a seek.

The fix consists in forcing a pause/resume when a flush request must be
executed and the audio HAL has not been paused previously.

Bug: 11081559.
Change-Id: Ib84ed26d503a61c05933b923ec556b10cedfe140
hreads.cpp
1c7feca9cc3e408dfeb632e7060cf31e5015227e 04-Oct-2013 Eric Laurent <elaurent@google.com> am 6c48a011: am 026c5b07: Merge "audioflinger: fix wake lock acquisition check" into klp-dev

* commit '6c48a01188746202164f8e10d63ff3775dfcf727':
audioflinger: fix wake lock acquisition check
547789d25dc6bd6561553bcf6b384fb0d4fee834 04-Oct-2013 Eric Laurent <elaurent@google.com> audioflinger: fix wake lock acquisition check

Commit e14a5d6 introduced a bug in ThreadBase::acquireWakeLock() where
the wake lock acquisition return code is not initialized before
being checked causing the wake lock token to be sometines not set
and potential failure to release the wake lock later.

Bug: 10985160.
Change-Id: Iffd40e773ae3bcfec3c148a844d5dbebbf474eaf
hreads.cpp
5918e0cb64200f64632595f7aea6062c65d43353 04-Oct-2013 Marco Nelissen <marcone@google.com> am b5677882: am 8097068d: Merge "Better recording wake lock accounting" into klp-dev

* commit 'b5677882cf9a34bd3f2daf76d10951282ea9b083':
Better recording wake lock accounting
8097068de97c0cdab8150931f290edbd5b3721e5 03-Oct-2013 Marco Nelissen <marcone@google.com> Merge "Better recording wake lock accounting" into klp-dev
e14a5d6d2cc91dd2fc09ffdf7aa670b37da0795d 03-Oct-2013 Marco Nelissen <marcone@google.com> Better recording wake lock accounting

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

b/10985160

Change-Id: Iae6e6c030b7f1c6081d9c79725d6990f60dadaaa
hreads.cpp
hreads.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
98232ab7c20bfbdfe176d2c25bb810dbb5e7b4f1 30-Sep-2013 Jean-Michel Trivi <jmtrivi@google.com> am a2340b30: Merge "Don\'t call audio effect process on offloaded playback threads" into klp-dev

* commit 'a2340b3059b9d6e4286d0db7069df477c164df0c':
Don't call audio effect process on offloaded playback threads
a6c7d98033c161592a062c61eaa6b7fd635e3006 30-Sep-2013 Eric Laurent <elaurent@google.com> am 0adc67df: Merge "audioflinger: fix crash when starting offload thread" into klp-dev

* commit '0adc67dfc5cedb211c36f06849681a60a32f5805':
audioflinger: fix crash when starting offload thread
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
udioFlinger.h
ffects.cpp
laybackTracks.h
hreads.cpp
racks.cpp
a2340b3059b9d6e4286d0db7069df477c164df0c 27-Sep-2013 Jean-Michel Trivi <jmtrivi@google.com> Merge "Don't call audio effect process on offloaded playback threads" into klp-dev
4de95592980dba88a35b3dc8f3fd045588387a4f 27-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix crash when starting offload thread

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

Pass a wp to parent thread instead.

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

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

Bug: 8174034.
Change-Id: I4b093b022030cd4f5eb8b8e477333e91098a6549
hreads.cpp
hreads.h
fed6292af65a0b97b583ecbd3c232b3811a3f37b 26-Sep-2013 Jean-Michel Trivi <jmtrivi@google.com> Don't call audio effect process on offloaded playback threads

An audio effect process command is not meant to be called for
playback threads belonging to offloaded playback.

Bug 10933817

Change-Id: Idc7b6a0224791bbf8d61648474d3c288617c498f
ffects.cpp
62dbe93f7743061e97fc3299386a2f887ca748cf 25-Sep-2013 Eric Laurent <elaurent@google.com> am 4e141a4f: am 1802399c: Merge "fix deadlock in audioflinger::createEffect()" into klp-dev

* commit '4e141a4f1303767f70ea983925ec01b034fe667b':
fix deadlock in audioflinger::createEffect()
eb3c337a3d6c74ec857dfc8be7eeafe634614bcd 25-Sep-2013 Eric Laurent <elaurent@google.com> fix deadlock in audioflinger::createEffect()

commit 5baf2af5 introduced a regression by calling
getOutputForEffect() with AudioFLinger main mutex locked.
The locking order must always be AudioPolicyService mutex then
AudioFlinger then ThreadBase mutex.

Bug: 10916796.
Change-Id: Ide34a2d84dbb06dbb35abd0640d91b01b0ac4d40
udioFlinger.cpp
ffects.h
e93cf2ca27ae6f4a81d4ef548bbf10a34db6d98f 24-Sep-2013 Glenn Kasten <gkasten@google.com> Cleanup openRecord error handling

Bug: 10888816
Change-Id: I84897dd7d30b370640b54e928f230604b873cb68
udioFlinger.cpp
hreads.cpp
c0dab528e8c63abce2022a391dface95c3ef67e5 24-Sep-2013 Eric Laurent <elaurent@google.com> am a57e2ab5: am 664539d2: audioflinger: fix ro.audio.silent in offload again

* commit 'a57e2ab58a17d3da35593a6c85f65e19249e9ebc':
audioflinger: fix ro.audio.silent in offload again
79360ad49d6f84d9e99a08d225a642d65079d740 24-Sep-2013 Eric Laurent <elaurent@google.com> am 3f1d3b97: am 21e54568: fix incoming call audio start time.

* commit '3f1d3b97f723cf39fe6bde9efd0a3fc9e78028a5':
fix incoming call audio start time.
664539d25180ab8f77e0521533ea2821cf28985f 24-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix ro.audio.silent in offload again

Commit 1abbdb4 was not working 100% of the times because
it is possible that the offload thread loop never sleeps
after being created in which case the property is never read.

The loop now reads the property once when starting.

Bug: 10899309.
Change-Id: I2e2ca332f2d7086e59d65f6010378c4d9618ba9e
hreads.cpp
21e5456821e3c107d09b0629adbf23c9e06e7c0b 23-Sep-2013 Eric Laurent <elaurent@google.com> fix incoming call audio start time.

commit cec4abb fixing issue 6720482 had a flaw that
would insert commmands at the wrong position in the
audio policy service command thread queue causing other
commands to be delayed more than expected.

A change in track stop timing introduced by commit bfb1b83
made this issue visible when answering a call.

Bug: 10860012.
Change-Id: Iec769112f14e13d13b64628b808e43663e33771c
udioPolicyService.cpp
0230a2a8a413076a138db4c4e1dea018104fd5e2 20-Sep-2013 Eric Laurent <elaurent@google.com> am c6bed216: am a3b97ad2: Merge "audioflinger: implement getTimestamp() for offloaded tracks" into klp-dev

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

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

Bug: 9587132.
Change-Id: Ie9d5f4cca96306d08bc9a2dbd6edd8953096702d
hreads.cpp
hreads.h
racks.cpp
fbb2609f132f23a983d376dec9ae6bfebfcacc4c 20-Sep-2013 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix lost offload thread resume event" into klp-dev
ede6c3b8b1147bc425f7b923882f559a513fe23b 19-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix lost offload thread resume event

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

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

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

Bug: 10810347.

Change-Id: If9a3b22cc3b9e6eb384a56c48c40e6258d0896ad
hreads.cpp
hreads.h
racks.cpp
d7e076589dc5298d7a78cb683159723b7eb08d7f 19-Sep-2013 Eric Laurent <elaurent@google.com> am 87fb4f30: am d1b28d41: audioflniger: fix leaked audiosession references

* commit '87fb4f30077e7bcf78e65cf25fe95bd58238bad1':
audioflniger: fix leaked audiosession references
d1b28d41dbda203ffb420ba2e36cbe736b163ff8 19-Sep-2013 Eric Laurent <elaurent@google.com> audioflniger: fix leaked audiosession references

acquireAudioSessionId() should not create session references
if the caller is not listed in the known notification clients.
It happens when the MediaPlayer or AudioTrack is created by the
mediaserver on behalf of a client (e.g CameraService). In this case
releaseAudioSessionId() can be called from a different pid and
the session reference will not be removed.
Also we will not be able to remove the reference if the client
process dies.

Bug: 10606426.
Change-Id: Ibb5e27518daeb484a2e66302e4c6221cbaca5b70
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
ffects.cpp
ffects.h
hreads.cpp
racks.cpp
6d07d9bd2e0549ca2682ad9e94118feee1f733f6 14-Sep-2013 Eric Laurent <elaurent@google.com> am 029838a9: am 7f91e5e0: Merge "audioflinger: fix ro.audio.silent in offload mode" into klp-dev

* commit '029838a98c9377299ef3341e21e9378fd5562ab6':
audioflinger: fix ro.audio.silent in offload mode
d455cdfad40ca0558b8f4f800ec192027e272c14 14-Sep-2013 Eric Laurent <elaurent@google.com> am c91eb605: am 972a173d: audioflinger: longer offload thread standby delay

* commit 'c91eb6059a6af8b84c48e0ce727b01829f9cd789':
audioflinger: longer offload thread standby delay
7f91e5e09cf3bd8068894b2e54cbdaac70bf53a0 14-Sep-2013 Eric Laurent <elaurent@google.com> Merge "audioflinger: fix ro.audio.silent in offload mode" into klp-dev
1abbdb4429479975718421c4fef3f79ce7c820e3 14-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: fix ro.audio.silent in offload mode

Change-Id: I5a1a79000d53146689b0a198cc5419c36509703f
hreads.cpp
972a173d7d1de1a3b5a617aae3e2abb6e05ae02d 04-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: longer offload thread standby delay

- Increase offloaded output thread standby delay to 1 second
to allow transition between tracks with going to stanby
if reusing the same audio track (gapless)

- Make sure pause/flush/resume sequence is sent to the HAL
in the right order

- Fix format display in track dump

Bug: 8174034.
Change-Id: I43ef6f8fdbf7427e4eff6cc2d0665d7d1463ea8a
hreads.cpp
racks.cpp
f523897787b64cf2217d0ab4946b564420c675fe 12-Sep-2013 Glenn Kasten <gkasten@google.com> am 8a220740: am dc33c542: Merge "Fix AudioTrack shared memory leak" into klp-dev

* commit '8a220740cd77eb844123d3914190a94513797b40':
Fix AudioTrack shared memory leak
dc33c542351449ceee95cc50a9009f495e7c72ba 12-Sep-2013 Glenn Kasten <gkasten@google.com> Merge "Fix AudioTrack shared memory leak" into klp-dev
db358afc965d9bfb703953ac004275428a7cda64 12-Sep-2013 You Kim <you.kim72@gmail.com> AudioPolicyService: malloc/delete pair

Change-Id: I75cd44ac0caccda9148faaa052c9e7a0c06d46d1
Signed-off-by: You Kim <you.kim72@gmail.com>
udioPolicyService.cpp
d5577f26de1ae3a0dc6fbea9c60a07d585f894bf 12-Sep-2013 Eric Laurent <elaurent@google.com> am 4823964d: am efc4d489: Merge "audioflinger: add HOTWORD audio source." into klp-dev

* commit '4823964d198228289ff21530bf8b01bb2ef196bb':
audioflinger: add HOTWORD audio source.
efc4d4899e03fb8464017dd48539106cec2163de 12-Sep-2013 Eric Laurent <elaurent@google.com> Merge "audioflinger: add HOTWORD audio source." into klp-dev
0c72b24f91c68442eb374bd1b338c394105b8262 11-Sep-2013 Glenn Kasten <gkasten@google.com> Fix AudioTrack shared memory leak

Bug: 2801375
Change-Id: I50e15164fe310f69ea019dca5b49171a02bc6992
laybackTracks.h
racks.cpp
9a54bc27876acd5d8be5b1fc3dc46701fe76fbb3 09-Sep-2013 Eric Laurent <elaurent@google.com> audioflinger: add HOTWORD audio source.

HOTWORD is a special capture audio source that uses
the same audio tuning as VOICE_RECOGNITION but allows an
active capture to be preempted.

Bug: 10640877.

Change-Id: Iea09a11cbcdbacc8d434e5230e7559dcd1b44ac0
udioPolicyService.cpp
ecordTracks.h
erviceUtilities.cpp
erviceUtilities.h
hreads.cpp
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
ffects.cpp
ffects.h
racks.cpp
bfc4214079875f0dc8c349e8c475d1813c234e67 06-Sep-2013 Eric Laurent <elaurent@google.com> am 99b84e8b: am 3b4529e0: audioflinger: remove async write race conditions

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

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

Bug: 8174034.
Change-Id: I7af10491f39dc0e7d7414862a9d8e763daa2e2b7
hreads.cpp
hreads.h
344202e13a91c9d3d109fd8f4a67f5b23efa7800 04-Sep-2013 Glenn Kasten <gkasten@google.com> am 55817ab9: am fe346c70: Fix miscellanous AudioTrack::getTimestamp() bugs

* commit '55817ab9c1868f1e6a59155f55c768f01509cda5':
Fix miscellanous AudioTrack::getTimestamp() bugs
b9258d930d67fc314373f94ab4423974e5f87e1a 04-Sep-2013 Glenn Kasten <gkasten@google.com> am 97992cc7: am 732845c7: FastMixer computes presentation timestamps for fast tracks

* commit '97992cc71fd0bbd4aa22e5195ee7e5cde09ac254':
FastMixer computes presentation timestamps for fast tracks
1462a2b84a578b5541683c824e0f77ebf2aa82ae 04-Sep-2013 Glenn Kasten <gkasten@google.com> am a4a82c5f: am 6466c9e6: Add ExtendedAudioBufferProvider::framesReleased and onTimestamp

* commit 'a4a82c5f8f3eccfa10ce30a52cbb4b1c5c983282':
Add ExtendedAudioBufferProvider::framesReleased and onTimestamp
fe346c707f59d763ded93bc3d27b51f0c0408258 30-Aug-2013 Glenn Kasten <gkasten@google.com> Fix miscellanous AudioTrack::getTimestamp() bugs

Check that get_presentation_position is non-NULL before calling.

AudioTrack::getTimestamp not implemented for fast tracks.

Fix typo in Track::getTimestamp().

Fix bugs in AudioTrack::getTimestamp after stop:
- getTimestamp while stopped is not allowed.
- stop, start, getTimestamp now returns the correct value.

Change-Id: Ie8d9dc1f28d8927634e04175a68b147ffc2ea8eb
racks.cpp
a7fef85e7d419a4f5d6a3144f9ba70ceff2f122a 04-Sep-2013 Glenn Kasten <gkasten@google.com> am f81d5fc1: am 943ba3cc: Merge "Add NBAIO_Sink::getTimestamp()" into klp-dev

* commit 'f81d5fc1d67a5252d0da1a45274460c4dd33b87b':
Add NBAIO_Sink::getTimestamp()
732845c7e8d294bb1aaa4cd9687da62b51f1f6e6 23-Aug-2013 Glenn Kasten <gkasten@google.com> FastMixer computes presentation timestamps for fast tracks

and forwards them to each track's ExtendedAudioBufferProvider::onTimestamp().

Change-Id: I06fb9586bb7e20d5c0289abdc8cac6cd3fd2f6e8
astMixer.cpp
6466c9e6e6278c740aed77f695f679be9f5db478 23-Aug-2013 Glenn Kasten <gkasten@google.com> Add ExtendedAudioBufferProvider::framesReleased and onTimestamp

and implement them in SourceAudioBufferProvider using the associated NBAIO_Source,
and in Track using the associated AudioTrackServerProxy.

Change-Id: I60dc4adba63fc1dc452ff16caf347e4a7c8242c2
laybackTracks.h
racks.cpp
767094dd98b01baf21de2ad09c27b3c98776cf73 23-Aug-2013 Glenn Kasten <gkasten@google.com> Add NBAIO_Sink::getTimestamp()

with a real implementation in AudioStreamOutSink
for dummy implementation initially in MonoPipe.

Use in AudioFlinger::PlaybackThread::threadLoop_write()
to keep the input to the timestamp latch up-to-date.

Change-Id: I10ef277991b63bb43d55d6f3df75116ef32246cd
hreads.cpp
0fd582e3ce5243c3e5a429fee3330aafc69b69fa 31-Aug-2013 Eric Laurent <elaurent@google.com> am 5d8cbf41: am 6bf9ae20: audioflinger: offloaded tracks flush/pause order

* commit '5d8cbf41ee7e511d20a649e240d6aecbbac3fae7':
audioflinger: offloaded tracks flush/pause order
6bf9ae20b3bd2dbb8f2e89ee167a6785222301cf 31-Aug-2013 Eric Laurent <elaurent@google.com> audioflinger: offloaded tracks flush/pause order

Make sure that a flush received after a pause is forwarded
to the HAL after the pause.

Change-Id: Ib3221f70c59f8b3dbbac20b23104f6b779b75be0
hreads.cpp
f557872b594d15599bdb65efd91eb5adeb1d0840 30-Aug-2013 Glenn Kasten <gkasten@google.com> am 908d3c09: am 51ec03c2: Merge "Implement Track::getTimestamp()" into klp-dev

* commit '908d3c09ca7f2ccb280aa5dc8d876099ff9a9d0f':
Implement Track::getTimestamp()
30c296c153447f5c2bb5251928bf4d3c4e28e552 30-Aug-2013 Glenn Kasten <gkasten@google.com> am 3ae0a58a: am 9841f636: Merge "Add AudioFlinger::PlaybackThread::Track::getTimestamp()" into klp-dev

* commit '3ae0a58a83d092d96672295c8a62908478f28a9b':
Add AudioFlinger::PlaybackThread::Track::getTimestamp()
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()
bd096fd9d8e5fc0e62f98807f4818a06f70d0812 23-Aug-2013 Glenn Kasten <gkasten@google.com> Implement Track::getTimestamp()

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

Change-Id: I1ebfba968c773faaab95648c272fd3ebd74718d6
hreads.cpp
hreads.h
racks.cpp
573d80a8f463f648a515fc0975bf83951b272993 26-Aug-2013 Glenn Kasten <gkasten@google.com> Add AudioFlinger::PlaybackThread::Track::getTimestamp()

with a dummy implementation initially,
and use it in AudioFlinger::TrackHandle::getTimestamp()

Change-Id: I2da88fc52a135a7f0d9fd9538986e919dc8ccd3b
laybackTracks.h
racks.cpp
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
udioFlinger.h
racks.cpp
61bd7a0281ffecb99b27bff63334c559df7357e6 20-Aug-2013 Jeff Brown <jeffbrown@google.com> am 0541b3bb: am c8b226f4: Merge "Enforce permission for recording from remote submix." into klp-dev

* commit '0541b3bb40fa23e97e0a4599463b6afc0e271939':
Enforce permission for recording from remote submix.
893a5642871114fca3b2a00c6ff8e5699ce3e3ed 17-Aug-2013 Jeff Brown <jeffbrown@google.com> Enforce permission for recording from remote submix.

Bug: 10265163
Change-Id: I2395036bac6e10baeaf6ea4bc3093bd9dd98742d
udioFlinger.cpp
erviceUtilities.cpp
erviceUtilities.h
7165268ffa6c7b6b405b6afad82e2a346500e8ee 15-Aug-2013 Glenn Kasten <gkasten@google.com> Don't lock and then immediately unlock effect chains

Change-Id: Id9a4b1e9c49cecfd3a008a7814b5c14dad9a5831
hreads.cpp
b86432b1d62e7c9034223f0120b9bceb44215c41 15-Aug-2013 Glenn Kasten <gkasten@google.com> Fix races in reading activeTrack->mState without lock

Change-Id: I8cfbd9884fa5959a846ddb52cdc797266b896769
hreads.cpp
9e98235a9e9bb870e1c76911e3b4d00386a52c39 14-Aug-2013 Glenn Kasten <gkasten@google.com> Simplify flow by having all mActiveTrack.clear() continue

Change-Id: Icd160b0aa79a747bd19fabaa7feee813afb155e0
hreads.cpp
5edadd46c76c5ff1c3edabf2ea943c2278e82e1c 15-Aug-2013 Glenn Kasten <gkasten@google.com> Don't sleep with effect chains locked

Change-Id: I6eae037304d3dc8a8f3ef55c5b210fd4f8856e99
hreads.cpp
ad5bcc29b216412dbc4d936c270d30620c68f361 14-Aug-2013 Glenn Kasten <gkasten@google.com> Copy mActiveTrack for stability and easier access

Change-Id: If0d88610ec35128054a22f42b2d79f07c4b724eb
hreads.cpp
1ba19cd7fcdf18ab6efab2a1b831affab9a46157 14-Aug-2013 Glenn Kasten <gkasten@google.com> Simplify code by pulling up mActiveTrack == 0 test

Change-Id: I225bb032b2fde97d891191f3599d9850c2d27bb2
hreads.cpp
d9fc34fb0fcfcc739f868b116edf50c62af19d5e 14-Aug-2013 Glenn Kasten <gkasten@google.com> Remove dead 'if'

Change-Id: I23c082f0115ae598cad293be0ac66a130afb692a
hreads.cpp
4ef0b463a56c19bad9197aa9f90d792090461429 14-Aug-2013 Glenn Kasten <gkasten@google.com> Fix race in checking exitPending() in RecordThread::threadLoop()

Change-Id: I97a1c5ab17a6c334d275be794392dcf6c9a88d0e
hreads.cpp
2cfbf88b89854f30b295e8ae26a031edb8d712f8 14-Aug-2013 Glenn Kasten <gkasten@google.com> Simplify code that checks for record standby

Take advantage of the new processConfigEvents_l()
and it's post condition that mConfigEvents is empty.

Change-Id: Icd40fb175f3e374203c9c8d2e9df2c3929bed89b
hreads.cpp
26a4029c95620a2b98187cf003cd3c58eea03747 14-Aug-2013 Glenn Kasten <gkasten@google.com> checkForNewParameters_l returns a value which is currently ignored

Change-Id: I19b9cc9df094d67560f6e832d94fa284dca18687
hreads.cpp
d5418eb594435c958d6c37fa9938161a0112adbd 14-Aug-2013 Glenn Kasten <gkasten@google.com> Use Autolock where possible

Change-Id: Id0e1836831c45beda4e5cb11e983005ea699fc2a
hreads.cpp
f777331418a86cd9fd709af898ef24a69967aeb4 14-Aug-2013 Glenn Kasten <gkasten@google.com> Add ThreadBase::processConfigEvents_l()

Change-Id: I6bcdc212a984c52ab98b0b0744943b4ecc1e1542
hreads.cpp
hreads.h
c527a7c2b1bfd26e8f3086e1b653d56e521379d9 14-Aug-2013 Glenn Kasten <gkasten@google.com> Pull in scope of effectChains

Change-Id: Id5336f8663099088a0958fb8bd59fc5df9f92829
hreads.cpp
47c2070b2ce8aedb7300c0aad91caccf3c383841 14-Aug-2013 Glenn Kasten <gkasten@google.com> Add record thread locking comments and FIXMEs

Change-Id: Ia5bdc9b8b013c2e40af17c82833051290bf4df70
hreads.cpp
2d94426cd3302cb1215c92c5f1c4b90c24ceb72b 13-Aug-2013 Glenn Kasten <gkasten@google.com> Convert if/else-if in threadLoop to switch

Change-Id: I7428abb332ead6c2a1df5903f6c4e166be1f7abb
hreads.cpp
3468e8a4d79cc6a7bb0f03f8382426195bed44df 14-Aug-2013 Glenn Kasten <gkasten@google.com> Fix switch indentation to follow our audio style

Change-Id: I137763917962b276838715319b163c763cb54c71
hreads.cpp
34fca34606b448e6b71c2942f63cb13a0aebd620 13-Aug-2013 Glenn Kasten <gkasten@google.com> Explicit comparison to 0 for integral types

Change-Id: I2bfe864d1bda719581e297a38d96abfc0e3748b9
udioMixer.cpp
hreads.cpp
3255095af6677caeeebf81c8891ce8db745617ff 06-Aug-2013 Glenn Kasten <gkasten@google.com> Move local variable declarations to point of first use

Change-Id: Ia0fc4b099a3cf8bb5b67b287e7687e9dc9691e0e
udioFlinger.cpp
6e2ebe97f2ad0a21907f20f9ee644c4eacbb7a40 13-Aug-2013 Glenn Kasten <gkasten@google.com> Use curly braces in 'if' to make it easier to add logs

Change-Id: I58b33fefdd8bf703647414157a99a3223be3531c
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResampler.cpp
udioResamplerCubic.cpp
ffects.cpp
astMixer.cpp
hreads.cpp
racks.cpp
e198c360d5e75a9b2097844c495c10902e7e8500 13-Aug-2013 Glenn Kasten <gkasten@google.com> Whitespace

Change-Id: Id3ccc183a03421330d0498faaa62a45915cdc3d6
udioFlinger.cpp
hreads.cpp
hreads.h
2fc14730e4697a6f456b4631549c9981f6b0b115 05-Aug-2013 Glenn Kasten <gkasten@google.com> Comments

Change-Id: I56f82904cb3855bad6f33ad1ff4ddf66a61c5720
udioFlinger.cpp
hreads.cpp
c0029a8551d65929cbf51a55bd3bae3342a1f2fe 13-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Check input HAL channel mask instead of channel count"
030033342a6ea17003e6af38a56c7edc6d2ead01 07-Aug-2013 Glenn Kasten <gkasten@google.com> Clean up error handling in createTrack and openRecord

Outside callers now use initCheck() to determine whether a TrackBase
has been created successfully, instead of relying on internal knowledge.

Previously, callers needed to know that a TrackBase was only valid if it's
getCbk() != 0. For a Track (playback), they needed to know to also check
the track's name (track index). Now, outsiders can just call initCheck().

Other changes:
- Return a 0 reference if track creation fails
- Remove a dead line of code in AudioFlinger::openRecord

Change-Id: If374924a3f6fd27906f625aa83dd0a1e3f506e00
udioFlinger.cpp
laybackTracks.h
hreads.cpp
rackBase.h
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
e51a70ab6326715f614c737de1e8ea1941057b3b 12-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete TrackBase::getBuffer()"
e92db4bdb575d897d6bbd5086761fa9387393c83 12-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Pull up readyToRun into ThreadBase"
b0e6b967c290c905c4c696df4a8ac9e9d591928b 12-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Simplify the code that allocates mMixBuffer by removing mAllocMixBuffer"
309f7abb3c170ba764e67e9b6fed31fb442e9953 09-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Use 0 for sp<>, NULL for raw pointers"
3a6d5ded7187ae324532a60b03532c33d607e282 09-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Rename reqChannels to reqChannelMask"
f874f1375d758c8a7a84572a94371fbd4085f0df 08-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Pull up mBufferSize from RecordThread to ThreadBase"
2c03d0a2b741310c47d5f625cbdec4a4e4a0778e 08-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete field RecordTrack::mAudioRecordServerProxy"
ec3fb50c8ee25ac263a9c2cbe9242f877bef960c 17-Jul-2013 Glenn Kasten <gkasten@google.com> Check input HAL channel mask instead of channel count

The only supported channel masks are mono and stereo;
arbitrary channel masks are not yet allowed.

Change-Id: I9cebbe56480b53b98e59aa55245a1f03a30d2839
hreads.cpp
aac30336994235e42a92861eb83289131a6b94dd 06-Aug-2013 Glenn Kasten <gkasten@google.com> Remove obsolete TrackBase::getBuffer()

Change-Id: Ic39c7baa9538080bfec114bf18ff9b9986c93fed
rackBase.h
937098b9b564a779ff1c8c2d9e60769ee5c69810 26-Jun-2013 Glenn Kasten <gkasten@google.com> Use 0 for sp<>, NULL for raw pointers

Change-Id: Ia0595afdc41e1dec428d7a3db73558b54c417bf3
udioFlinger.cpp
hreads.cpp
fb872cc6f77f6d74011fab703b3edd7023c736cb 06-Aug-2013 Glenn Kasten <gkasten@google.com> memset audio_config to zero

Per guideline in hardware/libhardware/include/hardware/audio.h,
"You should memset() the entire structure to zero before use to
ensure forward compatibility."

Change-Id: I2bce70ef6ea4b070668bd9cbc54bfe20a60111aa
udioFlinger.cpp
f506e9495f2b2123b3bec7d42ec8ef13c6213ee8 06-Aug-2013 Glenn Kasten <gkasten@google.com> Rename reqChannels to reqChannelMask

This avoids potential ambiguity with channel count.

Change-Id: I0db82efc4c14dd8189d65a1db29809a085acf528
udioFlinger.cpp
6ae6b811666865815ebb1f670aacb1a0f2edaa73 06-Aug-2013 Glenn Kasten <gkasten@google.com> Remove obsolete field RecordTrack::mAudioRecordServerProxy

Change-Id: I054ba929e209797542940a0e734fc15f19f321c9
ecordTracks.h
racks.cpp
cf04c2cb8e031acc03c1c91cb1ccab15098c89b6 06-Aug-2013 Glenn Kasten <gkasten@google.com> Pull up readyToRun into ThreadBase

Change-Id: Ib150afd72c3b35d83599a61664e89302a8feb4b5
hreads.cpp
hreads.h
c1fac191069774c7bfcb062edbb821ea56e7dbc0 06-Aug-2013 Glenn Kasten <gkasten@google.com> Simplify the code that allocates mMixBuffer by removing mAllocMixBuffer

Change-Id: I5ac41210251789a034d760309c50fe018f2442ce
hreads.cpp
hreads.h
70949c47fbae3f836d15f040551d7631be3ed7c2 06-Aug-2013 Glenn Kasten <gkasten@google.com> Pull up mBufferSize from RecordThread to ThreadBase

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

Change-Id: I6f57b85ecece3cbd4e9e64b8c41c3352f7656912
hreads.cpp
hreads.h
90e58b1fefc8caf70b34301a92bc86179580b6fc 01-Aug-2013 Glenn Kasten <gkasten@google.com> RecordThread::createRecordTrack_l use flags for fast tracks

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

Change-Id: I65ddaeb1b85670fe9066076f638bfed0cda01c0d
hreads.cpp
hreads.h
ddb0ccf3fb6fe8da8c71a6deb30561b821f3c0a2 01-Aug-2013 Glenn Kasten <gkasten@google.com> RecordTrack::createRecordTrack_l flags are in/out

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

Change-Id: Ifbee57da3632ce130551065a426577fb97b1a68d
udioFlinger.cpp
hreads.cpp
hreads.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
udioFlinger.cpp
udioFlinger.h
f36dbfe3d517e9311be0a4d0fd6658380690e84c 02-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Report underruns for fast tracks also"
1a3739169becc850999c3c06db402541119a428c 01-Aug-2013 Glenn Kasten <gkasten@android.com> am 6d4d8790: am b687ff9f: Merge "Fix mismatched delete/new couple"

* commit '6d4d879037a495f9a4276a6996d1845594ce9090':
Fix mismatched delete/new couple
82aaf94a5b18939e4d790bbc752031f3070704a3 18-Jul-2013 Glenn Kasten <gkasten@google.com> Report underruns for fast tracks also

This fixes a regression that was introduced earlier
by commit 9f80dd223d83d9bb9077fb6baee056cee4eaf7e5
called "New control block for AudioTrack and AudioRecord".
That commit broke underrun reporting for fast tracks.

Also remove Track::mUnderrunCount, which counted the number of underrun
events, and was only used by dumpsys media.audio_flinger.

Now dumpsys media.audio_flinger reports the number of underrun frames,

Isolated underrun-related control block accesses via the proxy, so that
the server is not directly poking around in the control block.

The new proxy APIs are AudioTrackServerProxy::getUnderrunFrames() and
AudioTrackServerProxy::tallyUnderrunFrames(). getUnderrunFrames() returns
a rolling counter for streaming tracks, or zero for static buffer tracks
which never underrun, but do a kind of 'pause' at end of buffer.
tallyUnderrunFrames() increments the counter by a specified number of frames.

Change-Id: Ib31fd73eb17cbb23888ce3af8ff29f471f5bd5a2
laybackTracks.h
hreads.cpp
racks.cpp
b08ab81bab9e8cd2e3a7fff02725a387070fd078 31-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Add resampler comments and fix a typo"
34af02647b387a252fb02bab8e2cb9f7bd9c8abb 30-Jul-2013 Glenn Kasten <gkasten@google.com> Add resampler comments and fix a typo

Change-Id: Ie071673875f663de4212eed4a4dff89d51a5a915
udioFlinger.cpp
udioResampler.h
hreads.cpp
hreads.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
udioFlinger.cpp
udioFlinger.h
laybackTracks.h
racks.cpp
96f60d8f04432a1ed503b3e24d5736d28c63c9a2 12-Jul-2013 Glenn Kasten <gkasten@google.com> Rename control block flags to mFlags

Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89
hreads.cpp
racks.cpp
97252bb0e40a5a9b41f020163393cf6c5da10b7e 30-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "AudioRecord and HAL input stream must be 16-bit PCM only"
f20e1d8df84c5fbeeace0052d100982ae39bb7a4 12-Jul-2013 Glenn Kasten <gkasten@google.com> Rename control block server to mServer and add comments

Change-Id: Ieabd91acee92d0e84e66fbd358df5282b856306e
hreads.cpp
racks.cpp
a30e75897934da2ce7b1b03bcb4b58e139d3e81e 30-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Fix theoretical race using TrackBase::sampleRate()"
eb144bbbd0b18427562b0d7db5b38e11f9484739 09-Oct-2012 Andrei V. FOMITCHEV <andreix.fomitchev@intel.com> Fix mismatched delete/new couple

In RecordThread::readInputParameters(), mRsmpInBuffer is allocated
with new[] and should be freed with delete[] instead of delete.

This error has been found by valgrind.

Change-Id: I2f947abb658a21a7d1e61eebb99270cb37d2d147
Signed-off-by: Andrei V. FOMITCHEV <andreix.fomitchev@intel.com>
Signed-off-by: David Wagner <david.wagner@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
hreads.cpp
fa319e6d918b84f93fb5457af5d1cca6421ac517 30-Jul-2013 Glenn Kasten <gkasten@google.com> Remove CC_LIKELY and CC_UNLIKELY where not needed

Only keep them in performance-sensitive code

Change-Id: Ib257ddd7bc39ce9896997ffae008c524ac743d01
udioFlinger.cpp
hreads.cpp
racks.cpp
548efc94813c1dec6e8cf6c085ae41ccb04827f1 29-Nov-2012 Glenn Kasten <gkasten@google.com> Rename RecordThread::mInputBytes to the more generic mBufferSize

This prepares for using it in PlaybackThreads later

Change-Id: Id90a92aa6372e4b69914b0008cef07296ca5d6a3
hreads.cpp
hreads.h
9b58f63e45ef2fdfb839b9b9bb3411d81eb96128 16-Jul-2013 Glenn Kasten <gkasten@google.com> Move members from ThreadBase to PlaybackThread

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

Change-Id: I5fc0a8a89cc637976f22d49271a5a3e136dab4e1
hreads.cpp
hreads.h
7f249fa9bcb64da324d19f551943fac7686d221c 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Use standard name and type for channel mask"
175f8338e67aae6d0ca420b8f45a5f7cab4394d5 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Simplify getParameters()"
f6ed423af92a56ef54bba23eba883b1f21448b54 16-Jul-2013 Glenn Kasten <gkasten@google.com> Treat mChannelCount as uint32_t consistently

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

Change-Id: I2cc2fedf3e33144e5c8bbd9894763282d9217f63
hreads.cpp
hreads.h
rackBase.h
2eeca1f8e18106d118f7268cb9d8597539685c5c 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Move local variable declarations to point of first use"
b59c1ad726b8bdf441f373d0bdc612539769334a 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Declare methods in binder opcode order"
3dcd00dddec86a1c5133083ad7ba2265d49c048c 17-Jul-2013 Glenn Kasten <gkasten@google.com> Declare methods in binder opcode order

Change-Id: I5f624b7a51ffe1a17a67c056cf984f74e4c56eac
udioFlinger.h
racks.cpp
3af48e6b28983da8c11d3d7d7fdd2088d881b462 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete mBufferEnd"
b283374cbf79dc5a36f1eef0015d7baf8881792e 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Move delete AudioMixer closer to point of re-allocation"
35cc4f3127322ad3e3dd1e15e8ae29ff4b4a3af6 25-Jul-2013 Glenn Kasten <gkasten@google.com> Remove obsolete mBufferEnd

Change-Id: I507c6109d66000bb30933ca23b912a1316f55e5e
rackBase.h
racks.cpp
bd4c4fbb3b073e48963185d11a15da1fa18d2e54 25-Jul-2013 Glenn Kasten <gkasten@google.com> Remove obsolete TrackBase::step(), mStepCount, mStepServerFailed

Change-Id: I6347096f066b8b19451c6472db7b0671f0cf7702
rackBase.h
racks.cpp
afbbc6c5f6bc470d504dcf24ceb3ac21d57fb78d 29-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Simplify RecordTrack::stop()"
420ea49539d23ab305a7b33c0854a7a475493dd4 27-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "CBLK_OVERRUN, not CBLK_UNDERRUN, is for record threads"
65d30dd9ee498f7b3bfc033735458a6ff399c207 27-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete TrackBase::reset()"
422801c5e9b795105f28e639c4bed5ee3f4e56f3 26-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "HAL stream format for mixer output threads must be stereo 16-bit PCM"
a8356f663014e7d4c27869629af83d8bb3441e19 25-Jul-2013 Glenn Kasten <gkasten@google.com> Simplify RecordTrack::stop()

Change-Id: Ib959c1e9dc9544d12277ce11bea445118b2e0521
hreads.cpp
hreads.h
racks.cpp
fc38a2e0268b5e531db2975c3a81462a3593c861 25-Jul-2013 Glenn Kasten <gkasten@google.com> CBLK_OVERRUN, not CBLK_UNDERRUN, is for record threads

Change-Id: I8948f76ef4717a423c37cd6ea7db4381636af612
racks.cpp
0fea74cdbc09c1259e08215e2ea90e7988d62df8 25-Jul-2013 Glenn Kasten <gkasten@google.com> Remove obsolete TrackBase::reset()

Change-Id: I38100b7e28a12d7af8cb40ae3f4d9cb4a0ebe701
rackBase.h
racks.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
ffects.cpp
ffects.h
laybackTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
9e8fcbcd8efa51d70d1207ff57bfbfe31324287a 25-Jul-2013 Glenn Kasten <gkasten@google.com> Move delete AudioMixer closer to point of re-allocation

No need to delete AudioMixer before readOutputParameters

Change-Id: Icafa785c9021bbe8d985e4f9527f8fc8c5e62622
hreads.cpp
7fc97ba08e2850f3f16db704b78ce78e3dbe1ff0 17-Jul-2013 Glenn Kasten <gkasten@google.com> HAL stream format for mixer output threads must be stereo 16-bit PCM

Direct and tunnel output threads can support various HAL stream formats,
included encoded. But currently there are stereo 16-bit PCM assumptions
in several places for mixer and duplicating output threads:
- mMixBuffer and mixBuffer()
- AudioMixer including resampler
- FastMixer's mixBuffer
- effects
- NBAIO_Format
- anywhere FCC_2 is used
- possibly other places

Until those assumptions are removed, this CL enforces stereo 16-bit
PCM in mixer and duplicating threads at the place where the HAL format
is read. It was already being checked in checkForNewParameters_l(),
but not in readOutputParameters().

Change-Id: Ibe344cc922743da234299097aa1bb1f54795cc9b
astMixer.cpp
hreads.cpp
d8ea699dc8e7dac58bb32e9cdb31b0758da25817 16-Jul-2013 Glenn Kasten <gkasten@google.com> Simplify getParameters()

Change-Id: Iedfeca3cd477d023c350d6d4e6eed874ee467a32
hreads.cpp
34542acfa25c6413c87a94b6f7cc315a0c496277 26-Jun-2013 Glenn Kasten <gkasten@google.com> Move local variable declarations to point of first use

Change-Id: Ideb83dea2c3002651c34fa646753cba598e29e93
udioFlinger.cpp
hreads.cpp
fad226abd12435dbcd232f7de396f1a097b2bd5f 17-Jul-2013 Glenn Kasten <gkasten@google.com> Use standard name and type for channel mask

Former name 'channels' was ambiguous with respect to channel count.

Change-Id: I716f792d95a7e0c787d27514ad6e93dbcef8a415
hreads.cpp
291bb6d8947c5b0c062f0895d623c529259bfa39 17-Jul-2013 Glenn Kasten <gkasten@google.com> AudioRecord and HAL input stream must be 16-bit PCM only

Currently there are 16-bit PCM assumptions in several places for capture:
- resampler API
- mRsmpInBuffer and mRsmpOutBuffer
- RecordThread::threadLoop upmix, downmix, and resampling
- possibly other places

Until those assumptions are removed, this CL enforces 16-bit PCM in both
client and server at all places where a format is checked.

Change-Id: I08b0570bff626ad0d341804825a72c14e61b4233
udioFlinger.cpp
hreads.cpp
01061c1d57700b37fa879217763494cdf94d5c98 22-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Use AudioSystem::setLowRamDevice() to configure memory"
cb155c8f4bf556b0d37c3596c4dc265ab491152b 22-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Revert "Fix Audioflinger crash when TeeSink is enabled""
18cf609ca3f20a9da2c7e140088d7557e7479f49 22-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Fix compile warning"
1b8ae3d9f3605fab7d14c323f2118ba3c769a42a 19-Jul-2013 Glenn Kasten <gkasten@google.com> Fix compile warning

Change-Id: I80de4a013dc65eb7c532561438fd10e005354c03
udioPolicyService.cpp
4182c4e2a07e2441fcd5c22eaff0ddfe7f826f61 15-Jul-2013 Glenn Kasten <gkasten@google.com> Use AudioSystem::setLowRamDevice() to configure memory

Bug: 9798886
Change-Id: I9321e3f369f1ed9429ae222e3926ebdeb012b8b0
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
astMixer.h
hreads.cpp
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
udioFlinger.h
153b9fe667e6e78e0218ff0159353097428c7657 15-Jul-2013 Glenn Kasten <gkasten@google.com> Make AudioFlinger::instantiate() more resilient when called from separate module

Bug: 8834855
Change-Id: I4cd842cdfb09d2aaaaab9df9ac3bec6179709bd3
ndroid.mk
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioWatchdog.cpp
onfiguration.h
ffects.cpp
astMixer.cpp
astMixerState.cpp
tateQueue.cpp
tateQueueInstantiations.cpp
hreads.cpp
racks.cpp
c6ae3c8a261794fd4445e4e152d1ada074a3f92f 17-Jul-2013 Glenn Kasten <gkasten@google.com> Fix theoretical memory leak in mConfigEvents

Change-Id: I137f70676c8919661e716c33e0dd9c25c2b6285c
hreads.cpp
hreads.h
ee5e8d3e8dc61f8fb1fa725278d63802074c10c5 17-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Fix indentation"
3d1982595cb9cb0856841f1f57fbdb4581189e99 11-Jul-2013 Glenn Kasten <gkasten@google.com> Fix indentation

Change-Id: Ia28720a7d0fad8cf110c2448b967d5648d42e017
astMixer.cpp
fb1fdc9d6603aa228362e7349451f6455c9849c2 11-Jul-2013 Glenn Kasten <gkasten@google.com> Add comments

Change-Id: Ifbf3a46a4183c8abc0feee1c588953ab10303cc1
tateQueue.h
hreads.h
20ed5f444c149c49d0e599da09e5cec1e5cc6051 03-Jul-2013 Eric Laurent <elaurent@google.com> am ace2378c: am f59a4b39: fix scheduling policy service death detection

* commit 'ace2378c934b61fbd865b5ade9ff7d0df81dabe3':
fix scheduling policy service death detection
ace2378c934b61fbd865b5ade9ff7d0df81dabe3 03-Jul-2013 Eric Laurent <elaurent@google.com> am f59a4b39: fix scheduling policy service death detection

* commit 'f59a4b393f4844c5bbc8d6212364bdddea33d232':
fix scheduling policy service death detection
1ab85ec401801ef9a9184650d0f5a1639b45eeb9 31-May-2013 Glenn Kasten <gkasten@google.com> Include what is needed

Remove old includes.
Header files only include other header files that they directly need themselves.

Change-Id: Ic471386808d9f42ea19ccbd59cb50a5f83a89dd0
udioFlinger.cpp
udioPolicyService.cpp
hreads.cpp
f59a4b393f4844c5bbc8d6212364bdddea33d232 02-Jul-2013 Eric Laurent <elaurent@google.com> fix scheduling policy service death detection

Check status of transactions to scheduling policy service
and re-acquire a binder interface in case of DEAD_OBJECT.

Bug: 8875559.
Change-Id: I1e00bd44e2d4723b3ec95d5c31d9652ba08e238a
SchedulingPolicyService.cpp
chedulingPolicyService.cpp
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>
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
racks.cpp
9fdcb0a9497ca290bcf364b10868587b6bde3a34 27-Jun-2013 Glenn Kasten <gkasten@google.com> Fix theoretical race using TrackBase::sampleRate()

In two places we assumed that TrackBase::sampleRate() would return the
same value when it is called twice in the same function. This is not
guaranteed; sampleRate() reads from the control block so the return
value could change. To fix this, only call sampleRate() once and cache
the return value to get a consistent value.

This was only a theoretical race. In MixerThread::prepareTracks_l()
it would have no bad effect. In TimedTrack::getNextBuffer() it could
cause a real problem, but we don't currently support dynamic sample rate
ratios for timed tracks.

Change-Id: I8e5c33f0121fc058d1e70c2ab5e9135397d3e0b7
hreads.cpp
racks.cpp
30755ddfd36849a0be87fee5da849f161a45a8a6 21-Jun-2013 Glenn Kasten <gkasten@android.com> am d3ac2fc0: am f3e21c30: am 60f3f102: Merge "Prevent AudioCommands being freed before read"

* commit 'd3ac2fc0c5429003f69d161e42bba7e94434ec09':
Prevent AudioCommands being freed before read
d3ac2fc0c5429003f69d161e42bba7e94434ec09 21-Jun-2013 Glenn Kasten <gkasten@android.com> am f3e21c30: am 60f3f102: Merge "Prevent AudioCommands being freed before read"

* commit 'f3e21c301b8fef49eecf9c716373fcbfbaa47670':
Prevent AudioCommands being freed before read
f3e21c301b8fef49eecf9c716373fcbfbaa47670 21-Jun-2013 Glenn Kasten <gkasten@android.com> am 60f3f102: Merge "Prevent AudioCommands being freed before read"

* commit '60f3f102ba2973cc31e5c7ea00d95bbf19968e8b':
Prevent AudioCommands being freed before read
5fa8c4bf81275d5e1f5ef71bc66fc22e3152eeb0 18-Jan-2013 Christer Fletcher <christer.fletcher@sonymobile.com> Prevent AudioCommands being freed before read

When AudioCommandThread::threadLoop process AudioCommands it was
possible for it to delete a command where the posting thread still
hadn't read that status from it.

If a second command signaled the thread loop to continue after it
had inserted a new command while the thread loop was actually waiting
for the first command to report that it had read the status the
thread loop would continue and delete the first command.

Changed the wait condition when waiting for the calling thread to
read status to use command->mCond instead of mWaitWorkCV. This way
it's guaranteed that the signal to continue comes from the correct
thread.

Change-Id: Ia69b48cb4fdfaf8b4c83b56a197fb9f2058a92d1
udioPolicyService.cpp
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
udioFlinger.h
laybackTracks.h
ecordTracks.h
hreads.cpp
rackBase.h
racks.cpp
fe9a901a445633e70073b1b91fca3af34d8e8132 12-Jun-2013 Eric Laurent <elaurent@google.com> am bb35be24: am 7be48189: Merge "audioflinger: fix effects on direct output threads" into jb-mr2-dev

* commit 'bb35be24239f05f59715960a93cd491a4cd3b4d6':
audioflinger: fix effects on direct output threads
bb35be24239f05f59715960a93cd491a4cd3b4d6 12-Jun-2013 Eric Laurent <elaurent@google.com> am 7be48189: Merge "audioflinger: fix effects on direct output threads" into jb-mr2-dev

* commit '7be48189c0aefb82825a7689d9e1005175570779':
audioflinger: fix effects on direct output threads
d0107bcd44fe608b0c00a8843d19fb6356c4cb69 11-Jun-2013 Eric Laurent <elaurent@google.com> audioflinger: fix effects on direct output threads

PlaybackThread::addTrack_l() uses the assumption that
effects are attached to a track only if the track accumulation
buffer is different from the mixer thread output buffer.
This is not true for direct output threads where only one track is active
an only one buffer is needed.
This assumption is an optimization to avoid checking for effect chains with
the same session ID each time a track is processed. The optimization
is not key if only one track is attached to the thread which is the case for
direct outputs.

Current code fails to increment the active track count in the effect chain
on direct output threads when a track is started thus making the effect
framework clear the mix buffer and produce silence each time the mixer runs.

The fix consists in removing the optimization described above.

Bug: 9324989.

Change-Id: Id7a6337450ed90d326299c2ce9fc02f4b9e2fa6f
hreads.cpp
04b035e3ccbf2919e4447c66e6483c11f2889f01 07-Jun-2013 Eric Laurent <elaurent@google.com> am d3a5b48a: am 18b46679: Merge "AudioFlinger: do not cache audio device when 0." into jb-mr2-dev

* commit 'd3a5b48a1bc4f5d6ff4472f54f909abaadd5fa39':
AudioFlinger: do not cache audio device when 0.
d3a5b48a1bc4f5d6ff4472f54f909abaadd5fa39 07-Jun-2013 Eric Laurent <elaurent@google.com> am 18b46679: Merge "AudioFlinger: do not cache audio device when 0." into jb-mr2-dev

* commit '18b466790aa0a55ff4282ed8b5e550e58e0444b2':
AudioFlinger: do not cache audio device when 0.
7e1139c0377b6806942fb2a043737b3b9cf0ae91 07-Jun-2013 Eric Laurent <elaurent@google.com> AudioFlinger: do not cache audio device when 0.

AudioFlinger should not cache the audio device
passed to the audio HAL when it is AUDIO_DEVICE_NONE
but keep previous valid selection instead.

Bug: 9323399.
Change-Id: I6f9480e55a21be4115453e6a5eebc5cf2536c476
ffects.cpp
hreads.cpp
7c027248e1a4ccd5b22bc4deafb03e2d87ac8f38 26-Dec-2012 Glenn Kasten <gkasten@google.com> Consistent whitespace

Change-Id: I118cce68d3b777f9ec9b6bfb70367496422a40f2
udioFlinger.cpp
hreads.cpp
racks.cpp
61d404efeaaf3ea1b615c160b843ac9f274d0018 20-May-2013 Dianne Hackborn <hackbod@google.com> Update to supply correct name for new power manager app ops.

Change-Id: Ia686319509d98a4f467479ea494e8a54f2c1e238
hreads.cpp
e974c7df1c4a87ced27a773430690a20d208d40e 15-May-2013 Elliott Hughes <enh@google.com> am effc08ed: Merge "Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC"

* commit 'effc08ed1eb1d55ca13997ec96f72e40a0866394':
Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC
8df7184c17a6f7f7fa6612b6de30af655f5eb0a7 10-May-2013 Glenn Kasten <gkasten@google.com> Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC

(cherry-pick of da1a325bc0a1421f4233e62704da4fab8b0acf7b.)

Bug: 8895727
Change-Id: I29d5dcf8519600fdd2910345449c66a5c1284646
est-resample.cpp
4a434ce11e328ab97b02ca3cc44e920bc82c198b 10-May-2013 Glenn Kasten <gkasten@google.com> Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC

(cherry-pick of da1a325bc0a1421f4233e62704da4fab8b0acf7b.)

Bug: 8895727
Change-Id: I29d5dcf8519600fdd2910345449c66a5c1284646
est-resample.cpp
b8ef4856ba7c0cd74ce77e0bc855f8b391f46fa7 10-May-2013 Glenn Kasten <gkasten@google.com> Merge "Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC"
da1a325bc0a1421f4233e62704da4fab8b0acf7b 10-May-2013 Glenn Kasten <gkasten@google.com> Replace obsolete CLOCK_MONOTONIC_HR by CLOCK_MONOTONIC

Bug: 8895727
Change-Id: I0abf6da941965e9e29e232943184dbc72b95d03c
est-resample.cpp
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
ndroid.mk
udioFlinger.h
udioPolicyService.h
udioResampler.h
84e391686d7eced293913d1d7993721224ee0ba1 07-May-2013 Glenn Kasten <gkasten@google.com> Fix Audioflinger crash when TeeSink is enabled

Bug: 8834855
Change-Id: I54665f16d79901970348a8247d9a354da2990f42
udioFlinger.h
831a0055665c3d15ff9c99ad23e5ab2b7346f2ac 07-May-2013 Glenn Kasten <gkasten@google.com> Fix Audioflinger crash when TeeSink is enabled

Bug: 8834855
Change-Id: I54665f16d79901970348a8247d9a354da2990f42
udioFlinger.h
a6560120f96685d7929d535319198485d1d5ccdf 03-May-2013 Eric Laurent <elaurent@google.com> Merge "Remove timing jitter during startup of audio" into jb-mr2-dev
4170f515cd6148b952a07fcbe23364f5c76a2d9c 03-May-2013 Eric Laurent <elaurent@google.com> Merge "Remove timing jitter during startup of audio" into jb-mr2-dev
c114c6509b7f552e76e55a3502e926436ccfb2d8 25-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: fix duplicating track sampling rate

Add missing initialization of client proxy sampling rate
and volumes in OutputTrack constructor.

Bug: 8687522
Change-Id: I813e700315bb97083a63dd32279f1998ac775483
racks.cpp
8d2d4932b96632e9eb3af4a3d4000192ef603960 25-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: fix duplicating track sampling rate

Add missing initialization of client proxy sampling rate
and volumes in OutputTrack constructor.

Bug: 8687522
Change-Id: I813e700315bb97083a63dd32279f1998ac775483
racks.cpp
f8197a6a9d9363cb52bb8a2c15c0e5a52064355e 23-Apr-2013 Glenn Kasten <gkasten@google.com> Remove timing jitter during startup of audio

This fixes a regression introduced recently, that increased timing jitter
during the startup of the FastMixer and AudioTrack callback threads.

The regression was to make requestPriority() asynchronous as a way to
avoid an apparent priority inversion in system_server. This means that
the target thread could run briefly with the initial priority, before
the new priority takes effect.

This change removes the startup jitter for FastMixer, by making the
requestPriority() synchronous again for that case. It doesn't matter
that this restores the priority inversion involving normal mixer thread,
because it happens during startup of both threads.

The change also removes the startup jitter for the AudioTrack callback
thread, by having the target thread check whether the requestPriority()
has completed yet. If not, the target thread blocks with a timeout
until the priority boost finishes.

Finally, we now log an error message if the expected priority boost
doesn't happen.

Bug: 8698989
Change-Id: Id590e9a274b70ec1ba85b44a585ee37a22e41cbc
astMixer.cpp
SchedulingPolicyService.cpp
SchedulingPolicyService.h
chedulingPolicyService.cpp
chedulingPolicyService.h
hreads.cpp
a07f17ca46db04c9d5d9e7d6b2878db59ca2b9ea 23-Apr-2013 Glenn Kasten <gkasten@google.com> Remove timing jitter during startup of audio

This fixes a regression introduced recently, that increased timing jitter
during the startup of the FastMixer and AudioTrack callback threads.

The regression was to make requestPriority() asynchronous as a way to
avoid an apparent priority inversion in system_server. This means that
the target thread could run briefly with the initial priority, before
the new priority takes effect.

This change removes the startup jitter for FastMixer, by making the
requestPriority() synchronous again for that case. It doesn't matter
that this restores the priority inversion involving normal mixer thread,
because it happens during startup of both threads.

The change also removes the startup jitter for the AudioTrack callback
thread, by having the target thread check whether the requestPriority()
has completed yet. If not, the target thread blocks with a timeout
until the priority boost finishes.

Finally, we now log an error message if the expected priority boost
doesn't happen.

Bug: 8698989
Change-Id: Id590e9a274b70ec1ba85b44a585ee37a22e41cbc
astMixer.cpp
SchedulingPolicyService.cpp
SchedulingPolicyService.h
chedulingPolicyService.cpp
chedulingPolicyService.h
hreads.cpp
727cc2d1b378844474c775e9f42dab672d603ae9 16-Apr-2013 Glenn Kasten <gkasten@google.com> Use correct pid when running under test harness

This is a partial fix which addresses one of the root causes of this bug,
but only when running under test harness. It has no effect otherwise.

Bug: 8598539
Change-Id: I87444daef1d76b17544f331e651ba1c87893c381
udioFlinger.cpp
erviceUtilities.cpp
erviceUtilities.h
949a926cadbc961fbb649c91d76d7aee8ea4d7bd 16-Apr-2013 Glenn Kasten <gkasten@google.com> Use correct pid when running under test harness

This is a partial fix which addresses one of the root causes of this bug,
but only when running under test harness. It has no effect otherwise.

Bug: 8598539
Change-Id: I87444daef1d76b17544f331e651ba1c87893c381
udioFlinger.cpp
erviceUtilities.cpp
erviceUtilities.h
a75003e583b7b317951ceca13e44f3fd226012c7 15-Apr-2013 Glenn Kasten <gkasten@google.com> Merge "Workaround: requestPriority() is one-way" into jb-mr2-dev
5182337fcf848ca410ae61397752dfb0995067ef 15-Apr-2013 Glenn Kasten <gkasten@google.com> Merge "Workaround: requestPriority() is one-way" into jb-mr2-dev
8d480b86ec00396b37a22803fdfe5f7bef3d8e05 12-Apr-2013 Glenn Kasten <gkasten@google.com> Workaround: requestPriority() is one-way

Bug: 8565696
Change-Id: If5fcdf8593e1ca15bea45217bd683b43a2a106c7
SchedulingPolicyService.cpp
9a62391fa187a345a5d1301d4bc0b165c2ea4737 12-Apr-2013 Glenn Kasten <gkasten@google.com> Workaround: requestPriority() is one-way

Bug: 8565696
Change-Id: If5fcdf8593e1ca15bea45217bd683b43a2a106c7
SchedulingPolicyService.cpp
ecba7488c5cceaacef95836b1b476433451e7761 10-Apr-2013 Ying Wang <wangying@google.com> Add liblog

Bug: 8580410
Change-Id: If493d87d60d71be664ad75b140c62acadb75b0d0
ndroid.mk
da0dc0af0effe9fbfb3ce3187c8472fca2baf3c6 10-Apr-2013 Ying Wang <wangying@google.com> Add liblog

Bug: 8580410
Change-Id: If493d87d60d71be664ad75b140c62acadb75b0d0
ndroid.mk
7fd54ff906c69400727fc8e90118a8a0429d7ab2 04-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: multiple tracks on direct output

Fix problems when multiple tracks exist on a direct output
thread: when multiple tracks are active, continue to update all
track states but only take into account the last track started
for audio HAL volume and mixer state control.

Bug 8388941

Change-Id: I57e6757286f41651dda99b11a5449e431812431b
hreads.cpp
d595b7c858c481a07745674ce2d8a6690e980e74 04-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: multiple tracks on direct output

Fix problems when multiple tracks exist on a direct output
thread: when multiple tracks are active, continue to update all
track states but only take into account the last track started
for audio HAL volume and mixer state control.

Bug 8388941

Change-Id: I57e6757286f41651dda99b11a5449e431812431b
hreads.cpp
d0ebb538599cc25726b856e0f5deeb8215db8c92 03-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: add effect config status check

Check the result of the effect engine configuration command
and do not attempt to send parameters to, enable, or process
the effect if configuration fails.

Bug 8512027

Change-Id: I8c78a05d79fba36b1a387aa5cf2700612301ac91
ffects.cpp
2a9c5cd47159c41051fe7b8366d8205a7d1d5296 03-Apr-2013 Eric Laurent <elaurent@google.com> audioflinger: add effect config status check

Check the result of the effect engine configuration command
and do not attempt to send parameters to, enable, or process
the effect if configuration fails.

Bug 8512027

Change-Id: I8c78a05d79fba36b1a387aa5cf2700612301ac91
ffects.cpp
75d1ef97d9799061be9631b08b56592a7cea6013 11-Mar-2013 Glenn Kasten <gkasten@google.com> Increase size of statistics buffer

Bug: 8354576
Change-Id: I327e9dc203e09df8abc21e589ce9056540618abd
astMixer.h
0d35f7818dedd67844cc90218d5c131a8644f802 11-Mar-2013 Glenn Kasten <gkasten@google.com> Increase size of statistics buffer

Bug: 8354576
Change-Id: I327e9dc203e09df8abc21e589ce9056540618abd
astMixer.h
538f498bbd5a2da51c9037a2689afc97f8bded8f 26-Nov-2012 Glenn Kasten <gkasten@google.com> Add template class SingleStateQueue

Change-Id: If7e2bc9b2a216524ee9cbb68682e2634933b4973
ndroid.mk
5c4cc0d99d3b1cb35c5d7c237272ee53142745fb 26-Nov-2012 Glenn Kasten <gkasten@google.com> Add template class SingleStateQueue

Change-Id: If7e2bc9b2a216524ee9cbb68682e2634933b4973
ndroid.mk
a265845ecafe06c9668ce7ac67636657f4bedf86 26-Feb-2013 Glenn Kasten <gkasten@google.com> Miscellaneous cleanup

Abbreviation framesReady to fRdy for new systrace.
Put inline const on one line.
Use local copy of mState in state.
Improve logging.
Line length 100.

Change-Id: I8201c3ce0e53fd464fd33d02544e52c342d40b68
udioFlinger.cpp
astMixer.cpp
laybackTracks.h
hreads.cpp
rackBase.h
racks.cpp
c9b2e20f7c9a71e07ef398152709c76079decbcd 26-Feb-2013 Glenn Kasten <gkasten@google.com> Miscellaneous cleanup

Abbreviation framesReady to fRdy for new systrace.
Put inline const on one line.
Use local copy of mState in state.
Improve logging.
Line length 100.

Change-Id: I8201c3ce0e53fd464fd33d02544e52c342d40b68
udioFlinger.cpp
astMixer.cpp
laybackTracks.h
hreads.cpp
rackBase.h
racks.cpp
10774e144b3c99afad9a5070ccf50fdb12b5fb4e 02-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "media.log cleanup" into jb-mr2-dev
bf04b5860182d8f4130dcb5d6d88ee68a58c99cd 02-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "media.log cleanup" into jb-mr2-dev
d3c4b134a87b96227b90b9ec052d8a6e9880bbdf 27-Feb-2013 Glenn Kasten <gkasten@google.com> media.log cleanup

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

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

Bug: 6490974
Change-Id: I02d3e83646c738acaebb415bd0d6b548638b4ef5
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
ab7d72f0804fbb7e91ad9d2a16f826d97e20e5d0 27-Feb-2013 Glenn Kasten <gkasten@google.com> media.log cleanup

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

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

Bug: 6490974
Change-Id: I02d3e83646c738acaebb415bd0d6b548638b4ef5
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
5324bb2889c34cb85849ff1302215751a32c6a0d 01-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "Remove tee sink debugging at compile time" into jb-mr2-dev
487422017767078980bc7435f05ea2b58601b6f4 01-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "Remove tee sink debugging at compile time" into jb-mr2-dev
3c3c527a792249d07938c5c6cb9b465344a22383 27-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Logging to investigate a crash"

This reverts commit f0ff908da019a44115109f1b4d1b6864b35a8a29.
udioMixer.cpp
409e3749a5627f1b360feb1479fcd341067a90b8 27-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Logging to investigate a crash"

This reverts commit f0ff908da019a44115109f1b4d1b6864b35a8a29.
udioMixer.cpp
dd0bda0c47871d4964b5035a096c7c8c27fa7469 26-Feb-2013 Glenn Kasten <gkasten@google.com> Remove tee sink debugging at compile time

Bug: 8223560
Change-Id: Iddbfb06c45d43d9f20bb428215dd4094931e19a7
ndroid.mk
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
racks.cpp
46909e7eb074ce1b95b8a411eb71154f53f84f77 26-Feb-2013 Glenn Kasten <gkasten@google.com> Remove tee sink debugging at compile time

Bug: 8223560
Change-Id: Iddbfb06c45d43d9f20bb428215dd4094931e19a7
ndroid.mk
udioFlinger.cpp
udioFlinger.h
hreads.cpp
hreads.h
racks.cpp
dd4abb5177b8d94cd30a787d4ce336d5110c185c 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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
hreads.cpp
rackBase.h
racks.cpp
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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
hreads.cpp
rackBase.h
racks.cpp
2f8025eef6c681920579f75d298a262b12a80ac9 18-Feb-2013 Glenn Kasten <gkasten@google.com> A reference cannot be re-bound

Bug: 8213067
Bug: 6490974
Change-Id: If546215641fbc9a0fb1e8af8b85cc01f0a4b26ab
udioMixer.cpp
fc900c922e219771d0cd3c075720d90026e1ca4a 18-Feb-2013 Glenn Kasten <gkasten@google.com> A reference cannot be re-bound

Bug: 8213067
Bug: 6490974
Change-Id: If546215641fbc9a0fb1e8af8b85cc01f0a4b26ab
udioMixer.cpp
5f6f3764989601d3b3ee65beaf1447d2a6b5f284 16-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 32584a7d672864b20ab8b83a3cb23c1858e908b7

Change-Id: I9dc680578b955b1af462eeb7a49d61a0d45eb81b
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
7f5d335f7b4caecd0dfb8f1085f352f1d2da5d2e 16-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 32584a7d672864b20ab8b83a3cb23c1858e908b7

Change-Id: I9dc680578b955b1af462eeb7a49d61a0d45eb81b
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
dd9764290b3c1d801fea9505189cae29db919902 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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
ce70d400ff9fb614e334ab2b661df2933533ef57 15-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 639482c24c911b125398b31883ba6d55faebe28b

Change-Id: I11f2829072ab11e18b0663024f27bf31192f1d39
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
e186b51e0a9834b287d7a509e960eaf1b688db75 15-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 639482c24c911b125398b31883ba6d55faebe28b

Change-Id: I11f2829072ab11e18b0663024f27bf31192f1d39
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
5881f18029deb80eb83ea88046d0593441be79c7 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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
tateQueue.h
hreads.cpp
hreads.h
racks.cpp
7f2f8042cf335ab1323dec3edbe9143a06109f4e 14-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 0ddd56316262ac74a95e9edb595697c163136d6d

Change-Id: I180a928af6f5a38d15a5efe44cd1fe927b5d961c
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
51eb3965caa8ba135bcdd8ffb7a2024a042ecdc0 14-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 0ddd56316262ac74a95e9edb595697c163136d6d

Change-Id: I180a928af6f5a38d15a5efe44cd1fe927b5d961c
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
b900234f9e772bb7591a551f06ba17ee1969368f 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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
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
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
c93aff0a698265501f46393f3146b884aa357aee 12-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 3051df27261e9952c0e642dec548515250e85f6a

Change-Id: I8bf5c3e91b65bd20de26f480c367c2854b62373c
udioFlinger.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
ecd9389c8712aedeb2a79823ea0e4fb842684269 12-Feb-2013 Glenn Kasten <gkasten@google.com> Revert "Temporary additional logging to investigate bug"

This reverts commit 3051df27261e9952c0e642dec548515250e85f6a

Change-Id: I8bf5c3e91b65bd20de26f480c367c2854b62373c
udioFlinger.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
a1bf28b533907b0b234e52c72bc372b3fa49c5a3 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
udioFlinger.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
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
udioFlinger.h
astMixer.cpp
hreads.cpp
hreads.h
racks.cpp
e336f9113bdd35119866a3c3f8008ca01c576660 05-Feb-2013 Jean-Michel Trivi <jmtrivi@google.com> Add support for querying if a stream is active remotely

Bug 7485803

Change-Id: I0744374f130fd2dd0714102354cffed2fa915361
udioPolicyService.cpp
udioPolicyService.h
272ab546940054ad7991bef4b3a36f15175721cd 05-Feb-2013 Jean-Michel Trivi <jmtrivi@google.com> Add support for querying if a stream is active remotely

Bug 7485803

Change-Id: I0744374f130fd2dd0714102354cffed2fa915361
udioPolicyService.cpp
udioPolicyService.h
83fa606bd629ac32a2dab5af255188acfa30db4a 04-Feb-2013 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix RecordThread initial device"
59686720182dcaa1a1a4757964df38c16f1a5246 04-Feb-2013 Eric Laurent <elaurent@google.com> Merge "AudioFlinger: fix RecordThread initial device"
5fa419b962f668e6fa9adf7e14fddea97cdb736e 04-Feb-2013 Glenn Kasten <gkasten@google.com> Fix crash when destroying a DuplicatingThread

Bug: 8121343
Change-Id: I9b1fc56c753e465e8a08916022e52db6c3a36906
udioFlinger.cpp
685ef09bcaf5de6abf2064d552296f70eaec6761 04-Feb-2013 Glenn Kasten <gkasten@google.com> Fix crash when destroying a DuplicatingThread

Bug: 8121343
Change-Id: I9b1fc56c753e465e8a08916022e52db6c3a36906
udioFlinger.cpp
201fc9c9feb4765a12bc39e95d25f3aa1deb8ffe 02-Feb-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix RecordThread initial device

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

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

Change-Id: I81fb5f4718428b54251e65d74b86e198ce15193e
udioFlinger.cpp
hreads.cpp
hreads.h
d3922f72601d82c6fc067a98916fda0bd1291c5f 02-Feb-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix RecordThread initial device

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

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

Change-Id: I81fb5f4718428b54251e65d74b86e198ce15193e
udioFlinger.cpp
hreads.cpp
hreads.h
011aa652a9349750dd6bca1dcb1b82f19e07504e 19-Jan-2013 Glenn Kasten <gkasten@google.com> AudioFlinger uses media.log service for logging

Change-Id: Ia0f8204334f6b233f644d897762a18c95d936b4b
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
astMixerState.cpp
astMixerState.h
hreads.cpp
hreads.h
racks.cpp
9e58b552f51b00b3b674102876bd6c77ef3da806 19-Jan-2013 Glenn Kasten <gkasten@google.com> AudioFlinger uses media.log service for logging

Change-Id: Ia0f8204334f6b233f644d897762a18c95d936b4b
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
astMixerState.cpp
astMixerState.h
hreads.cpp
hreads.h
racks.cpp
3a948fceb6b59121cc2e5eeb458064150870ffde 18-Jan-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix build with debug log enabled

Change-Id: Id397155ec884c41cb84b35462ea09a97a04d3ed2
hreads.cpp
2592f6e68edbed386e004d5b045233f15e7b9ba1 18-Jan-2013 Eric Laurent <elaurent@google.com> AudioFlinger: fix build with debug log enabled

Change-Id: Id397155ec884c41cb84b35462ea09a97a04d3ed2
hreads.cpp
befdd0275dbb78e1a9fa2a33a3a1de731b1fe389 09-Jan-2013 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: I79f4d7052a4c0a9fde144063f44a9c8c9dd575d5
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/filter_coefficients.h
70dc7025fac462e502803108e55911e6b3301bfe 09-Jan-2013 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: I79f4d7052a4c0a9fde144063f44a9c8c9dd575d5
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/filter_coefficients.h
856ff4e4c3c43550f013e80277358fdf514342bf 22-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Start isolating control block accesses in a proxy"
d5681bc9a38fe4cd1d591e6ae62b9c68fb851041 22-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Start isolating control block accesses in a proxy"
5570227ac334479982a9dd8c1647c00f58f47c18 21-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Remove unnecessary parameter"
49d24d3fcd01aef0ec1fa4abd9c1b85473f64c0f 21-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Remove unnecessary parameter"
10f57df484daecc356ca1720c4ba799a8bf6761a 20-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Fix build warnings"
7cd2dd3ae3278a50396886cf0b5c9a1277601816 20-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Fix build warnings"
f93aa1fdae47ca2eddc7ca35fbde4266b114e8c5 20-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Add warning about following the design rules"
cb02ba7c2666b72db030b8bf4a3f2cddc3c23ead 20-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Add warning about following the design rules"
f37971f624164c3ed185d3f976404a6f60f49b9a 03-Feb-2012 Glenn Kasten <gkasten@google.com> Remove unnecessary parameter

Just get the parameter on server side

Change-Id: I433a63104dbb257e0d862be2ab61847cb36d1c15
udioFlinger.cpp
udioFlinger.h
8d6cc842e8d525405c68e57fdf3bc5da0b4d7e87 03-Feb-2012 Glenn Kasten <gkasten@google.com> Remove unnecessary parameter

Just get the parameter on server side

Change-Id: I433a63104dbb257e0d862be2ab61847cb36d1c15
udioFlinger.cpp
udioFlinger.h
92b1343f5fbc2fc43198a0a1252fe023cc9a5061 14-Dec-2012 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: I9e3cfa0c6b3467fe763ce55f759d179f02c5deea
udioResamplerSinc.cpp
udioResamplerSinc.h
hreads.cpp
c4974312e5a1e2ab94eca56045f991baf1508d73 14-Dec-2012 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: I9e3cfa0c6b3467fe763ce55f759d179f02c5deea
udioResamplerSinc.cpp
udioResamplerSinc.h
hreads.cpp
552f274d82fb4988fb972df69134e031d375abfe 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
udioFlinger.h
laybackTracks.h
ecordTracks.h
hreads.cpp
rackBase.h
racks.cpp
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
udioFlinger.h
laybackTracks.h
ecordTracks.h
hreads.cpp
rackBase.h
racks.cpp
30c01816ddee2268fcd3d965240cba9c00301e7d 04-Dec-2012 Glenn Kasten <gkasten@google.com> Prepare for track invalidation to be done by proxy

Don't rely on control block to determine whether track has been marked
invalid. Instead, use a local flag that can't be corrupted by client.

Change-Id: I783dafe828f93c1c3d2d0e5a08105ea536436efb
laybackTracks.h
hreads.cpp
racks.cpp
5736c35b841de56ce394b4879389f669b61425e6 04-Dec-2012 Glenn Kasten <gkasten@google.com> Prepare for track invalidation to be done by proxy

Don't rely on control block to determine whether track has been marked
invalid. Instead, use a local flag that can't be corrupted by client.

Change-Id: I783dafe828f93c1c3d2d0e5a08105ea536436efb
laybackTracks.h
hreads.cpp
racks.cpp
e1cf3c41bd27b5ab7d8e70ef8dd6fcd0f5453568 11-Dec-2012 Glenn Kasten <gkasten@google.com> am 76143093: am f0ff908d: Logging to investigate a crash

* commit '761430930a7335d714af0f7c1d497feb8f9f0a5a':
Logging to investigate a crash
ae162976dda428671af09a8fbc3f03173a7e6f3e 11-Dec-2012 Glenn Kasten <gkasten@google.com> am 76143093: am f0ff908d: Logging to investigate a crash

* commit '761430930a7335d714af0f7c1d497feb8f9f0a5a':
Logging to investigate a crash
f0ff908da019a44115109f1b4d1b6864b35a8a29 07-Dec-2012 Glenn Kasten <gkasten@google.com> Logging to investigate a crash

Bug: 6490974
Change-Id: Ib926a9258bde4ee05ed42eea662dff68e426a997
udioMixer.cpp
ef5abc369823f634c460c8f24d3cbf310542fe3b 07-Dec-2012 Glenn Kasten <gkasten@google.com> Logging to investigate a crash

Bug: 6490974
Change-Id: Ib926a9258bde4ee05ed42eea662dff68e426a997
udioMixer.cpp
e0da485dd76267e86cff7cbd334c74435d745225 04-Dec-2012 Alex Ray <aray@google.com> Merge "audioflinger: define ANDROID_SMP, remove conditional tracing"
811cddad95a75c71dfeca0965c92f710c81e192f 04-Dec-2012 Alex Ray <aray@google.com> Merge "audioflinger: define ANDROID_SMP, remove conditional tracing"
4b3a49e3a9ced6e63adab08acc5b720f8feddefa 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
udioFlinger.h
laybackTracks.h
hreads.cpp
racks.cpp
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
udioFlinger.h
laybackTracks.h
hreads.cpp
racks.cpp
71b6e60c52ce367bc0d64ffca60848d600511b65 01-Dec-2012 Alex Ray <aray@google.com> audioflinger: define ANDROID_SMP, remove conditional tracing

With ANDROID_SMP set, tracing functionality is completely inline, and
without the performance hits of external library calls, tracing does
not need to be conditionally compiled.

Change-Id: I4b29a9a52c403f0d2ea137c5b7bc05a518a7ca4b
ndroid.mk
astMixer.cpp
b3a8364eeea621ef63b983e4c1b0771f62069fe0 01-Dec-2012 Alex Ray <aray@google.com> audioflinger: define ANDROID_SMP, remove conditional tracing

With ANDROID_SMP set, tracing functionality is completely inline, and
without the performance hits of external library calls, tracing does
not need to be conditionally compiled.

Change-Id: I4b29a9a52c403f0d2ea137c5b7bc05a518a7ca4b
ndroid.mk
astMixer.cpp
af348741539ae4a84aa929a54ecf359dae96f3ee 30-Nov-2012 Alex Ray <aray@google.com> Remove conditional compilation of ATRACE functions

Tracing functions are meant to be dynamically controlled via sysprops.
Conditional compilation removes this functionality.

Change-Id: I26bc473d104d0b3c50a228dddfda3fa2428d157a
ndroid.mk
astMixer.cpp
hreads.cpp
371eb9756c32109ea572b91216b19bb623f6d3fd 30-Nov-2012 Alex Ray <aray@google.com> Remove conditional compilation of ATRACE functions

Tracing functions are meant to be dynamically controlled via sysprops.
Conditional compilation removes this functionality.

Change-Id: I26bc473d104d0b3c50a228dddfda3fa2428d157a
ndroid.mk
astMixer.cpp
hreads.cpp
05f9e4fe9a97e077b5ed37214464c0a67af80871 30-Nov-2012 Glenn Kasten <gkasten@google.com> Add warning about following the design rules

Change-Id: Ic4895ed5682bad10b03e97d8015e642ee1696533
astMixer.cpp
a3d2628a22f2b3d682495044897a40ea1399a662 30-Nov-2012 Glenn Kasten <gkasten@google.com> Add warning about following the design rules

Change-Id: Ic4895ed5682bad10b03e97d8015e642ee1696533
astMixer.cpp
e8cb004257565111cb261f3e9c786adba881859a 30-Nov-2012 Simon Wilson <simonwilson@google.com> Merge "Use ATRACE macros instead of Tracer statics"
45f7c446777171a728f9eb257f48145dde5d19e2 30-Nov-2012 Simon Wilson <simonwilson@google.com> Merge "Use ATRACE macros instead of Tracer statics"
7a90bc9265782788675af577c7b1c56e5d5be709 30-Nov-2012 Simon Wilson <simonwilson@google.com> Use ATRACE macros instead of Tracer statics

ATRACE_BEGIN and ATRACE_END have replaced the static
Tracer::traceBegin and Tracer::traceEnd functions, so
use them instead.

Fixes compilation errors when tracing is enabled.

Change-Id: I4d1147d2f76afcdf113e9986f0544cb848802b15
astMixer.cpp
hreads.cpp
2d590964aa58e137d17a43e095e6443dd0fe2e98 30-Nov-2012 Simon Wilson <simonwilson@google.com> Use ATRACE macros instead of Tracer statics

ATRACE_BEGIN and ATRACE_END have replaced the static
Tracer::traceBegin and Tracer::traceEnd functions, so
use them instead.

Fixes compilation errors when tracing is enabled.

Change-Id: I4d1147d2f76afcdf113e9986f0544cb848802b15
astMixer.cpp
hreads.cpp
f15a6227840b8d04a70fbd45fbd4de06b21fdc1f 29-Nov-2012 Glenn Kasten <gkasten@google.com> am 9428cdd7: am 5dea84c3: Fix log spam

* commit '9428cdd7b9d32647d35207b3579133ee6a1f7355':
Fix log spam
8fac1ce6bd56e3a4b0c26c1c177bf76d9ee19da6 29-Nov-2012 Glenn Kasten <gkasten@google.com> am 9428cdd7: am 5dea84c3: Fix log spam

* commit '9428cdd7b9d32647d35207b3579133ee6a1f7355':
Fix log spam
5dea84c39b5e790315b525009c635806e33c97e0 29-Nov-2012 Glenn Kasten <gkasten@google.com> Fix log spam

Change-Id: Ie6c982af906dcfd3cdea4b771dfab1f7e47745ca
udio-resampler/AudioResamplerCoefficients.cpp
65ac1b1761c57124382355c21edbbdaaab2ee025 29-Nov-2012 Glenn Kasten <gkasten@google.com> Fix log spam

Change-Id: Ie6c982af906dcfd3cdea4b771dfab1f7e47745ca
udio-resampler/AudioResamplerCoefficients.cpp
9bcb476a95a26e62f5706d1f00f4873cf44f9e04 19-Nov-2012 Glenn Kasten <gkasten@google.com> New VHQ resampler

Squashed commit of the following:

commit 12b6952da9f25e94d06dd7185bce255924e7e791
Author: Mathias Agopian <mathias@google.com>
Date: Mon Nov 19 15:27:26 2012 -0800

fix a typo in SINC resampler that prevented tracks to be mixed

we were always erasing the current mix instead of mixing into it.

Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2

commit 0019ce082df430278f14ab922e900ce33b64897d
Author: Dave Bort <dbort@google.com>
Date: Tue Nov 13 01:30:32 2007 -0800

Rename "TARGET" to "MODULE" in the build system.

Part one of the grand renaming.

API_CHANGE: Third parties may need to update their makefiles.
Any variables with "LOCAL" and "TARGET" in their names
should now use "MODULE" instead of "TARGET"; e.g., LOCAL_MODULE,
LOCAL_MODULE_TAGS.

PRESUBMIT=passed
OCL=39840

Change-Id: Ica9a7937d3d9552ab84db46ac6eea8a290e404fe
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit f01adc0cef0e39e75c76d9195ac26a94cac0a100
Author: Glenn Kasten <gkasten@google.com>
Date: Wed Nov 14 08:32:08 2012 -0800

Fix build warnings

Change-Id: Ic43bcca166a529a6431711b05a7fa21849b6a38b

commit 9bb031a565c753a03d9c9397edea318947d80528
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 10 04:44:30 2012 -0800

more optimizations...

calculate the offsets from the phase differently, this happens
to reduce the register pressure in the main loop, which in turns
allows the compiler to generate much better code (doesn't need
to spill a lot of stuff on the stack).

this gives another 15% performance increase

Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96

commit 5a951598f31217b8cd2babd0720c9608ee17291a
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 10 03:26:39 2012 -0800

refactor code to improve neon code

we want to make sure we don't transfer data from the
neon unit to the arm register file, as this can be quite
slow. instead we do all the calculation on the neon side
and write the result directly to main memory.

Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187

commit b381ee9e83bc9fd18986e79c7809841514ed590e
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 15:16:13 2012 -0800

NEON optimized SINC resampler

this currently gives us a 60% to 80% boost depending
on the quality level selected.

Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b

commit bea077354210242ea193a50b0dbab0fedab25df3
Author: Mathias Agopian <mathias@google.com>
Date: Mon Nov 5 01:51:37 2012 -0800

minor cleanups

Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f

commit 8f4ed7decbe161a5ff38200b218f5216d80aba46
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 18:49:14 2012 -0800

improve resample test

- handle stereo input
- input file can now be ommited, in this case
a linear chirp will be used automatically
- better usage information

Change-Id: I5d62a6c26a9054a1c1a517a065b4df5a2cdcda22

commit 5fcd634ea6cb4df27c495abe20f5f9b8ff55d128
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 02:03:49 2012 -0800

change how we store the FIR coefficients

The coefficient table is now transposed and shows
much better its polyphase nature: we now have a FIR
per line, each line corresponding to a phase.

This doesn't change at all the results produced by
the filter, but allows us to make slightly better
use of the data cache and improves performance a bit
(although not as much as I thought it would).

The main benefit is that it is the first step
before we can make much larger optimizations
(like using NEON).

Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43

commit d652231abf4c7e2ea1fc89caae730cec1f7259a1
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 3 23:37:53 2012 -0700

improve SINC resampler performance

The improvement is about 60% by just tweaking a few
things to help the compiler generate better code.
It turns out that inlining too much stuff manually was hurting us.

Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304

commit 9dc68ef5b94c700c4ee68790e8cbb334c90a538d
Author: Mathias Agopian <mathias@google.com>
Date: Thu Nov 1 21:03:46 2012 -0700

new coefficients for the vhq resampler

previous coefficients were provided by a 3rd party and didn't have a
way to re-generate them. we're now using the 'fir' utility.

the performance of the filter is virtually identical, except for
the down-sampling case which seems slightly better now:
It looks like both the previous and new coefficients are generating
some sort of clipping for full-scale signals in the down-sampling case
(although the new ones seem better), the reason for that is
unknown (see bug: 7453062)

Also updated the HQ coefficients for the down-samplers, previous ones
were a little bit too conservative -- the new ones push the cut-off
frequency up by about 1 KHz.

Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647

commit 38e0b8560a6fc1b7124e22e0e09a84a285182f8e
Author: Mathias Agopian <mathias@google.com>
Date: Tue Oct 30 13:51:44 2012 -0700

fix SINC resampler on non ARM architectures

make sure the C version of the code generates the same
output than the ARM assemply version.

Change-Id: Ide218785c35d02598b2d7278e646b1b178148698

commit a1878128b182696ba508569b4d211d0dfae92463
Author: Mathias Agopian <mathias@google.com>
Date: Tue Oct 30 12:49:07 2012 -0700

fix another issue with generating FIR coefficients

the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were
missing the 2*f scale factor. This explains why we were seeing
clipping and had to manually scale the filter down.

Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186

commit 1a0fb993430acc9f601e6c538305bc407c20ac5d
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 17:13:20 2012 -0700

fir a typo that caused up-sampling coefficiens to be wrong

up-sample coefficient were generated with a cut-off frequency of 24KHz
intead of ~20KHz, which caused more aliasing in the audible band.

also increased the attenuation to 1.3 dB on both up and down
sampling coefficient to avoid clipping.

Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e

commit 9520ad6862bd682ad075a9d9e3e94ada9f6e58b6
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 17:13:16 2012 -0700

test-resample: clip instead of overflowing

Change-Id: I550e5a59e51c11e1095ca338222b094f92b96878

commit ba36656300f250f7f1fdeb75149749344260e6cb
Author: Mathias Agopian <mathias@google.com>
Date: Sun Oct 21 01:01:38 2012 -0700

a test app for the resamplers

Change-Id: I66852d90d384f1d9e77b51ad1a1ebdbaf61d0607

commit 056a08b9bfd33cf27228c992adc8293a56b01be8
Author: Mathias Agopian <mathias@google.com>
Date: Fri Oct 26 14:11:01 2012 -0700

reenable the cubic resampler

cubic resampler was disabled because it hadn't been qualified,
however after I did some tests, it does improve significantly
the sound quality over the order-1 resampler, even if it is
still quite bad.

also HIGH_QUALITY resampler was partially disabled, it's now
fully enabled. It's a big improvement over the cubic resampler
in terms of aliasing noise (it's not as good in the pass-band).

Change-Id: I70e3658c255896588642697be9eb594ff4ec0f8b

commit 8c0241d3ff50ae85167f69b3bd369244894cfa44
Author: Mathias Agopian <mathias@google.com>
Date: Fri Oct 26 13:48:42 2012 -0700

improve SINC resampler coefficients

- we increase the interpolation precision from 4 to 7 bits
this doesn't increase CPU power required, it only increases the
size of the filter table but significantly reduces the noise
introduced by the quantization of the impulse response.

- the parameters of the filter are set such that aliasing is
rejected at 80 dB below 20 KHz. Because we don't use a lot of
coefficient (to save compute power), there are quite a bit of
attenuation in the pass-band: starting at 9KHz for the
down-sampler (48 to 44.1), and starting at 13 KHz for the
up-sampler (44.1 to 48) -- the transition band is about 15 KHz.

Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838

commit 69e7dab2192adc1f780464146810629ebd01b145
Author: Pixelflinger <mathias.agopian@gmail.com>
Date: Thu Oct 25 19:43:49 2012 -0700

improve fir tool: cleanup, better default, bug fixes

- all parameters can be changed on the command-line
- added float output
- added debug option
- added an option to generate a polyphase filter coefficients
- added an attenuation option in dBFS
- added a lot of comments and references
- fixed kaiser window parameter

also the default should generate a filter with 80 dB rejection
(of the 24 KHz aliasing) above 20 KHz and a 15 KHz transition
band around ~20 KHz (for 48 KHz sampling rate).
It's not very good but corresponds to the current code.

commit 8347499d105a50257c18e9dac652e750b06428b1
Author: Glenn Kasten <gkasten@google.com>
Date: Mon Oct 22 17:09:27 2012 -0700

Increase allowed number of VHQ resamplers to 3

Bug: 7378660
Change-Id: I69e33ca2eb4bb9bd38e2c63df62cd1130d68baf6

commit f91cf3cad7f5c4d52614271c89ab468741c5d24c
Author: Mathias Agopian <mathias@google.com>
Date: Sun Oct 21 03:04:05 2012 -0700

Fix a typo that caused the high quality resampler to produce garbage

the problem is that if libaudio_resampler is present, it is those
coefficients that will always be selected, but the correct
meta-data.

Bug: 7385994
Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621

commit e158a9e4262a174c59469a205658bc3ca4078234
Author: Dan Bornstein <danfuzz@google.com>
Date: Fri Oct 3 10:34:57 2008 -0700

Manually merge change #111620 from tc3 to mainline, to keep the

automerger from choking on it.

p4 sync
p4 integrate -r -b android_to_tc3 //...@111620,111620
p4 resolve -a
p4 resolve # resolve a couple merge travesties

PRESUBMIT=passed
BUG=1399648
TBR=edheyl
OCL=111902

Change-Id: I854b01553dd92bbf9c864f5a9bd51a3d665f0ac2
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit b9f3c26032be7a6ea01a10d93d94826f449e68ab
Author: Dave Bort <dbort@google.com>
Date: Fri Jan 18 14:51:05 2008 -0800

Rename "Makefile" to "Android.mk" throughout the tree.

For <http://b/issue?id=960416>.

I've tested this as much as I can, but 1500 open files =
easy to mess things up. Please let me know if there's
a problem rather than rolling back this change.

PRESUBMIT=passed
BUG=960416
TBR=joeo
OCL=46537

Change-Id: I5a404caf0f398a7afa7ae7abaf2f2a1c6ab490eb
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit 0c22a9a44c4103483fba1d944acf1354c5eb1617
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 23:44:25 2007 -0700

Tweak the SINC resampler parameters and double the performance. It's using about 10% CPU in the worse case now.

Change-Id: I50ac7e6c6702a427fa36ab6d976c507155057507
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit b85e41487983ad085b859acf8251e7e54480308a
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 04:34:36 2007 -0700

A sinc resampler for Audioflinger. It's not enabled yet, but fully functional and apparently working. It need more "quality" tests. In the 48->44 KHz, it takes about 25% of the CPU time.

Change-Id: I80eb5185e13ebdb907e0b85c49ba1272c23d60ec
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit ba3949ef17cac2ba71cc3096c413782a49c922e5
Author: Mathias Agopian <mathias@google.com>
Date: Thu Aug 23 21:01:28 2007 -0700

fix a few small typos in the FIR computation

Change-Id: I6e56b514fe520f30f7487f85c64ea5d2a7c19b40
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit 7474bfa7de2604021963794dddfe44985648db6a
Author: Mathias Agopian <mathias@google.com>
Date: Thu Aug 23 03:16:02 2007 -0700

This is a tool to compute the the reconstruction filter coefficients for a sinc audio resampler.

Change-Id: I99be2505139b8e0e7647200e1647509d4f7e6067
Signed-off-by: Glenn Kasten <gkasten@google.com>

Bug: 7577965
Change-Id: I2c84a9283a1668723bad83e1a119c849c88c3e6b
ndroid.mk
udioResampler.cpp
udioResamplerSinc.cpp
udioResamplerSinc.h
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/filter_coefficients.h
udio-resampler/resampler_filter_coefficients_10042011.h
est-resample.cpp
a614426bc7e195af227a585bb0a07f43b4022d78 19-Nov-2012 Glenn Kasten <gkasten@google.com> New VHQ resampler

Squashed commit of the following:

commit 12b6952da9f25e94d06dd7185bce255924e7e791
Author: Mathias Agopian <mathias@google.com>
Date: Mon Nov 19 15:27:26 2012 -0800

fix a typo in SINC resampler that prevented tracks to be mixed

we were always erasing the current mix instead of mixing into it.

Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2

commit 0019ce082df430278f14ab922e900ce33b64897d
Author: Dave Bort <dbort@google.com>
Date: Tue Nov 13 01:30:32 2007 -0800

Rename "TARGET" to "MODULE" in the build system.

Part one of the grand renaming.

API_CHANGE: Third parties may need to update their makefiles.
Any variables with "LOCAL" and "TARGET" in their names
should now use "MODULE" instead of "TARGET"; e.g., LOCAL_MODULE,
LOCAL_MODULE_TAGS.

PRESUBMIT=passed
OCL=39840

Change-Id: Ica9a7937d3d9552ab84db46ac6eea8a290e404fe
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit f01adc0cef0e39e75c76d9195ac26a94cac0a100
Author: Glenn Kasten <gkasten@google.com>
Date: Wed Nov 14 08:32:08 2012 -0800

Fix build warnings

Change-Id: Ic43bcca166a529a6431711b05a7fa21849b6a38b

commit 9bb031a565c753a03d9c9397edea318947d80528
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 10 04:44:30 2012 -0800

more optimizations...

calculate the offsets from the phase differently, this happens
to reduce the register pressure in the main loop, which in turns
allows the compiler to generate much better code (doesn't need
to spill a lot of stuff on the stack).

this gives another 15% performance increase

Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96

commit 5a951598f31217b8cd2babd0720c9608ee17291a
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 10 03:26:39 2012 -0800

refactor code to improve neon code

we want to make sure we don't transfer data from the
neon unit to the arm register file, as this can be quite
slow. instead we do all the calculation on the neon side
and write the result directly to main memory.

Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187

commit b381ee9e83bc9fd18986e79c7809841514ed590e
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 15:16:13 2012 -0800

NEON optimized SINC resampler

this currently gives us a 60% to 80% boost depending
on the quality level selected.

Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b

commit bea077354210242ea193a50b0dbab0fedab25df3
Author: Mathias Agopian <mathias@google.com>
Date: Mon Nov 5 01:51:37 2012 -0800

minor cleanups

Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f

commit 8f4ed7decbe161a5ff38200b218f5216d80aba46
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 18:49:14 2012 -0800

improve resample test

- handle stereo input
- input file can now be ommited, in this case
a linear chirp will be used automatically
- better usage information

Change-Id: I5d62a6c26a9054a1c1a517a065b4df5a2cdcda22

commit 5fcd634ea6cb4df27c495abe20f5f9b8ff55d128
Author: Mathias Agopian <mathias@google.com>
Date: Sun Nov 4 02:03:49 2012 -0800

change how we store the FIR coefficients

The coefficient table is now transposed and shows
much better its polyphase nature: we now have a FIR
per line, each line corresponding to a phase.

This doesn't change at all the results produced by
the filter, but allows us to make slightly better
use of the data cache and improves performance a bit
(although not as much as I thought it would).

The main benefit is that it is the first step
before we can make much larger optimizations
(like using NEON).

Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43

commit d652231abf4c7e2ea1fc89caae730cec1f7259a1
Author: Mathias Agopian <mathias@google.com>
Date: Sat Nov 3 23:37:53 2012 -0700

improve SINC resampler performance

The improvement is about 60% by just tweaking a few
things to help the compiler generate better code.
It turns out that inlining too much stuff manually was hurting us.

Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304

commit 9dc68ef5b94c700c4ee68790e8cbb334c90a538d
Author: Mathias Agopian <mathias@google.com>
Date: Thu Nov 1 21:03:46 2012 -0700

new coefficients for the vhq resampler

previous coefficients were provided by a 3rd party and didn't have a
way to re-generate them. we're now using the 'fir' utility.

the performance of the filter is virtually identical, except for
the down-sampling case which seems slightly better now:
It looks like both the previous and new coefficients are generating
some sort of clipping for full-scale signals in the down-sampling case
(although the new ones seem better), the reason for that is
unknown (see bug: 7453062)

Also updated the HQ coefficients for the down-samplers, previous ones
were a little bit too conservative -- the new ones push the cut-off
frequency up by about 1 KHz.

Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647

commit 38e0b8560a6fc1b7124e22e0e09a84a285182f8e
Author: Mathias Agopian <mathias@google.com>
Date: Tue Oct 30 13:51:44 2012 -0700

fix SINC resampler on non ARM architectures

make sure the C version of the code generates the same
output than the ARM assemply version.

Change-Id: Ide218785c35d02598b2d7278e646b1b178148698

commit a1878128b182696ba508569b4d211d0dfae92463
Author: Mathias Agopian <mathias@google.com>
Date: Tue Oct 30 12:49:07 2012 -0700

fix another issue with generating FIR coefficients

the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were
missing the 2*f scale factor. This explains why we were seeing
clipping and had to manually scale the filter down.

Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186

commit 1a0fb993430acc9f601e6c538305bc407c20ac5d
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 17:13:20 2012 -0700

fir a typo that caused up-sampling coefficiens to be wrong

up-sample coefficient were generated with a cut-off frequency of 24KHz
intead of ~20KHz, which caused more aliasing in the audible band.

also increased the attenuation to 1.3 dB on both up and down
sampling coefficient to avoid clipping.

Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e

commit 9520ad6862bd682ad075a9d9e3e94ada9f6e58b6
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 17:13:16 2012 -0700

test-resample: clip instead of overflowing

Change-Id: I550e5a59e51c11e1095ca338222b094f92b96878

commit ba36656300f250f7f1fdeb75149749344260e6cb
Author: Mathias Agopian <mathias@google.com>
Date: Sun Oct 21 01:01:38 2012 -0700

a test app for the resamplers

Change-Id: I66852d90d384f1d9e77b51ad1a1ebdbaf61d0607

commit 056a08b9bfd33cf27228c992adc8293a56b01be8
Author: Mathias Agopian <mathias@google.com>
Date: Fri Oct 26 14:11:01 2012 -0700

reenable the cubic resampler

cubic resampler was disabled because it hadn't been qualified,
however after I did some tests, it does improve significantly
the sound quality over the order-1 resampler, even if it is
still quite bad.

also HIGH_QUALITY resampler was partially disabled, it's now
fully enabled. It's a big improvement over the cubic resampler
in terms of aliasing noise (it's not as good in the pass-band).

Change-Id: I70e3658c255896588642697be9eb594ff4ec0f8b

commit 8c0241d3ff50ae85167f69b3bd369244894cfa44
Author: Mathias Agopian <mathias@google.com>
Date: Fri Oct 26 13:48:42 2012 -0700

improve SINC resampler coefficients

- we increase the interpolation precision from 4 to 7 bits
this doesn't increase CPU power required, it only increases the
size of the filter table but significantly reduces the noise
introduced by the quantization of the impulse response.

- the parameters of the filter are set such that aliasing is
rejected at 80 dB below 20 KHz. Because we don't use a lot of
coefficient (to save compute power), there are quite a bit of
attenuation in the pass-band: starting at 9KHz for the
down-sampler (48 to 44.1), and starting at 13 KHz for the
up-sampler (44.1 to 48) -- the transition band is about 15 KHz.

Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838

commit 69e7dab2192adc1f780464146810629ebd01b145
Author: Pixelflinger <mathias.agopian@gmail.com>
Date: Thu Oct 25 19:43:49 2012 -0700

improve fir tool: cleanup, better default, bug fixes

- all parameters can be changed on the command-line
- added float output
- added debug option
- added an option to generate a polyphase filter coefficients
- added an attenuation option in dBFS
- added a lot of comments and references
- fixed kaiser window parameter

also the default should generate a filter with 80 dB rejection
(of the 24 KHz aliasing) above 20 KHz and a 15 KHz transition
band around ~20 KHz (for 48 KHz sampling rate).
It's not very good but corresponds to the current code.

commit 8347499d105a50257c18e9dac652e750b06428b1
Author: Glenn Kasten <gkasten@google.com>
Date: Mon Oct 22 17:09:27 2012 -0700

Increase allowed number of VHQ resamplers to 3

Bug: 7378660
Change-Id: I69e33ca2eb4bb9bd38e2c63df62cd1130d68baf6

commit f91cf3cad7f5c4d52614271c89ab468741c5d24c
Author: Mathias Agopian <mathias@google.com>
Date: Sun Oct 21 03:04:05 2012 -0700

Fix a typo that caused the high quality resampler to produce garbage

the problem is that if libaudio_resampler is present, it is those
coefficients that will always be selected, but the correct
meta-data.

Bug: 7385994
Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621

commit e158a9e4262a174c59469a205658bc3ca4078234
Author: Dan Bornstein <danfuzz@google.com>
Date: Fri Oct 3 10:34:57 2008 -0700

Manually merge change #111620 from tc3 to mainline, to keep the

automerger from choking on it.

p4 sync
p4 integrate -r -b android_to_tc3 //...@111620,111620
p4 resolve -a
p4 resolve # resolve a couple merge travesties

PRESUBMIT=passed
BUG=1399648
TBR=edheyl
OCL=111902

Change-Id: I854b01553dd92bbf9c864f5a9bd51a3d665f0ac2
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit b9f3c26032be7a6ea01a10d93d94826f449e68ab
Author: Dave Bort <dbort@google.com>
Date: Fri Jan 18 14:51:05 2008 -0800

Rename "Makefile" to "Android.mk" throughout the tree.

For <http://b/issue?id=960416>.

I've tested this as much as I can, but 1500 open files =
easy to mess things up. Please let me know if there's
a problem rather than rolling back this change.

PRESUBMIT=passed
BUG=960416
TBR=joeo
OCL=46537

Change-Id: I5a404caf0f398a7afa7ae7abaf2f2a1c6ab490eb
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit 0c22a9a44c4103483fba1d944acf1354c5eb1617
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 23:44:25 2007 -0700

Tweak the SINC resampler parameters and double the performance. It's using about 10% CPU in the worse case now.

Change-Id: I50ac7e6c6702a427fa36ab6d976c507155057507
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit b85e41487983ad085b859acf8251e7e54480308a
Author: Mathias Agopian <mathias@google.com>
Date: Mon Oct 29 04:34:36 2007 -0700

A sinc resampler for Audioflinger. It's not enabled yet, but fully functional and apparently working. It need more "quality" tests. In the 48->44 KHz, it takes about 25% of the CPU time.

Change-Id: I80eb5185e13ebdb907e0b85c49ba1272c23d60ec
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit ba3949ef17cac2ba71cc3096c413782a49c922e5
Author: Mathias Agopian <mathias@google.com>
Date: Thu Aug 23 21:01:28 2007 -0700

fix a few small typos in the FIR computation

Change-Id: I6e56b514fe520f30f7487f85c64ea5d2a7c19b40
Signed-off-by: Glenn Kasten <gkasten@google.com>

commit 7474bfa7de2604021963794dddfe44985648db6a
Author: Mathias Agopian <mathias@google.com>
Date: Thu Aug 23 03:16:02 2007 -0700

This is a tool to compute the the reconstruction filter coefficients for a sinc audio resampler.

Change-Id: I99be2505139b8e0e7647200e1647509d4f7e6067
Signed-off-by: Glenn Kasten <gkasten@google.com>

Bug: 7577965
Change-Id: I2c84a9283a1668723bad83e1a119c849c88c3e6b
ndroid.mk
udioResampler.cpp
udioResamplerSinc.cpp
udioResamplerSinc.h
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/filter_coefficients.h
udio-resampler/resampler_filter_coefficients_10042011.h
est-resample.cpp
da398117aff410e1856299450ef6ca4faddad75c 20-Nov-2012 Eric Laurent <elaurent@google.com> Merge "AudioFlinger files reorganization"
eac37593f82855e980524f8c8c4441c21bba18e6 20-Nov-2012 Eric Laurent <elaurent@google.com> Merge "AudioFlinger files reorganization"
ca7cc8273ffd88b9b89655808ee7e3df74162b83 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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
ffects.cpp
ffects.h
laybackTracks.h
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
ffects.cpp
ffects.h
laybackTracks.h
ecordTracks.h
hreads.cpp
hreads.h
rackBase.h
racks.cpp
bc9ea63daaad764d242ce0eadfeb697abb9ce34e 20-Nov-2012 Mathias Agopian <mathias@google.com> fix a typo in SINC resampler that prevented tracks to be mixed

we were always erasing the current mix instead of mixing into it.

Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2
udioResamplerSinc.cpp
d6864faccd19096b72d32481a3cc475e6d36e50d 20-Nov-2012 Mathias Agopian <mathias@google.com> fix a typo in SINC resampler that prevented tracks to be mixed

we were always erasing the current mix instead of mixing into it.

Change-Id: Ib229245f9e5a0d384f1727640a59e9f0469211a2
udioResamplerSinc.cpp
c45128af9231a6e26c4deef798b79e74e4fad904 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
7aeff3f2197de81271c3e5547486f3407be56182 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge ""if" statements use curly braces per media style"
aa25c0321bd4b9eb46a4d1cb4ac5fa47af30eeb4 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge ""if" statements use curly braces per media style"
645f38376b042759ee3cfe78b7e97a6867b65814 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix time vs. bytes units bug in getRenderPosition"
77035d10a740914313500811b31a90ab948bd267 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix time vs. bytes units bug in getRenderPosition"
0dec3d6af5ad8783149134e594aadbe5dc339b4d 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Don't use control block frame count after create"
67ba2b6b8018ce7556cdd880dbf28d06a92ebb78 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Don't use control block frame count after create"
d7101432aa28f18b1510d9c186a27eecbeba46b2 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
udioFlinger.cpp
udioFlinger.h
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
udioFlinger.cpp
udioFlinger.h
a204922b4c04633a4e9896db3c40763bcf921ade 23-Jun-2012 Glenn Kasten <gkasten@google.com> "if" statements use curly braces per media style

Change-Id: I130e7849fd1da7a0b7fe56c3c53919d26e3843b8
udioFlinger.cpp
d65d73c4ae74d084751b417615a78cbe7a51372a 23-Jun-2012 Glenn Kasten <gkasten@google.com> "if" statements use curly braces per media style

Change-Id: I130e7849fd1da7a0b7fe56c3c53919d26e3843b8
udioFlinger.cpp
411e447c4b90298f5ff635429c53f94fbce4fff9 02-Nov-2012 Glenn Kasten <gkasten@google.com> Don't explicitly log tid

If needed, it can be obtained with adb logcat -v threadtime

Change-Id: I91b3911d20f7bcfc3361db4052db21ff9181f1cf
udioFlinger.cpp
udioPolicyService.cpp
827e5f1237757aee78b677efcf0f7c44fd0dd3d8 02-Nov-2012 Glenn Kasten <gkasten@google.com> Don't explicitly log tid

If needed, it can be obtained with adb logcat -v threadtime

Change-Id: I91b3911d20f7bcfc3361db4052db21ff9181f1cf
udioFlinger.cpp
udioPolicyService.cpp
b59a5026ecdb3dc283c448e5bbd51b1c6d42b946 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
d983364b3655a547b55bb11dbe148103198c011d 15-Nov-2012 Glenn Kasten <gkasten@google.com> Static AudioTrack plays twice initially

Bug: 7528721
Change-Id: I10bc16a26f33dba6572b730a170cb3bf00e68e30
udioFlinger.cpp
35436ad21902edf83e3c1307b45b38d13137d31c 15-Nov-2012 Glenn Kasten <gkasten@google.com> Static AudioTrack plays twice initially

Bug: 7528721
Change-Id: I10bc16a26f33dba6572b730a170cb3bf00e68e30
udioFlinger.cpp
56938ef8dc82b49ddbc201a8855c91ba46d73bfb 16-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Use size_t for frame counts"
aac817e6685a51843e84c23d970b3d559e74e8f6 16-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Use size_t for frame counts"
7da35f231725aa6e0b2ac8714a7d66471368df77 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use size_t for frame counts

Also fix typo: bufferCount should be frameCount.

Change-Id: Ibed539504db75ef99dc21c8ff1bf2987122063a5
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
5b78fc92d9e64623be66a5c3031b54dcd8ed28f9 15-Nov-2012 Glenn Kasten <gkasten@google.com> Static AudioTrack plays twice initially

Bug: 7528721
Change-Id: I10bc16a26f33dba6572b730a170cb3bf00e68e30
udioFlinger.cpp
4bd7e5436f9c308503d72e80804fb5637fda1584 15-Nov-2012 Glenn Kasten <gkasten@google.com> Static AudioTrack plays twice initially

Bug: 7528721
Change-Id: I10bc16a26f33dba6572b730a170cb3bf00e68e30
udioFlinger.cpp
520a9af9438c29b24e328dd2b7a287c7a96a4e6b 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
1127d65d536ebbe447ee17ce0926a7ce4a2a3c08 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use uint32_t for sample rate

Change-Id: Ie240b48fb54b08359f69ecd4e5f8bda3d15cbe80
udioFlinger.cpp
udioFlinger.h
3b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use uint32_t for sample rate

Change-Id: Ie240b48fb54b08359f69ecd4e5f8bda3d15cbe80
udioFlinger.cpp
udioFlinger.h
1513ad2d2de0962cc3b3121e6fae73d8ee1a4639 15-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Update audio comments"
b4a17e834b718eff1ba2eac4232de6e73a4bf9f5 15-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Update audio comments"
a9749e3468fda2288dda65d1ef52e0997f6d8897 15-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix build warnings"
acc8706f91f799ea63c10ecad4959c55e0873d93 15-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix build warnings"
656130a7bcff790dc9311754189d46bd4b911fbf 14-Nov-2012 Mathias Agopian <mathias@google.com> Merge changes I2ce3479d,Ibb56664d

* changes:
more optimizations...
refactor code to improve neon code
30ca3be314993fb4155bee1a17a4b76354cd6ef9 14-Nov-2012 Mathias Agopian <mathias@google.com> Merge changes I2ce3479d,Ibb56664d

* changes:
more optimizations...
refactor code to improve neon code
020f79fd967736d36c7ec860814e2e93866a020f 07-Nov-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: I85d7d2f6381b251db5695202fec75128883a8662
udioFlinger.h
tateQueue.h
22eb4e239fbe9103568147d566d7482e480350b8 07-Nov-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: I85d7d2f6381b251db5695202fec75128883a8662
udioFlinger.h
tateQueue.h
98d9922247ef21b0faf8c7d817650b8327052a4a 14-Nov-2012 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: Ic43bcca166a529a6431711b05a7fa21849b6a38b
est-resample.cpp
b26e3e9f2ab0334bff21a4fa4851dbf6e57fba5d 14-Nov-2012 Glenn Kasten <gkasten@google.com> Fix build warnings

Change-Id: Ic43bcca166a529a6431711b05a7fa21849b6a38b
est-resample.cpp
e2a0586eae45a3eb1fad0f28ca2f8b0204d78df6 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
5aab59a2bd0a2cd80240ffd66c1b963b5fe06d65 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
5d3370d0db4dc97fa413a302e426fb24e87462be 10-Nov-2012 Mathias Agopian <mathias@google.com> more optimizations...

calculate the offsets from the phase differently, this happens
to reduce the register pressure in the main loop, which in turns
allows the compiler to generate much better code (doesn't need
to spill a lot of stuff on the stack).

this gives another 15% performance increase

Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96
udioResamplerSinc.cpp
udioResamplerSinc.h
7492a7ff46a75b5d8e10ae11d4ad50429cf945ce 10-Nov-2012 Mathias Agopian <mathias@google.com> more optimizations...

calculate the offsets from the phase differently, this happens
to reduce the register pressure in the main loop, which in turns
allows the compiler to generate much better code (doesn't need
to spill a lot of stuff on the stack).

this gives another 15% performance increase

Change-Id: I2ce3479dd48b9e6941adb80e6d443d6e14d64d96
udioResamplerSinc.cpp
udioResamplerSinc.h
3c11ff2f409a0abb5b9d8ffd5e13cc42cda67fdc 10-Nov-2012 Mathias Agopian <mathias@google.com> refactor code to improve neon code

we want to make sure we don't transfer data from the
neon unit to the arm register file, as this can be quite
slow. instead we do all the calculation on the neon side
and write the result directly to main memory.

Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187
udioResamplerSinc.cpp
udioResamplerSinc.h
0d585c85524eb5d398fadff5ca8dd43939ed9cb4 10-Nov-2012 Mathias Agopian <mathias@google.com> refactor code to improve neon code

we want to make sure we don't transfer data from the
neon unit to the arm register file, as this can be quite
slow. instead we do all the calculation on the neon side
and write the result directly to main memory.

Change-Id: Ibb56664d3ab03098ae2798b75e2b6927ac900187
udioResamplerSinc.cpp
udioResamplerSinc.h
3f6f4393d0adf4465959059d69798aed55e34876 09-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Move buffers pointer out of the control block"
e35a582d02586cb43ad9e344138b4edad62868b3 09-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Move buffers pointer out of the control block"
c6ccbabd2800e749bc86a34d2ae233f99102ba51 05-Nov-2012 Mathias Agopian <mathias@google.com> NEON optimized SINC resampler

this currently gives us a 60% to 80% boost depending
on the quality level selected.

Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b
udioResamplerSinc.cpp
est-resample.cpp
ad9af03c4b491912239fc8c97a3ad0d342a33303 05-Nov-2012 Mathias Agopian <mathias@google.com> NEON optimized SINC resampler

this currently gives us a 60% to 80% boost depending
on the quality level selected.

Change-Id: I7db385007e811ed7bffe5fd3403b44e300894f5b
udioResamplerSinc.cpp
est-resample.cpp
af03dfb73d05dfabdf55640aff8b2256fdd78663 05-Nov-2012 Mathias Agopian <mathias@google.com> minor cleanups

Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f
udioResamplerSinc.cpp
7aa7ed773040ea60bbe0a2a6ea949d62802304a4 05-Nov-2012 Mathias Agopian <mathias@google.com> minor cleanups

Change-Id: Ia12ee4fb59e90221761bec85e6450db29197591f
udioResamplerSinc.cpp
2f6226ad7a3fa81dc102001fbc1d1288e55a0947 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
ba85098eb31bd2637db49816f0591361211024f2 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
891b11da870ad3f860c1d2610ef4d8836ed6c590 07-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Remove CBLK_FAST from control block flags"
8fa3ad0e4c77f7868348ad2a4cacc34c34e7c39e 07-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Remove CBLK_FAST from control block flags"
c26741598a840f7c1d12ee457fb26f68fcdbcc70 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
3929402c7e3d9865cdeabedf291e1c4a1db48ce7 07-Nov-2012 Mathias Agopian <mathias@google.com> Merge changes I5d62a6c2,Iebf76958,I8068f0f7

* changes:
improve resample test
change how we store the FIR coefficients
improve SINC resampler performance
879256758603bac0e4718ab88db145f19f70027b 07-Nov-2012 Mathias Agopian <mathias@google.com> Merge changes I5d62a6c2,Iebf76958,I8068f0f7

* changes:
improve resample test
change how we store the FIR coefficients
improve SINC resampler performance
ac65726b26a63635d3461f96b4b979add5a8f7dc 05-Nov-2012 Glenn Kasten <gkasten@google.com> Merge duplicate code in TrackBase::TrackBase()

Change-Id: Id8a7db4d94888796a9dcbed4cac99941705cd174
udioFlinger.cpp
287fedb1b1430f138c1f583869b10294773945be 05-Nov-2012 Glenn Kasten <gkasten@google.com> Merge duplicate code in TrackBase::TrackBase()

Change-Id: Id8a7db4d94888796a9dcbed4cac99941705cd174
udioFlinger.cpp
d12b033552585cd8761ba6241f21e4cea4a21878 05-Nov-2012 Glenn Kasten <gkasten@google.com> Simplify control block flag names

Use only one symbol per flag

Change-Id: Ia3582e2134abd60c896d11337face65383e79c7c
udioFlinger.cpp
9c5fdd83f9b9f49be35107971feb33528d60b945 05-Nov-2012 Glenn Kasten <gkasten@google.com> Simplify control block flag names

Use only one symbol per flag

Change-Id: Ia3582e2134abd60c896d11337face65383e79c7c
udioFlinger.cpp
7df17073f1783421d6ed2013e6b55c60283d1474 05-Nov-2012 Mathias Agopian <mathias@google.com> improve resample test

- handle stereo input
- input file can now be ommited, in this case
a linear chirp will be used automatically
- better usage information

Change-Id: I5d62a6c26a9054a1c1a517a065b4df5a2cdcda22
est-resample.cpp
3f71761cab8a08e4ae9e4cf8cb8f1b82643825b2 05-Nov-2012 Mathias Agopian <mathias@google.com> improve resample test

- handle stereo input
- input file can now be ommited, in this case
a linear chirp will be used automatically
- better usage information

Change-Id: I5d62a6c26a9054a1c1a517a065b4df5a2cdcda22
est-resample.cpp
e8299af5665bf9c396466c33b9b16a84fe78c7f6 04-Nov-2012 Mathias Agopian <mathias@google.com> change how we store the FIR coefficients

The coefficient table is now transposed and shows
much better its polyphase nature: we now have a FIR
per line, each line corresponding to a phase.

This doesn't change at all the results produced by
the filter, but allows us to make slightly better
use of the data cache and improves performance a bit
(although not as much as I thought it would).

The main benefit is that it is the first step
before we can make much larger optimizations
(like using NEON).

Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43
udioResamplerSinc.cpp
udioResamplerSinc.h
udio-resampler/filter_coefficients.h
46afbec3743f1d799f185273ff897d1f8e0175dd 04-Nov-2012 Mathias Agopian <mathias@google.com> change how we store the FIR coefficients

The coefficient table is now transposed and shows
much better its polyphase nature: we now have a FIR
per line, each line corresponding to a phase.

This doesn't change at all the results produced by
the filter, but allows us to make slightly better
use of the data cache and improves performance a bit
(although not as much as I thought it would).

The main benefit is that it is the first step
before we can make much larger optimizations
(like using NEON).

Change-Id: Iebf7695825dcbd41f25861efcaefbaa3365ecb43
udioResamplerSinc.cpp
udioResamplerSinc.h
udio-resampler/filter_coefficients.h
50ebdf2086b645b9b703a6d489238767a9afb34f 04-Nov-2012 Mathias Agopian <mathias@google.com> improve SINC resampler performance

The improvement is about 60% by just tweaking a few
things to help the compiler generate better code.
It turns out that inlining too much stuff manually was hurting us.

Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304
udioResamplerSinc.cpp
udioResamplerSinc.h
a798c97386a842d06d290797ba5dce95d031332a 04-Nov-2012 Mathias Agopian <mathias@google.com> improve SINC resampler performance

The improvement is about 60% by just tweaking a few
things to help the compiler generate better code.
It turns out that inlining too much stuff manually was hurting us.

Change-Id: I8068f0f75051f95ac600e50ce552572dd1e8c304
udioResamplerSinc.cpp
udioResamplerSinc.h
fb242fa66643d1bd5362077a44c02c86c8064564 02-Nov-2012 Mathias Agopian <mathias@google.com> Merge "new coefficients for the vhq resampler"
f27bdebd0c611f9618577f65346f44574146dc00 02-Nov-2012 Mathias Agopian <mathias@google.com> Merge "new coefficients for the vhq resampler"
c5b0b9a13a29be483173f092663ed17ea306ac0d 02-Nov-2012 Mathias Agopian <mathias@google.com> new coefficients for the vhq resampler

previous coefficients were provided by a 3rd party and didn't have a
way to re-generate them. we're now using the 'fir' utility.

the performance of the filter is virtually identical, except for
the down-sampling case which seems slightly better now:
It looks like both the previous and new coefficients are generating
some sort of clipping for full-scale signals in the down-sampling case
(although the new ones seem better), the reason for that is
unknown (see bug: 7453062)

Also updated the HQ coefficients for the down-samplers, previous ones
were a little bit too conservative -- the new ones push the cut-off
frequency up by about 1 KHz.

Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647
udioResamplerSinc.cpp
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/filter_coefficients.h
udio-resampler/resampler_filter_coefficients_10042011.h
4ed475d3ad4231370371e14a94779c5d300eb3c5 02-Nov-2012 Mathias Agopian <mathias@google.com> new coefficients for the vhq resampler

previous coefficients were provided by a 3rd party and didn't have a
way to re-generate them. we're now using the 'fir' utility.

the performance of the filter is virtually identical, except for
the down-sampling case which seems slightly better now:
It looks like both the previous and new coefficients are generating
some sort of clipping for full-scale signals in the down-sampling case
(although the new ones seem better), the reason for that is
unknown (see bug: 7453062)

Also updated the HQ coefficients for the down-samplers, previous ones
were a little bit too conservative -- the new ones push the cut-off
frequency up by about 1 KHz.

Change-Id: I54a827b5c707c7cc41268ed01283758dce1d7647
udioResamplerSinc.cpp
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/filter_coefficients.h
udio-resampler/resampler_filter_coefficients_10042011.h
8af901cdea0af7e536579dee6d56e69987035a01 01-Nov-2012 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioPolicyService.cpp
udioPolicyService.h
est-resample.cpp
85ab62c4b433df3f1a9826bed1c9bec07a86c750 01-Nov-2012 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioPolicyService.cpp
udioPolicyService.h
est-resample.cpp
8c32734c1e2dda852011fc46d0caded971464bc2 30-Sep-2012 Glenn Kasten <gkasten@google.com> Save copy of mic input, disabled by default

Change-Id: I4f5e95a5ddf016530d1b2747a0a5ca0962caabda
ndroid.mk
udioFlinger.cpp
udioFlinger.h
d06785bebf7e43d4a011b62a252771373ada910c 30-Sep-2012 Glenn Kasten <gkasten@google.com> Save copy of mic input, disabled by default

Change-Id: I4f5e95a5ddf016530d1b2747a0a5ca0962caabda
ndroid.mk
udioFlinger.cpp
udioFlinger.h
901475744e15d8a4728cb111e510624377abaec3 31-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "StateQueue comments"
a2757a0ef4ccffd01864dcc643726d26838d562b 31-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "StateQueue comments"
be58bd19f4b99e04651cff0dfc968248f5b0e440 31-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete references to libmedia_native"
b7d55a839356ad55316b5dd5b83396b69d391ce3 31-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Remove obsolete references to libmedia_native"
d55d23209bb90ff7bd7443d1b54fa07c0ed8d14f 30-Oct-2012 Mathias Agopian <mathias@google.com> Merge changes Ide218785,I86d0bb82

* changes:
fix SINC resampler on non ARM architectures
fix another issue with generating FIR coefficients
670d4b7520bca8c6b3c59db2640698358d83aca6 30-Oct-2012 Mathias Agopian <mathias@google.com> Merge changes Ide218785,I86d0bb82

* changes:
fix SINC resampler on non ARM architectures
fix another issue with generating FIR coefficients
d7a3c142b3ce4ed26e025533f57bef9e4ec58740 30-Oct-2012 Mathias Agopian <mathias@google.com> fix SINC resampler on non ARM architectures

make sure the C version of the code generates the same
output than the ARM assemply version.

Change-Id: Ide218785c35d02598b2d7278e646b1b178148698
udioResamplerSinc.cpp
1f09b4ada212d259b531228db67ca160d280275c 30-Oct-2012 Mathias Agopian <mathias@google.com> fix SINC resampler on non ARM architectures

make sure the C version of the code generates the same
output than the ARM assemply version.

Change-Id: Ide218785c35d02598b2d7278e646b1b178148698
udioResamplerSinc.cpp
cca56d5784c02a5f02ce5e47c3d6583d71a2469b 30-Oct-2012 Mathias Agopian <mathias@google.com> fix another issue with generating FIR coefficients

the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were
missing the 2*f scale factor. This explains why we were seeing
clipping and had to manually scale the filter down.

Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186
udioResamplerSinc.cpp
d88a051aff15fdf5c57e1e5a4083bbd9635af3ad 30-Oct-2012 Mathias Agopian <mathias@google.com> fix another issue with generating FIR coefficients

the impulse response of a low-pass is 2*f*sinc(2*pi*f*k), we were
missing the 2*f scale factor. This explains why we were seeing
clipping and had to manually scale the filter down.

Change-Id: I86d0bb82ecdd99681c8ba5a8112a8257bf6f0186
udioResamplerSinc.cpp
faa4420344216ccbad15a49aa7c1cd6141532fcb 30-Oct-2012 Glenn Kasten <gkasten@google.com> Remove obsolete references to libmedia_native

Bug: 6654403
Change-Id: I3993d62987cf0dd85db10bf002a5cce53d4f01bd
ndroid.mk
c41590251aa84c078c942d258e838aad814b73a5 30-Oct-2012 Glenn Kasten <gkasten@google.com> Remove obsolete references to libmedia_native

Bug: 6654403
Change-Id: I3993d62987cf0dd85db10bf002a5cce53d4f01bd
ndroid.mk
b387e0f0e3338b4e19055d6ec2b79c04314251b3 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Document AudioMixer hard-coded limits"
0eac0714e9fbd6e43b1fd13a38131800b2a81377 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Document AudioMixer hard-coded limits"
f84d5761c5f12bb75af492de27d9bc5491e5667d 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Use ALOGVV instead of commented ALOGV"
db3a20ea484514f7f23d4ef3c30fe4780ab940d2 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Use ALOGVV instead of commented ALOGV"
3b0389dd5f611db1f65dcae88d0f6b332e447d7a 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up constructor and derivation whitespace"
bf1d047d6759c624139bfe9897dc3062d2e446e2 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up constructor and derivation whitespace"
a6d7d340cee564d41e7594a22233cab3d1ee26d9 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Mark volume fields private"
eb79904784c9479ae6fb60202c47e5287c058c4a 30-Oct-2012 Glenn Kasten <gkasten@google.com> Merge "Mark volume fields private"
7c4349fe6e1e4faaa0c0db40a74f2ccbac46f57e 30-Oct-2012 Mathias Agopian <mathias@google.com> fir a typo that caused up-sampling coefficiens to be wrong

up-sample coefficient were generated with a cut-off frequency of 24KHz
intead of ~20KHz, which caused more aliasing in the audible band.

also increased the attenuation to 1.3 dB on both up and down
sampling coefficient to avoid clipping.

Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e
udioResamplerSinc.cpp
b4b75b47c2a4248e60bbc3229d6acc4d5f872431 30-Oct-2012 Mathias Agopian <mathias@google.com> fir a typo that caused up-sampling coefficiens to be wrong

up-sample coefficient were generated with a cut-off frequency of 24KHz
intead of ~20KHz, which caused more aliasing in the audible band.

also increased the attenuation to 1.3 dB on both up and down
sampling coefficient to avoid clipping.

Change-Id: Ie8aeecf1429190541b656810c6716b6aae5ece2e
udioResamplerSinc.cpp
3e48fd11e3fca5c1d03354a99657298e110be56a 30-Oct-2012 Mathias Agopian <mathias@google.com> test-resample: clip instead of overflowing

Change-Id: I550e5a59e51c11e1095ca338222b094f92b96878
est-resample.cpp
9aec8c3f7f72cd36a8e3d7aafc1149f50514087a 30-Oct-2012 Mathias Agopian <mathias@google.com> test-resample: clip instead of overflowing

Change-Id: I550e5a59e51c11e1095ca338222b094f92b96878
est-resample.cpp
cbe4b36e67baba4ec1a4d7a9db9461e09c714f0c 19-Oct-2012 Glenn Kasten <gkasten@google.com> Use ALOGVV instead of commented ALOGV

Change-Id: I17bdb5274877760c7edaa31416020d349082e593
udioFlinger.cpp
26dd66e8ea7a1abf28c33196fc77822f68a718af 19-Oct-2012 Glenn Kasten <gkasten@google.com> Use ALOGVV instead of commented ALOGV

Change-Id: I17bdb5274877760c7edaa31416020d349082e593
udioFlinger.cpp
67360781c2d139a71d924ae24880b56adb7c1605 27-Oct-2012 Glenn Kasten <gkasten@google.com> StateQueue comments

Change-Id: Id8c76d1e2ab5201e7ab3875f1dbcc0a126e611a4
tateQueue.h
2188bc912a56d9bc577fcec7bf2208f49455e744 27-Oct-2012 Glenn Kasten <gkasten@google.com> StateQueue comments

Change-Id: Id8c76d1e2ab5201e7ab3875f1dbcc0a126e611a4
tateQueue.h
d82c750ca261d01caa405f555eef34b7af8d9b63 08-Mar-2012 Glenn Kasten <gkasten@google.com> Document AudioMixer hard-coded limits

Change-Id: I83ea8bed375f251260945db788bdb5f280dba12d
udioMixer.cpp
udioMixer.h
599fabc596687efa4b71b8f3ebbb957c7cae0c72 08-Mar-2012 Glenn Kasten <gkasten@google.com> Document AudioMixer hard-coded limits

Change-Id: I83ea8bed375f251260945db788bdb5f280dba12d
udioMixer.cpp
udioMixer.h
8a831724c52164a62e22e8e4d5f5180501e3c307 10-Jul-2012 Glenn Kasten <gkasten@google.com> Clean up constructor and derivation whitespace

Change-Id: I47d688a9c10c4c3c868accc34102fb402ebcac62
udioFlinger.h
274c02ee1464d8948913ac70e64e8dbb80f82ad7 10-Jul-2012 Glenn Kasten <gkasten@google.com> Clean up constructor and derivation whitespace

Change-Id: I47d688a9c10c4c3c868accc34102fb402ebcac62
udioFlinger.h
288a6fd72949dec167c5421d5bc977d1ccb75561 06-Mar-2012 Glenn Kasten <gkasten@google.com> Mark volume fields private

Change-Id: I8ffca0460195263d159aa13015c246122d8556a2
udioFlinger.h
dc8a0d75bd7b1343cd65c3c7f6e0f91ca0fa6946 06-Mar-2012 Glenn Kasten <gkasten@google.com> Mark volume fields private

Change-Id: I8ffca0460195263d159aa13015c246122d8556a2
udioFlinger.h
bcf5220780fbf24477bf8d6148581307356c97b7 21-Oct-2012 Mathias Agopian <mathias@google.com> a test app for the resamplers

Change-Id: I66852d90d384f1d9e77b51ad1a1ebdbaf61d0607
ndroid.mk
est-resample.cpp
0fc2cb59d5f77412f5922540d67fea81f4d1744b 21-Oct-2012 Mathias Agopian <mathias@google.com> a test app for the resamplers

Change-Id: I66852d90d384f1d9e77b51ad1a1ebdbaf61d0607
ndroid.mk
est-resample.cpp
51ba3c7c9a4a238cdef57ad75a2d8f406ffd4515 26-Oct-2012 Mathias Agopian <mathias@google.com> reenable the cubic resampler

cubic resampler was disabled because it hadn't been qualified,
however after I did some tests, it does improve significantly
the sound quality over the order-1 resampler, even if it is
still quite bad.

also HIGH_QUALITY resampler was partially disabled, it's now
fully enabled. It's a big improvement over the cubic resampler
in terms of aliasing noise (it's not as good in the pass-band).

Change-Id: I70e3658c255896588642697be9eb594ff4ec0f8b
ndroid.mk
udioResampler.cpp
93d0767a8a9ee9d649eea9afac59f778e29a6a54 26-Oct-2012 Mathias Agopian <mathias@google.com> reenable the cubic resampler

cubic resampler was disabled because it hadn't been qualified,
however after I did some tests, it does improve significantly
the sound quality over the order-1 resampler, even if it is
still quite bad.

also HIGH_QUALITY resampler was partially disabled, it's now
fully enabled. It's a big improvement over the cubic resampler
in terms of aliasing noise (it's not as good in the pass-band).

Change-Id: I70e3658c255896588642697be9eb594ff4ec0f8b
ndroid.mk
udioResampler.cpp
3bd72cc23f74e750069a2943ad3d5c9af3be4b55 26-Oct-2012 Mathias Agopian <mathias@google.com> improve SINC resampler coefficients

- we increase the interpolation precision from 4 to 7 bits
this doesn't increase CPU power required, it only increases the
size of the filter table but significantly reduces the noise
introduced by the quantization of the impulse response.

- the parameters of the filter are set such that aliasing is
rejected at 80 dB below 20 KHz. Because we don't use a lot of
coefficient (to save compute power), there are quite a bit of
attenuation in the pass-band: starting at 9KHz for the
down-sampler (48 to 44.1), and starting at 13 KHz for the
up-sampler (44.1 to 48) -- the transition band is about 15 KHz.

Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838
udioResamplerSinc.cpp
udioResamplerSinc.h
443e69625d598ea578e2c838960778ce498fd773 26-Oct-2012 Mathias Agopian <mathias@google.com> improve SINC resampler coefficients

- we increase the interpolation precision from 4 to 7 bits
this doesn't increase CPU power required, it only increases the
size of the filter table but significantly reduces the noise
introduced by the quantization of the impulse response.

- the parameters of the filter are set such that aliasing is
rejected at 80 dB below 20 KHz. Because we don't use a lot of
coefficient (to save compute power), there are quite a bit of
attenuation in the pass-band: starting at 9KHz for the
down-sampler (48 to 44.1), and starting at 13 KHz for the
up-sampler (44.1 to 48) -- the transition band is about 15 KHz.

Change-Id: I855548d2aab8a0fb0d2a2da3a364b6842d7d3838
udioResamplerSinc.cpp
udioResamplerSinc.h
d5f327e5f1d9d43208c59ae1f47187fb375fb941 23-Oct-2012 Glenn Kasten <gkasten@google.com> am 3aaa4e30: am c4640c9e: Increase allowed number of VHQ resamplers to 3

* commit '3aaa4e30f7663673f3453d3f4671b1119f1802fd':
Increase allowed number of VHQ resamplers to 3
790382e5f7e18672dce955747b8afd09a5e6cf04 23-Oct-2012 Glenn Kasten <gkasten@google.com> am 3aaa4e30: am c4640c9e: Increase allowed number of VHQ resamplers to 3

* commit '3aaa4e30f7663673f3453d3f4671b1119f1802fd':
Increase allowed number of VHQ resamplers to 3
c4640c9eef850bb1c754bd6b477f1cc8350c6081 23-Oct-2012 Glenn Kasten <gkasten@google.com> Increase allowed number of VHQ resamplers to 3

Bug: 7378660
Change-Id: I69e33ca2eb4bb9bd38e2c63df62cd1130d68baf6
udioResampler.cpp
f1b2a9b65a904b10f91482cc0389bea1f66a891f 23-Oct-2012 Glenn Kasten <gkasten@google.com> Increase allowed number of VHQ resamplers to 3

Bug: 7378660
Change-Id: I69e33ca2eb4bb9bd38e2c63df62cd1130d68baf6
udioResampler.cpp
8516ae9f56fd6d2ae6c6b5534609ae2ae3725d10 22-Oct-2012 Mathias Agopian <mathias@google.com> am 7f4d5714: am e384d75b: Merge "Fix a typo that caused the high quality resampler to produce garbage" into jb-mr1-dev

* commit '7f4d5714f3f0ab4efaf2d0929a9f984467ef95c7':
Fix a typo that caused the high quality resampler to produce garbage
df71e8e48ccf36b9f3947fb9d90cea4a5d319187 22-Oct-2012 Mathias Agopian <mathias@google.com> am 7f4d5714: am e384d75b: Merge "Fix a typo that caused the high quality resampler to produce garbage" into jb-mr1-dev

* commit '7f4d5714f3f0ab4efaf2d0929a9f984467ef95c7':
Fix a typo that caused the high quality resampler to produce garbage
61ea117b03b53382b5ecbc33004c7d37ea70ea8b 21-Oct-2012 Mathias Agopian <mathias@google.com> Fix a typo that caused the high quality resampler to produce garbage

the problem is that if libaudio_resampler is present, it is those
coefficients that will always be selected, but the correct
meta-data.

Bug: 7385994
Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621
udioResamplerSinc.cpp
ebed918320bdacdb225f679a8d7135d1acd3fe51 21-Oct-2012 Mathias Agopian <mathias@google.com> Fix a typo that caused the high quality resampler to produce garbage

the problem is that if libaudio_resampler is present, it is those
coefficients that will always be selected, but the correct
meta-data.

Bug: 7385994
Change-Id: Ieebeb37b4dfb62a1a051bc29fae2ce056dbc6621
udioResamplerSinc.cpp
d3eb71055a81cf405ae3fac8172d3fd592ed2e4b 19-Oct-2012 Glenn Kasten <gkasten@google.com> am 424b4a57: am 291f824e: Remove active track when thread goes to standby

* commit '424b4a57f5e1e8bd99cb619398389a467ec41f92':
Remove active track when thread goes to standby
4687da74717842852009df4787fe041ef8c935ef 19-Oct-2012 Glenn Kasten <gkasten@google.com> am 424b4a57: am 291f824e: Remove active track when thread goes to standby

* commit '424b4a57f5e1e8bd99cb619398389a467ec41f92':
Remove active track when thread goes to standby
291f824e02ff517a34cfe50220b4e2b402ee998d 19-Oct-2012 Glenn Kasten <gkasten@google.com> Remove active track when thread goes to standby

Bug: 7369232
Change-Id: I7ff9f525dad4be0aef562a53015b06ee7d3d50f1
udioFlinger.cpp
126c910f48a1e1b7a8044157d95f774d5e142316 19-Oct-2012 Glenn Kasten <gkasten@google.com> Remove active track when thread goes to standby

Bug: 7369232
Change-Id: I7ff9f525dad4be0aef562a53015b06ee7d3d50f1
udioFlinger.cpp
ca794bc9fb43f24addff4c1915d397269d1568ab 16-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am aa00830e: am bbe11e46: Merge "Fix track estimation for presentation complete" into jb-mr1-dev

* commit 'aa00830e46cb7494af7217246788c1bca83b1d04':
Fix track estimation for presentation complete
426ee0f6f828b01693f83780832c167b683c004f 16-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am aa00830e: am bbe11e46: Merge "Fix track estimation for presentation complete" into jb-mr1-dev

* commit 'aa00830e46cb7494af7217246788c1bca83b1d04':
Fix track estimation for presentation complete
a045dcafd2b77036210f5b72e79d745ad4c1b848 16-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix track estimation for presentation complete

Audio tracks were not using the right latency estimation for
signalling the completion of their presetation. This caused
the synchronization mechanism between playback and record to be
off, and a synchronized recording would contain some of the audio
that was meant to be over once recording would start.
Use the playback thread's latency reporting which takes the audio
pipe into account.

Bug 7237669

Change-Id: I23a907a53ad0b0d68d246789ec595a77a79fced5
udioFlinger.cpp
115b87ecf6182698b54055288d0f8710308b324d 16-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix track estimation for presentation complete

Audio tracks were not using the right latency estimation for
signalling the completion of their presetation. This caused
the synchronization mechanism between playback and record to be
off, and a synchronized recording would contain some of the audio
that was meant to be over once recording would start.
Use the playback thread's latency reporting which takes the audio
pipe into account.

Bug 7237669

Change-Id: I23a907a53ad0b0d68d246789ec595a77a79fced5
udioFlinger.cpp
b9c24111ecc135d47d563eaa3609730b6b4ee5e0 11-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am 0f95fadb: am 7e2c0a15: Merge "Support querying active record sources" into jb-mr1-dev

* commit '0f95fadb8a3ee402f2c51a932a06f1f685ab2d35':
Support querying active record sources
aa1890ff61b06c0f19ae5cf60720e351f62ba600 11-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am 0f95fadb: am 7e2c0a15: Merge "Support querying active record sources" into jb-mr1-dev

* commit '0f95fadb8a3ee402f2c51a932a06f1f685ab2d35':
Support querying active record sources
d7086030fcf731e4bcef6c033cc6418cd04e6b91 10-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> Support querying active record sources

Add support for querying whether there is currently a recording
underway from the specified audio source.

Bug 7314859

Change-Id: I986b231a10ffd368b08ec2f9c7f348d28eaeb892
udioPolicyService.cpp
udioPolicyService.h
e3f641fd9348bf7f4c07f6cc707347fccea1439c 10-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> Support querying active record sources

Add support for querying whether there is currently a recording
underway from the specified audio source.

Bug 7314859

Change-Id: I986b231a10ffd368b08ec2f9c7f348d28eaeb892
udioPolicyService.cpp
udioPolicyService.h
1e908f4d342f7c7f0535d254837fc2e95a535650 09-Oct-2012 Eric Laurent <elaurent@google.com> am 80dfc5dc: am 350d3b68: Merge "audio policy: deprecate ro.camera.sound.forced" into jb-mr1-dev

* commit '80dfc5dc7ec6d20beb0360e8efcc5331f4d25d06':
audio policy: deprecate ro.camera.sound.forced
915b08fe3e65c8391a60404c52c1f87a4499eaab 09-Oct-2012 Eric Laurent <elaurent@google.com> am 80dfc5dc: am 350d3b68: Merge "audio policy: deprecate ro.camera.sound.forced" into jb-mr1-dev

* commit '80dfc5dc7ec6d20beb0360e8efcc5331f4d25d06':
audio policy: deprecate ro.camera.sound.forced
bac4a4a9073a440bc6df7ca2306604819aa1c342 09-Oct-2012 Eric Laurent <elaurent@google.com> audio policy: deprecate ro.camera.sound.forced

The volume and routing policy of AUDIO_STREAM_ENFORCED_AUDIBLE is
now controlled by AudioService.

Do not read ro.camera.sound.forced is not needed anymore.

Bug 7032634.

Change-Id: Ic0a6396fc4b6efb91cdb4dffe0c8eb035d0440bd
udioPolicyService.cpp
116bc97164e0fa836744f31e54779b5a7a8c9db4 09-Oct-2012 Eric Laurent <elaurent@google.com> audio policy: deprecate ro.camera.sound.forced

The volume and routing policy of AUDIO_STREAM_ENFORCED_AUDIBLE is
now controlled by AudioService.

Do not read ro.camera.sound.forced is not needed anymore.

Bug 7032634.

Change-Id: Ic0a6396fc4b6efb91cdb4dffe0c8eb035d0440bd
udioPolicyService.cpp
9c54cca8444bd00bba5173815d3029d45f244960 08-Oct-2012 ty.lee <ty.lee@lge.com> am 6f45866e: am c8823995: audioflinger/resampler: add build source for libaudio-resampler

* commit '6f45866e8a942b2a8a21c75708a717b0c8a8f120':
audioflinger/resampler: add build source for libaudio-resampler
a3bdbdca6772a43cb63b70bbede8dea8359bc6cc 08-Oct-2012 ty.lee <ty.lee@lge.com> am 6f45866e: am c8823995: audioflinger/resampler: add build source for libaudio-resampler

* commit '6f45866e8a942b2a8a21c75708a717b0c8a8f120':
audioflinger/resampler: add build source for libaudio-resampler
c8823995d16b909fae30ff4f94217e875d3e8c8a 01-Oct-2012 ty.lee <ty.lee@lge.com> audioflinger/resampler: add build source for libaudio-resampler

Bug: 7229644
Change-Id: I93bde36be1c3ec84174a4c98423e28f8b3d8782f
Signed-off-by: ty.lee <ty.lee@lge.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
ndroid.mk
2b5232dd49d006a08c35ba865a6801acdb15483c 01-Oct-2012 ty.lee <ty.lee@lge.com> audioflinger/resampler: add build source for libaudio-resampler

Bug: 7229644
Change-Id: I93bde36be1c3ec84174a4c98423e28f8b3d8782f
Signed-off-by: ty.lee <ty.lee@lge.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
ndroid.mk
ea967355de0b985c8111abd57a23f566fe355260 04-Oct-2012 Glenn Kasten <gkasten@google.com> resolved conflicts for merge of f12b1c81 to master

Change-Id: I914a11706bd01a198e2137e0c12af0fc92ffa02b
d192e5f15c395daa87f4f198154379ee7c93d528 04-Oct-2012 Glenn Kasten <gkasten@google.com> resolved conflicts for merge of f12b1c81 to master

Change-Id: I914a11706bd01a198e2137e0c12af0fc92ffa02b
ac6020508acedd316391dee42329040bf45f8d90 01-Oct-2012 Glenn Kasten <gkasten@google.com> Integrate improved coefficient sinc resampler: VHQ

Summary:
Very high quality is enabled only for 44.1 -> 48 or 48 -> 44.1,
and uses low quality for all other use cases.
Track estimated CPU load and throttles the quality based on load;
as currently configured it should allow up to 2 instances of very high quality.
Medium quality and high quality are currently disabled unless explicitly requested.

Details:
Only load .so the first time it is needed.
Cleanup code style: formatting, indentation, whitespace.
Restore medium quality resampler, but it is not used (see next line).
Fix memory leak for sinc resampler.
Check sample rate in resampler constructor.
Add logs for debugging.
Rename DEFAULT to DEFAULT_QUALITY for consistency with other quality levels.
Renumber VERY_HIGH_QUALITY from 255 to 4.
Use enum src_quality consistently.
Improve parsing of property af.resampler.quality.
Fix reentrancy bug - allow an instance of high quality and an instance
of very high quality to both be active concurrently.

Bug: 7229644
Change-Id: I0ce6b913b05038889f50462a38830b61a602a9f7
ndroid.mk
udioMixer.cpp
udioResampler.cpp
udioResampler.h
udioResamplerCubic.h
udioResamplerSinc.cpp
udioResamplerSinc.h
a6d41334d25ffde12484eb28301352560a063ef6 01-Oct-2012 Glenn Kasten <gkasten@google.com> Integrate improved coefficient sinc resampler: VHQ

Summary:
Very high quality is enabled only for 44.1 -> 48 or 48 -> 44.1,
and uses low quality for all other use cases.
Track estimated CPU load and throttles the quality based on load;
as currently configured it should allow up to 2 instances of very high quality.
Medium quality and high quality are currently disabled unless explicitly requested.

Details:
Only load .so the first time it is needed.
Cleanup code style: formatting, indentation, whitespace.
Restore medium quality resampler, but it is not used (see next line).
Fix memory leak for sinc resampler.
Check sample rate in resampler constructor.
Add logs for debugging.
Rename DEFAULT to DEFAULT_QUALITY for consistency with other quality levels.
Renumber VERY_HIGH_QUALITY from 255 to 4.
Use enum src_quality consistently.
Improve parsing of property af.resampler.quality.
Fix reentrancy bug - allow an instance of high quality and an instance
of very high quality to both be active concurrently.

Bug: 7229644
Change-Id: I0ce6b913b05038889f50462a38830b61a602a9f7
ndroid.mk
udioMixer.cpp
udioResampler.cpp
udioResampler.h
udioResamplerCubic.h
udioResamplerSinc.cpp
udioResamplerSinc.h
c704ce6c0101f4933587fb2799618fb55e80f69a 01-Oct-2012 Glenn Kasten <gkasten@google.com> am 14bab416: am 087dd8e7: Disable audio watchdog

* commit '14bab41620ed8e667c79242e5ad0f4bd84264758':
Disable audio watchdog
f1aa6eb20be602a43ea478957fc8e6d5098cfde4 01-Oct-2012 Glenn Kasten <gkasten@google.com> am 14bab416: am 087dd8e7: Disable audio watchdog

* commit '14bab41620ed8e667c79242e5ad0f4bd84264758':
Disable audio watchdog
0033ac1b0c2258077ad60792b5c60807b359fd0e 01-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am 7fff6091: am 7165491b: Merge "bug 7253033 clean up before closing an output" into jb-mr1-dev

* commit '7fff6091174451170912099954725c8109f4c559':
bug 7253033 clean up before closing an output
a98a900f58d297d71621fb80afcb7d291bbb50db 01-Oct-2012 Jean-Michel Trivi <jmtrivi@google.com> am 7fff6091: am 7165491b: Merge "bug 7253033 clean up before closing an output" into jb-mr1-dev

* commit '7fff6091174451170912099954725c8109f4c559':
bug 7253033 clean up before closing an output
087dd8e7232e4c009e9121ab7e8c37985522c9ad 27-Sep-2012 Glenn Kasten <gkasten@google.com> Disable audio watchdog

It's not critical, and is wasting power

Bug: 7241714
Change-Id: I6ad4375f0000c92529688723dbe0ff0caa809c5d
ndroid.mk
udioFlinger.cpp
02e5dbb025bf164f0b273f01a114ddc497798823 27-Sep-2012 Glenn Kasten <gkasten@google.com> Disable audio watchdog

It's not critical, and is wasting power

Bug: 7241714
Change-Id: I6ad4375f0000c92529688723dbe0ff0caa809c5d
ndroid.mk
udioFlinger.cpp
2fa114de80a5f6afd2055054a163c6d7e2ef71bc 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
395f2c8dd0d4b87c5b31cfa838885ae8169adff8 27-Sep-2012 Iliyan Malchev <malchev@google.com> am 33afc99b: am 6d6a4d3f: Merge changes Ia4414241,I34f5d36a into jb-mr1-dev

* commit '33afc99b78977ab94ba3fe86f485c6e2a33563aa':
audioflinger: use resample coefficients from audio-resampler library.
audioflinger/resampler: Add VERY_HIGH_QUALITY audio-resampler
f40c239e645b4e1afca3df9a022715b4056e7111 27-Sep-2012 Iliyan Malchev <malchev@google.com> am 33afc99b: am 6d6a4d3f: Merge changes Ia4414241,I34f5d36a into jb-mr1-dev

* commit '33afc99b78977ab94ba3fe86f485c6e2a33563aa':
audioflinger: use resample coefficients from audio-resampler library.
audioflinger/resampler: Add VERY_HIGH_QUALITY audio-resampler
41dfd129a181a5b0b62628733cf96e0ce11d64d7 17-Jan-2012 SathishKumar Mani <smani@codeaurora.org> audioflinger: use resample coefficients from audio-resampler library.

-Add a separate quality VERY_HIGH_QUALITY in resampler
-Use resample coefficients audio-resampler library for
quality VERY_HIGH_QUALITY.
-This improves the quality of resampled output.

Bug: 7024293
Change-Id: Ia44142413bed5f5963d7eab7846eec877a2415e4
Signed-off-by: Iliyan Malchev <malchev@google.com>
ndroid.mk
udioResampler.cpp
udioResampler.h
udioResamplerSinc.cpp
udioResamplerSinc.h
76b111685010e1fea7c0a865c038aee35507fde4 17-Jan-2012 SathishKumar Mani <smani@codeaurora.org> audioflinger: use resample coefficients from audio-resampler library.

-Add a separate quality VERY_HIGH_QUALITY in resampler
-Use resample coefficients audio-resampler library for
quality VERY_HIGH_QUALITY.
-This improves the quality of resampled output.

Bug: 7024293
Change-Id: Ia44142413bed5f5963d7eab7846eec877a2415e4
Signed-off-by: Iliyan Malchev <malchev@google.com>
ndroid.mk
udioResampler.cpp
udioResampler.h
udioResamplerSinc.cpp
udioResamplerSinc.h
f818ccfbbfc574d179c4639af6b41c83c368a699 24-Sep-2012 SathishKumar Mani <smani@codeaurora.org> audioflinger/resampler: Add VERY_HIGH_QUALITY audio-resampler

Change-Id: I34f5d36ae60010ec64222d6660d10a84da3bf566
Bug: 7024293
Signed-off-by: Iliyan Malchev <malchev@google.com>
udio-resampler/Android.mk
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/resampler_filter_coefficients_10042011.h
12bff5dd87e6b863482e6bfd9f4561078ebcf3f0 24-Sep-2012 SathishKumar Mani <smani@codeaurora.org> audioflinger/resampler: Add VERY_HIGH_QUALITY audio-resampler

Change-Id: I34f5d36ae60010ec64222d6660d10a84da3bf566
Bug: 7024293
Signed-off-by: Iliyan Malchev <malchev@google.com>
udio-resampler/Android.mk
udio-resampler/AudioResamplerCoefficients.cpp
udio-resampler/dnsampler_filter_coefficients_x128_10112011.h
udio-resampler/resampler_filter_coefficients_10042011.h
7ab148fd703107f8f4d64483d1f03986bed3f38d 26-Sep-2012 Glenn Kasten <gkasten@google.com> am 070936d0: am 842c5d95: Revert "Don\'t wait for presentation complete if terminated"

* commit '070936d0530b535ccc9b404872f8333368bbfb02':
Revert "Don't wait for presentation complete if terminated"
fc417dc27adee8421eae1c6f506993e9a0cf2c4e 26-Sep-2012 Glenn Kasten <gkasten@google.com> am 070936d0: am 842c5d95: Revert "Don\'t wait for presentation complete if terminated"

* commit '070936d0530b535ccc9b404872f8333368bbfb02':
Revert "Don't wait for presentation complete if terminated"
52013e7ad02bd22b19a64bdccaa953c7b4b4d448 26-Sep-2012 Glenn Kasten <gkasten@google.com> Revert "Don't wait for presentation complete if terminated"

This reverts commit 44cda3a4e7ca3de0db9cb49145def3803b03ebb4

Change-Id: I7fd29b77690dab057ac966a42fb198b2772f092c
udioFlinger.cpp
842c5d9553f3f8e97d04ed1bd0d37e4851240654 26-Sep-2012 Glenn Kasten <gkasten@google.com> Revert "Don't wait for presentation complete if terminated"

This reverts commit 44cda3a4e7ca3de0db9cb49145def3803b03ebb4

Change-Id: I7fd29b77690dab057ac966a42fb198b2772f092c
udioFlinger.cpp
2de3067ebf718007c4bacd3df4fba6f070c1538b 26-Sep-2012 Glenn Kasten <gkasten@google.com> am 512ba315: am cc0f1cfb: Implement android.media.AudioManager.getProperty()

* commit '512ba3150d45803ebadbefe45977a5eeed323540':
Implement android.media.AudioManager.getProperty()
a4b3b7df111099ae6ce4996c6ff8ea586614e0b4 26-Sep-2012 Glenn Kasten <gkasten@google.com> am 512ba315: am cc0f1cfb: Implement android.media.AudioManager.getProperty()

* commit '512ba3150d45803ebadbefe45977a5eeed323540':
Implement android.media.AudioManager.getProperty()
4c6db4ce1e2760682d1c9e66448dbb39bb5d14d8 24-Sep-2012 Glenn Kasten <gkasten@google.com> Implement android.media.AudioManager.getProperty()

Bug: 6635041
Change-Id: I3386a4a6c226bc4eceaf65556119e4fb15f73224
udioFlinger.cpp
udioFlinger.h
cc0f1cfb69ce8b8985fc2c0984847a06a13ad22d 24-Sep-2012 Glenn Kasten <gkasten@google.com> Implement android.media.AudioManager.getProperty()

Bug: 6635041
Change-Id: I3386a4a6c226bc4eceaf65556119e4fb15f73224
udioFlinger.cpp
udioFlinger.h
aeda50a708e41a000c509ee52cc6876ec48c191c 25-Sep-2012 Eric Laurent <elaurent@google.com> am 4680802d: am b6ba2fd0: audioflinger: improve record start and thread exit

* commit '4680802d540379fda8a831167d8e7f2067327d90':
audioflinger: improve record start and thread exit
19dedfe04206b9d8044cb86bb2ed9dc30a26b9b5 25-Sep-2012 Eric Laurent <elaurent@google.com> am 4680802d: am b6ba2fd0: audioflinger: improve record start and thread exit

* commit '4680802d540379fda8a831167d8e7f2067327d90':
audioflinger: improve record start and thread exit
67d8ac3a8b49b114366684cd6310493423581056 25-Sep-2012 Eric Laurent <elaurent@google.com> audioflinger: improve record start and thread exit

Use broadcast() instead of signal() on the
thread wake up condition when starting record or requesting thread
exit to make sure that if another thread is waiting for the same
condition (e.g binder thread calling setParameters()) the mixer
thread will be woken up.

Bug 7184317.

Change-Id: I3154a4509ca7af6ffae5236e522b0fab8e75ed06
udioFlinger.cpp
b6ba2fd0d61a4844c153e17843fbe2c841c4bf57 25-Sep-2012 Eric Laurent <elaurent@google.com> audioflinger: improve record start and thread exit

Use broadcast() instead of signal() on the
thread wake up condition when starting record or requesting thread
exit to make sure that if another thread is waiting for the same
condition (e.g binder thread calling setParameters()) the mixer
thread will be woken up.

Bug 7184317.

Change-Id: I3154a4509ca7af6ffae5236e522b0fab8e75ed06
udioFlinger.cpp
ca301b7ec0a2a005a924d1cc7a4e988843722055 24-Sep-2012 Glenn Kasten <gkasten@google.com> am 6aee72a4: am 8d452f1c: Merge "Check clock_gettime(CLOCK_MONOTONIC) for failure" into jb-mr1-dev

* commit '6aee72a479afb15498a4dc31327c5d5ff7ee4294':
Check clock_gettime(CLOCK_MONOTONIC) for failure
eb2ef90381ea42617f6a04b9356f5b5bf1ce4f5c 24-Sep-2012 Glenn Kasten <gkasten@google.com> am 6aee72a4: am 8d452f1c: Merge "Check clock_gettime(CLOCK_MONOTONIC) for failure" into jb-mr1-dev

* commit '6aee72a479afb15498a4dc31327c5d5ff7ee4294':
Check clock_gettime(CLOCK_MONOTONIC) for failure
7ca821d51972bb83fa900cf2206ae98f29b33ca9 24-Sep-2012 Glenn Kasten <gkasten@google.com> Merge "Check clock_gettime(CLOCK_MONOTONIC) for failure" into jb-mr1-dev
8d452f1c61aa70c4a86c4114532f2c0983120ef8 24-Sep-2012 Glenn Kasten <gkasten@google.com> Merge "Check clock_gettime(CLOCK_MONOTONIC) for failure" into jb-mr1-dev
99ae06be60d7ccd753a0808191583225e5533f3a 24-Sep-2012 Glenn Kasten <gkasten@google.com> Check clock_gettime(CLOCK_MONOTONIC) for failure

Bug: 7100774
Change-Id: I15a84a19bb6d6ef1d9dac4beaa03587638196404
astMixer.cpp
80b3273cea8660fe8a5868d024d2788a1e083ffc 24-Sep-2012 Glenn Kasten <gkasten@google.com> Check clock_gettime(CLOCK_MONOTONIC) for failure

Bug: 7100774
Change-Id: I15a84a19bb6d6ef1d9dac4beaa03587638196404
astMixer.cpp
b777b2757b299c5fdb26d729ce405ab5b1c698ec 24-Sep-2012 Eric Laurent <elaurent@google.com> am 842feefd: am c0c3b298: Merge "fix end of track presentation on suspended output" into jb-mr1-dev

* commit '842feefd25f3ac03de3cd9bcc5bc7627abec6ebc':
fix end of track presentation on suspended output
d4c1f2b55688fafabd468cd5b316dea636d7b4b8 24-Sep-2012 Eric Laurent <elaurent@google.com> am 842feefd: am c0c3b298: Merge "fix end of track presentation on suspended output" into jb-mr1-dev

* commit '842feefd25f3ac03de3cd9bcc5bc7627abec6ebc':
fix end of track presentation on suspended output
6090a17389fc86ec6d7b16b358c540fa6627923f 24-Sep-2012 Eric Laurent <elaurent@google.com> fix end of track presentation on suspended output

The code detecting the end of an audio track presentation before
removing it from the active track list is based on the
count of audio frames sent to audio HAL. When an output stream
is suspended (e.g. A2DP when SCO is active), this count does not
change and a track in stopped state will never be removed from
active track list causing the mixer thread to never release
the wake lock.

The fix consists in incrementing the audio HAL frame count even
if the output is suspended.

Also fix a problem in getRenderPosition() when the output is suspended.

Bug 7167534.

Change-Id: I3be836cbbea29b65dc087199cac6a1cd84c0a41d
udioFlinger.cpp
1afc26db11b71c43f63a0f72a45a803f1a7910dd 24-Sep-2012 Eric Laurent <elaurent@google.com> fix end of track presentation on suspended output

The code detecting the end of an audio track presentation before
removing it from the active track list is based on the
count of audio frames sent to audio HAL. When an output stream
is suspended (e.g. A2DP when SCO is active), this count does not
change and a track in stopped state will never be removed from
active track list causing the mixer thread to never release
the wake lock.

The fix consists in incrementing the audio HAL frame count even
if the output is suspended.

Also fix a problem in getRenderPosition() when the output is suspended.

Bug 7167534.

Change-Id: I3be836cbbea29b65dc087199cac6a1cd84c0a41d
udioFlinger.cpp
1cbb9253100d428e52330cc71f09db08cfdcf6ae 14-Sep-2012 Eric Laurent <elaurent@google.com> am 01dcf4de: am 896adcd3: audioflinger: send priority request from a thread

* commit '01dcf4de81ed0f9b6942dea2787463bf9c945a37':
audioflinger: send priority request from a thread
6adeb50d4b320c235c4ad1e334493eb174eaeeda 14-Sep-2012 Eric Laurent <elaurent@google.com> am 01dcf4de: am 896adcd3: audioflinger: send priority request from a thread

* commit '01dcf4de81ed0f9b6942dea2787463bf9c945a37':
audioflinger: send priority request from a thread
550f0bc9cbe8ea44b380eafa2ee674c62d10b819 14-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> am 868bb58e: am 4362f530: Handle audio HAL returning 0 bytes in record thread

* commit '868bb58ed5873edb1d138f82d4751823ef433ebb':
Handle audio HAL returning 0 bytes in record thread
cb48dcf506e8ed9fbc5fae449ff014e495dff67d 14-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> am 868bb58e: am 4362f530: Handle audio HAL returning 0 bytes in record thread

* commit '868bb58ed5873edb1d138f82d4751823ef433ebb':
Handle audio HAL returning 0 bytes in record thread
ef6be0bb71c08db7e9e9274d70edffb95f0da25f 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
3fc73b477cba93ff74e46d93ed40ebe1cfced138 13-Sep-2012 Eric Laurent <elaurent@google.com> am 6777e539: am f4bca03d: Merge "Don\'t deadlock on AudioRecord start when reads return 0" into jb-mr1-dev

* commit '6777e539f0479ed8ca13bfeed63edf9402b00655':
Don't deadlock on AudioRecord start when reads return 0
2fb740c2335a3321deb46b5120b77e61bf702016 13-Sep-2012 Eric Laurent <elaurent@google.com> am 6777e539: am f4bca03d: Merge "Don\'t deadlock on AudioRecord start when reads return 0" into jb-mr1-dev

* commit '6777e539f0479ed8ca13bfeed63edf9402b00655':
Don't deadlock on AudioRecord start when reads return 0
89b4470bc926c4b5de59deaff2b6a4993ab6cab7 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Handle audio HAL returning 0 bytes in record thread

Enter standby when HAL returns an error, but also consider 0 bytes
returned as NOT_ENOUGH_DATA.

Change-Id: Ica83142310e9c176f936e0440571a6034cbc575f
udioFlinger.cpp
4362f5300162ed55f56cf167eccf7f2e5b89d435 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Handle audio HAL returning 0 bytes in record thread

Enter standby when HAL returns an error, but also consider 0 bytes
returned as NOT_ENOUGH_DATA.

Change-Id: Ica83142310e9c176f936e0440571a6034cbc575f
udioFlinger.cpp
063c1eac60d7cee5d6f1ee61a10f0b6027782357 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix build in AudioFlinger/FastMixer

Commit was missing some changes to modifications to send session ID
from AudioFlinger to AudioMixer.

Change-Id: I7daeaf4eff243b5287bef63be86a87acf408374a
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
43ed5337f3eaa909ad2e87df0ccd061c3e6d0096 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix build in AudioFlinger/FastMixer

Commit was missing some changes to modifications to send session ID
from AudioFlinger to AudioMixer.

Change-Id: I7daeaf4eff243b5287bef63be86a87acf408374a
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
607364600e4f6ef8bebec8958e16e7fb0bcb7d25 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Don't deadlock on AudioRecord start when reads return 0

When calling start() on an AudioRecord with a HAL that
returns 0 on a read() operation, the start blocking
condition was never unblocked.
Add a boolean to track the first read operation so the returned
number of bytes (mBytesRead) is only evaluated after that
first read.

Change-Id: I8c735a00d48cd6a0da467ccdf75d3616b38f6afa
udioFlinger.cpp
52762410dbc9189cd92a4094a1dbd4cfe8e71cb6 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Don't deadlock on AudioRecord start when reads return 0

When calling start() on an AudioRecord with a HAL that
returns 0 on a read() operation, the start blocking
condition was never unblocked.
Add a boolean to track the first read operation so the returned
number of bytes (mBytesRead) is only evaluated after that
first read.

Change-Id: I8c735a00d48cd6a0da467ccdf75d3616b38f6afa
udioFlinger.cpp
a59d27196cc411331efbcce5dde817c7273a64c3 13-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: I836873eebd6711f1048fce81cd2eb29b94f0ad0c
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
d06e132358d44f02c22527b4f463df1f58da9216 13-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: I836873eebd6711f1048fce81cd2eb29b94f0ad0c
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
cff7137411e737dfb783013c23841ccb335e5f5b 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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
astMixer.cpp
9b827b72202038a321a9b038165971bed042311c 11-Sep-2012 Glenn Kasten <gkasten@google.com> am f53e33fb: am 6ce3d19c: Merge "Add outlier statistics for fast mixer cycle times" into jb-mr1-dev

* commit 'f53e33fbb03f7de07d79f5f99f73d7b2d0bbed03':
Add outlier statistics for fast mixer cycle times
240d637c7da00dd89648b96581154b514e2770e5 11-Sep-2012 Glenn Kasten <gkasten@google.com> am f53e33fb: am 6ce3d19c: Merge "Add outlier statistics for fast mixer cycle times" into jb-mr1-dev

* commit 'f53e33fbb03f7de07d79f5f99f73d7b2d0bbed03':
Add outlier statistics for fast mixer cycle times
644f98718e604a58545918d99b1438e12b3a973f 11-Sep-2012 Eric Laurent <elaurent@google.com> am 1fbb83b6: am 85396642: Merge "audioflinger: changes for new audio devices enums" into jb-mr1-dev

* commit '1fbb83b665720f2629d7a3759a0a7b61b4f04571':
audioflinger: changes for new audio devices enums
75ed25a60f65e2239c1e9e480297559825fffe8f 11-Sep-2012 Eric Laurent <elaurent@google.com> am 1fbb83b6: am 85396642: Merge "audioflinger: changes for new audio devices enums" into jb-mr1-dev

* commit '1fbb83b665720f2629d7a3759a0a7b61b4f04571':
audioflinger: changes for new audio devices enums
b89909df83e55af1726ebc97d1a5ecb4905a91ef 09-Sep-2012 Glenn Kasten <gkasten@google.com> Merge "Add outlier statistics for fast mixer cycle times" into jb-mr1-dev
6ce3d19cd35a49add6893298f70b87917fc60d52 09-Sep-2012 Glenn Kasten <gkasten@google.com> Merge "Add outlier statistics for fast mixer cycle times" into jb-mr1-dev
ba8a616c39259e98094440e9656a49a1cc96c976 07-Sep-2012 Glenn Kasten <gkasten@google.com> Add outlier statistics for fast mixer cycle times

Change-Id: I31c964caeb8b5d9ae0a426224f030cdcb01114a0
astMixer.cpp
1ab212cf5cfa5b88c801840e11e3191cd10f48e4 07-Sep-2012 Glenn Kasten <gkasten@google.com> Add outlier statistics for fast mixer cycle times

Change-Id: I31c964caeb8b5d9ae0a426224f030cdcb01114a0
astMixer.cpp
8895925e38d2521607fd2010f3f3b14ecd15962c 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
6a9fa853b13e854793a9ae85adf6bb2c78c81dd5 07-Sep-2012 Eric Laurent <elaurent@google.com> am e1659521: am d06ab147: Merge "AudioFlinger: send audio source to audio effects" into jb-mr1-dev

* commit 'e16595211299534fe1b1986f66d55d250ffc1fea':
AudioFlinger: send audio source to audio effects
ad42039eaefa06fff6cd957bcae196f087364c09 07-Sep-2012 Eric Laurent <elaurent@google.com> am e1659521: am d06ab147: Merge "AudioFlinger: send audio source to audio effects" into jb-mr1-dev

* commit 'e16595211299534fe1b1986f66d55d250ffc1fea':
AudioFlinger: send audio source to audio effects
2e9b0f24e7089fb23356871b2fdce771c2dae852 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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
8cd6a4a8199a84270231ca1f9212070b35e72815 31-Aug-2012 Glenn Kasten <gkasten@google.com> am 08d8228d: am b3428f7f: Merge "Update audio comments" into jb-mr1-dev

* commit '08d8228d508adf26e1e6bdf44401ee3b7fcca22f':
Update audio comments
0f7d1771689280dd32eec4a301d2781fa9172baa 31-Aug-2012 Glenn Kasten <gkasten@google.com> am 08d8228d: am b3428f7f: Merge "Update audio comments" into jb-mr1-dev

* commit '08d8228d508adf26e1e6bdf44401ee3b7fcca22f':
Update audio comments
2662ac9220c9e07cd343e78bf3a0c21ca3e4ffd1 30-Jul-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
udioFlinger.cpp
udioFlinger.h
c3ae93f21280859086ae371428ffd32f39e76d50 30-Jul-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
udioFlinger.cpp
udioFlinger.h
fdca11917d73c21971054aa8cb9fc9ae28fa3164 31-Aug-2012 Glenn Kasten <gkasten@google.com> am b5720b1f: am c9936c72: Merge "Remove dead code" into jb-mr1-dev

* commit 'b5720b1ff9262419cd331e56c75a60b291bc7694':
Remove dead code
49a3f8a8b4ec226690e7b5c91a7e516970ca6d0b 31-Aug-2012 Glenn Kasten <gkasten@google.com> am b5720b1f: am c9936c72: Merge "Remove dead code" into jb-mr1-dev

* commit 'b5720b1ff9262419cd331e56c75a60b291bc7694':
Remove dead code
7f7d27eb0ee5dc7b0f52dd2c89791d14bfe82f29 03-Aug-2012 Glenn Kasten <gkasten@google.com> Remove dead code

RecordThread::isValidSyncEvent() returns false, so most of
RecordThread::setSyncEvent() is never executed.

Change-Id: I0cf848beb46a367a45126d2df3073c5afa2ca59c
udioFlinger.cpp
7aa25591769685ae0e8349b3ca3534c724484375 03-Aug-2012 Glenn Kasten <gkasten@google.com> Remove dead code

RecordThread::isValidSyncEvent() returns false, so most of
RecordThread::setSyncEvent() is never executed.

Change-Id: I0cf848beb46a367a45126d2df3073c5afa2ca59c
udioFlinger.cpp
b0dc8b57c7cc39a057170a0d1e5842bd866b1775 31-Aug-2012 Glenn Kasten <gkasten@google.com> am c9beb01c: am b9cba9b7: Merge "Move libnbaio out of AudioFlinger" into jb-mr1-dev

* commit 'c9beb01c800e6326051aee52a00659288c25c6eb':
Move libnbaio out of AudioFlinger
e0c87269b94e5b24de8e9577ba32070b24e83582 31-Aug-2012 Glenn Kasten <gkasten@google.com> am c9beb01c: am b9cba9b7: Merge "Move libnbaio out of AudioFlinger" into jb-mr1-dev

* commit 'c9beb01c800e6326051aee52a00659288c25c6eb':
Move libnbaio out of AudioFlinger
fc7992bd8220824f1404c0c54ac516d9e28b58c2 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
ndroid.mk
udioBufferProvider.h
udioBufferProviderSource.cpp
udioBufferProviderSource.h
udioFlinger.cpp
udioFlinger.h
udioMixer.h
udioResampler.h
udioStreamInSource.cpp
udioStreamInSource.h
udioStreamOutSink.cpp
udioStreamOutSink.h
xtendedAudioBufferProvider.h
astMixerState.h
ibsndfileSink.cpp
ibsndfileSink.h
ibsndfileSource.cpp
ibsndfileSource.h
onoPipe.cpp
onoPipe.h
onoPipeReader.cpp
onoPipeReader.h
BAIO.cpp
BAIO.h
ipe.cpp
ipe.h
ipeReader.cpp
ipeReader.h
ourceAudioBufferProvider.cpp
ourceAudioBufferProvider.h
oundup.c
oundup.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
ndroid.mk
udioBufferProvider.h
udioBufferProviderSource.cpp
udioBufferProviderSource.h
udioFlinger.cpp
udioFlinger.h
udioMixer.h
udioResampler.h
udioStreamInSource.cpp
udioStreamInSource.h
udioStreamOutSink.cpp
udioStreamOutSink.h
xtendedAudioBufferProvider.h
astMixerState.h
ibsndfileSink.cpp
ibsndfileSink.h
ibsndfileSource.cpp
ibsndfileSource.h
onoPipe.cpp
onoPipe.h
onoPipeReader.cpp
onoPipeReader.h
BAIO.cpp
BAIO.h
ipe.cpp
ipe.h
ipeReader.cpp
ipeReader.h
ourceAudioBufferProvider.cpp
ourceAudioBufferProvider.h
oundup.c
oundup.h
4aa73099649056a39bd37e090c1fedd07c1ccbd5 22-Aug-2012 Glenn Kasten <gkasten@google.com> am 916ecd0a: am 0c676cd0: Make tee sink compile OK again

* commit '916ecd0acb4c12568d029c027a7626fc422bd84c':
Make tee sink compile OK again
0c676cd04ff15cc7eacf6144b4aead6deaccf60c 22-Aug-2012 Glenn Kasten <gkasten@google.com> Make tee sink compile OK again

Change-Id: Ie865ceeabaeb698a62c11eac9f96e303c44c28ae
ipeReader.cpp
ipeReader.h
b45786becf800ae7c36939c7bc92f54fe8253147 13-Aug-2012 Glenn Kasten <gkasten@google.com> am a6a266d0: am 106e8a42: const methods

* commit 'a6a266d0e148f085ac1f83c4a36d3cf940c59e24':
const methods
2ef6e196198b3c2961e7fbf4637a70d6b38085ca 13-Aug-2012 Glenn Kasten <gkasten@google.com> am 0319e9e3: am 0dbb3560: Simplify AudioFlinger::PlaybackThread::isValidSyncEvent()

* commit '0319e9e31cb7b0033a3026b0305b78e2d48c6ec8':
Simplify AudioFlinger::PlaybackThread::isValidSyncEvent()
106e8a42038f9e90d5ff97f8ab6f1a42258bde9e 02-Aug-2012 Glenn Kasten <gkasten@google.com> const methods

Change-Id: I92e32ee16274c032c9d0ce910676be2a7fa52471
udioFlinger.cpp
udioFlinger.h
bfb3fec3341889226c66d72ab926c7de9553a125 13-Aug-2012 Glenn Kasten <gkasten@google.com> am b2f2d164: am d23eedca: Discard setSyncEvent() return value

* commit 'b2f2d1644b9d1a823fc3b78a59893652b080b35d':
Discard setSyncEvent() return value
0dbb356050d0db9e0043dd43045c1864a933332b 03-Aug-2012 Glenn Kasten <gkasten@google.com> Simplify AudioFlinger::PlaybackThread::isValidSyncEvent()

Change-Id: I3e4af69b929d4ca04afaac26c7e41c89fce25b9c
udioFlinger.cpp
2917080826e0d7cec47e8ec8891e9ee1c2535d6a 13-Aug-2012 Glenn Kasten <gkasten@google.com> am f0235625: am a9599049: Merge "Replace hard-coded "2" by a constant and comment" into jb-mr1-dev

* commit 'f02356254262ec4a56e5ec1b1abefe1849ba9f9d':
Replace hard-coded "2" by a constant and comment
d23eedca9b5a1812891c05d89850ab7ee707040d 02-Aug-2012 Glenn Kasten <gkasten@google.com> Discard setSyncEvent() return value

setSyncEvent() returns a status_t which is sometimes ignored.
Emphasize this is intentional by casting to void.

Change-Id: Ic614988347cba36bd2504d7ad321594a355b0d9d
udioFlinger.cpp
a959904968f1d300fe86334bf5099ae2dc39ee28 13-Aug-2012 Glenn Kasten <gkasten@google.com> Merge "Replace hard-coded "2" by a constant and comment" into jb-mr1-dev
037ac53aac0f51f2ccfaaa91822365c1c73c4365 10-Aug-2012 Jean-Baptiste Queru <jbq@google.com> am 0efd0358: am fcfc61da: am ff4c64d6: am c64a1787: Merge "Fix initialization of audio mixer track resources for MIPS."

* commit '0efd035854ad2c8d20100a740e054c4bf7b3e9a4':
Fix initialization of audio mixer track resources for MIPS.
fcfc61da927e98d18cdcb53da8fa0a8a32ee1422 10-Aug-2012 Jean-Baptiste Queru <jbq@google.com> am ff4c64d6: am c64a1787: Merge "Fix initialization of audio mixer track resources for MIPS."

* commit 'ff4c64d6b1b58494a1b15f1a664e5c421d095d15':
Fix initialization of audio mixer track resources for MIPS.
3ed292031dc50c56110cdadb1e3778117e3be76a 08-Aug-2012 Glenn Kasten <gkasten@google.com> Replace hard-coded "2" by a constant and comment

Bug: 6679403
Change-Id: I6c2701f9afedc26540dfad0b4e23348bbc4cb01a
udioFlinger.cpp
e75640c4b06a5715622eeffd8d204f811284fd8c 09-Aug-2012 Glenn Kasten <gkasten@google.com> am 638f936d: am 0d27c65d: Tune the overrun correction

* commit '638f936d4dd0d4afdc952988ac6b6a9dcbb577e7':
Tune the overrun correction
3c507a754788872bdc19aa651180447c5456f191 09-Aug-2012 John Grossman <johngro@google.com> am acc5c275: am f6a35760: Merge "AudioFlinger: fix timed audio" into jb-mr1-dev

* commit 'acc5c275f6affe789184436b7d40fb1656a4596f':
AudioFlinger: fix timed audio
0d27c65ddb5c968baa6db0c26e80f5c451bc52bc 07-Aug-2012 Glenn Kasten <gkasten@google.com> Tune the overrun correction

The new overrun correction is: if the previous write() cycle time is <
50% of expected, then sleep enough extra to make the total cycle time =
95% of expected. This should help compensate for HAL implementations
that have uneven cycle times due to sample rate conversion.

Bug: 6881638
Change-Id: I5ab58afdfceee7ac523177f021fbf62d743d571a
astMixer.cpp
2c3b2da3049627264b7c6b449a1622f002210f03 03-Aug-2012 John Grossman <johngro@google.com> AudioFlinger: fix timed audio

(cherry picked from commit e20ac92c564a2f4e8123885807abdf0a78de0dd7)

> AudioFlinger: fix timed audio
>
> Addresses Bug 6900517.
>
> Finish up support for timed audio in the new FastMixer world. Pay special
> attention to remaining lock-less and voluntary yield free on the FastMixer
> thread. This fixes audio playback for Q on JB.
>
> Change-Id: Iaf815e58a1b1d0a0190051794bec8dc5c9231785
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: I9bd687acc345a05867af48e71116690fdb0ce1b5
Signed-off-by: John Grossman <johngro@google.com>
udioBufferProviderSource.cpp
udioBufferProviderSource.h
udioFlinger.cpp
udioStreamOutSink.cpp
udioStreamOutSink.h
astMixer.cpp
onoPipe.cpp
onoPipe.h
onoPipeReader.cpp
onoPipeReader.h
BAIO.cpp
BAIO.h
ourceAudioBufferProvider.cpp
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>
udioFlinger.cpp
udioFlinger.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>
udioFlinger.cpp
udioFlinger.h
3c0a0e8541846427db0587c2fffb90f60ee680b0 02-Aug-2012 Paul Lind <plind@mips.com> Fix initialization of audio mixer track resources for MIPS.

The value 1 << 32 (maxNumTracks defaults to 32) is surprisingly not defined
in C, and differs on MIPS than the other arch.

Therefore the track resources were not initialized properly, resulting
in failure to play any audio.

The fix allows the mConfiguredNames bitmask to be correctly set to all
1's in the 32-track case, for all arch.

Change-Id: Ied3e1305952e9567602e2cd76c5ef3acb0809ee0
Signed-off-by: Paul Lind <plind@mips.com>
udioMixer.cpp
bdce245042dab808cb9062d9161256f01b03a79c 01-Aug-2012 Glenn Kasten <gkasten@google.com> am b2676a29: am 44cda3a4: Don\'t wait for presentation complete if terminated

* commit 'b2676a2920c6514ae9405cc56dfa2db49f096016':
Don't wait for presentation complete if terminated
44cda3a4e7ca3de0db9cb49145def3803b03ebb4 01-Aug-2012 Glenn Kasten <gkasten@google.com> Don't wait for presentation complete if terminated

Change-Id: Ia04cf6c620693457dca87b4ffea5dd0fe71efdce
udioFlinger.cpp
d4b5f7213911636a26a43127eb6ea139f403f558 01-Aug-2012 Glenn Kasten <gkasten@google.com> am 8d058d89: am 5665fde6: Merge "Start adding support for multiple record tracks" into jb-mr1-dev

* commit '8d058d89fd4d46bbacbb8f2dc9bd52e94cd69e56':
Start adding support for multiple record tracks
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
udioFlinger.cpp
udioFlinger.h
05144f1d68c5240a1fedd42ac83814f3ecf70dfd 30-Jul-2012 Glenn Kasten <gkasten@google.com> Merge "Share local time frequency for all tracks & mixers"
93d906837e0e89aa1d9c913ab2b531b809f9bb9e 24-Jul-2012 John Grossman <johngro@google.com> 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>
udioFlinger.cpp
udioFlinger.h
91de9b56282d126ffb36344266af5fee3cefcfdd 20-Jul-2012 John Grossman <johngro@google.com> 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>
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
52008f821a5202502a82a8ba2c024e69bd336350 18-Mar-2012 Glenn Kasten <gkasten@google.com> Share local time frequency for all tracks & mixers

Change-Id: I5e6f0e371f728a5225c2fa6f778c109449d33602
udioMixer.cpp
udioMixer.h
0a7af18d0308295405491f86603e3d119450aba0 10-Jul-2012 Glenn Kasten <gkasten@google.com> Use valueAt instead of editValueAt when possible

Change-Id: I885b169f4b176a6b5c2ca9a534214b4ffff1700e
udioFlinger.cpp
udioFlinger.h
58e5aa34f01d663654d8bafad65db1dda42161ff 20-Jun-2012 Glenn Kasten <gkasten@google.com> effect_descriptor_t const correctness

Change-Id: Iad008f20d35a18acf500f773900164552fd0c19e
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
1d491ff06f4b9c90ff24fe953b90d0843eaf1c04 16-Jul-2012 Glenn Kasten <gkasten@google.com> Fix races in AudioRecord stop()

Change-Id: Id0ac1915f57fef4a938c7f90989c1162a8b6c51c
udioFlinger.cpp
udioFlinger.h
69d799679c8c0308e42057e7b5ad63a7ae806480 19-Jul-2012 Glenn Kasten <gkasten@google.com> Use upmix/downmix utility routines

Change-Id: I9ae2ec938fb695ec576ea008a42205325af7bbf1
udioFlinger.cpp
e65c89113232d070dd9153c54ca19301bca7a162 21-Jul-2012 Eric Laurent <elaurent@google.com> fix audio effect not destroyed when needed.

commit a5f44eba contained an error which made that audio effect
modules where not destroyed but left in the destroyed state
rendering them unuseable after being released.

Bug 6805168.

Change-Id: Ia4e683b3c970ffd01846c482fde73d799ff219de
udioFlinger.cpp
33e6e35b03a726e35203e97550f32154c91d5f13 17-Jul-2012 Glenn Kasten <gkasten@google.com> Miscellaneous audio record fixes

Call AudioSystem::stopInput() if exitPending() after wait() returns.

Acquire lock before clearing mActiveThread.

Change-Id: Ia55e4c4b3accc65ad5479cbdc094fd919152af9f
udioFlinger.cpp
cd2d61016527bf48bd2e9a920bb3fdbb875eb3e4 19-Jul-2012 Glenn Kasten <gkasten@google.com> Use constructor to initialize instead of memcpy

Also don't check for thread parameter as it's always non-NULL

Change-Id: Id23ded1370556ef3f76f81f5f0c6fa644bcba681
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
5ad92f620fbbb6a8281f10169a23d38e3601e07a 19-Jul-2012 Glenn Kasten <gkasten@google.com> Revert 94479fd5405642c67efd14cebe722feb9cbe6e77

Change-Id: I5ca78d5462badf541868785b2ba2e3f6d0cf492a
udioFlinger.cpp
bb4350d3b9e9485ae59e084de270f86aecef8066 04-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_devices_t more places

Change-Id: Id0ace02ca6f480a6c46e11880acf6cdc66d83184
udioFlinger.cpp
udioFlinger.h
a189a6883ee55cf62da1d7bf5bf5a8ab501938a4 20-Feb-2012 Glenn Kasten <gkasten@google.com> Use struct assignment instead of explicit memcpy

for POD structs effect_descriptor_t and effect_config_t

Change-Id: Ib2fc47f85fb65ed91b0abb1f87217c49b5eb571d
udioFlinger.cpp
udioPolicyService.cpp
fd4e20c226eca185fc789de761beae64855bfbbb 04-Jun-2012 Glenn Kasten <gkasten@google.com> Run audio at priorities 2 and 3 above kernel 1

Also run the watchdog at same priority as the fast mixer.
requestPriority() originally used only the caller's pid to decide which
cgroup to assign, but in the future it might look at the priority also.
So it's safer to use same priority as the fast mixer to be sure we
run in the same cgroup.

Bug: 6461925
Change-Id: Ia59c93e4b22dacbb6746bfa6ad491be7b72f2b8d
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
1879fff068422852c1483dcf8365c2ff0e2fadfc 12-Jul-2012 Glenn Kasten <gkasten@google.com> Add tid parameter to IAudioFlinger::openRecord

Not yet implemented

Change-Id: I35523fb15ad71727ecc9f4bb870f07e4b7397dc4
udioFlinger.cpp
udioFlinger.h
bf04a5d7f287fc712e0ed91849dc85c90c1e182d 12-Jul-2012 Glenn Kasten <gkasten@google.com> Simplify AudioRecord::getInputFramesLost()

This also fixes a benign race in reading mActive without a lock.

Change-Id: I19e953d4f275e5c266ca1ca3fece7b6c02ad1707
udioFlinger.cpp
39c54f68804c1ce5c85ec588f3c2c63447a807b4 09-Mar-2012 Glenn Kasten <gkasten@google.com> Remove dead code

Change-Id: If22a6c4e572b0734eba0c5a7ce29a2c61c581e5d
udioFlinger.cpp
udioFlinger.h
4fe1ec4f40b58abff6cec147aa786cb65698161a 28-Feb-2012 Glenn Kasten <gkasten@google.com> Fix check for invalid channel count

Change-Id: Id9e3dce0e3d5971786212d3f70e17a17e32ce92b
udioFlinger.cpp
04270daf50f0c602d7c57a257a693e68246cbeb7 10-Jul-2012 Glenn Kasten <gkasten@google.com> Record overflow cleanup

Add comments and rename one method for clarity

Change-Id: I04a9147e46e88a072256c0211b112d52202419e2
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioPolicyService.cpp
udioPolicyService.h
4d2132c866228eaef563e8141ebf06aa25ee9ff7 10-Jul-2012 Eric Laurent <elaurent@google.com> Merge "audio policy: fix delayed command insertion"
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
udioFlinger.h
a34f8ec169986c5a28600c0decaa4e2db70df8e4 21-Jun-2012 Glenn Kasten <gkasten@google.com> Remove 'volatile' from mMute and add comments

Change-Id: I386ba27b2305a397aba70331c6bf0d35ea727cf6
udioFlinger.h
9f34a36d9cdb9595c288e50ffe00da038bc8abb9 21-Mar-2012 Glenn Kasten <gkasten@google.com> Whitespace and indentation

Change-Id: I424052b4ff9218147a5cfc8e6dcd67fe8105d229
udioFlinger.cpp
udioFlinger.h
7d6c35bf132a46c0a8a9826491882495fc98bd8c 02-Jul-2012 Glenn Kasten <gkasten@google.com> Move constant initializations from onFirstRef() to constructor

Change-Id: I57f55b0bd1edee105c58c3a055f95f1e4a2c9646
udioFlinger.cpp
6648821933dc06c0b09ab2c8b32135edddcd4291 21-Jun-2012 Glenn Kasten <gkasten@google.com> AudioFlinger::getBuffer() always returns non-NULL

Change-Id: I543d3db507597cacbfdad5d9ea71732137fe54fb
udioFlinger.cpp
udioFlinger.h
94479fd5405642c67efd14cebe722feb9cbe6e77 10-Jul-2012 Glenn Kasten <gkasten@google.com> Fix build

Revert after system/core audio_devices_t is submitted

Change-Id: I5a8ee1a7b711e834501e927f41c62efa6a6600b6
udioFlinger.cpp
cec4abb2a39eafa75cf6894170a200322aa7226e 03-Jul-2012 Eric Laurent <elaurent@google.com> audio policy: fix delayed command insertion

When inserting a delayed command in the audio policy service
command thread queue, later similar commands are filtered out.
In case of volume commands and delayed unmuting, this can cause
a problem where a new volume command can cause the timing of a
delayed unmuting command to not be honored.

This change makes that a volume command gets the time stamp of
any delayed command it replaces.

Bug 6720482.

Change-Id: I216f85ac0ea46e4a046d3483e9e9b7ffe6c34a08
udioPolicyService.cpp
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
udioFlinger.cpp
udioFlinger.h
c1dae24a08b67b98e18e4239d4f3a74d600d353c 03-Jul-2012 Glenn Kasten <gkasten@google.com> Remove debug code HAVE_REQUEST_PRIORITY and SOAKER

Change-Id: I73a2afe72d8acb53e57e6b4e6fb5133e22b7875a
ndroid.mk
udioFlinger.cpp
udioFlinger.h
oaker.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
d5903ec1332630f2992a6f0d5ca69d13a185c665 18-Mar-2012 Glenn Kasten <gkasten@google.com> Compare sp<> to 0 and raw pointers to NULL

Change-Id: I50ff8a010d349d1d7e3dffa04a6331814c2128b0
udioFlinger.cpp
a01992a0675a06df7d0bbe7b977207dd0c33fdc7 02-Jul-2012 Eric Laurent <elaurent@google.com> am dbbd5b86: am 109347d4: audioflinger: fix regression in attachAuxEffect().

* commit 'dbbd5b860a3a26bea3376410f75f27530d9cd10b':
audioflinger: fix regression in attachAuxEffect().
109347d421413303eb1678dd9e2aa9d40acf89d2 02-Jul-2012 Eric Laurent <elaurent@google.com> audioflinger: fix regression in attachAuxEffect().

Commit 717e1286 introduced a regression in PlaybackThread::Track::attachAuxEffect()
when called with an effect ID of 0 to detach the auxiliary effect.

It is normal in this case that AudioFlinger::getEffectThread_l() returns 0.

Bug 6768757.

Change-Id: I7430bd1aad2f68da38f7c3e4794e7ad657bfc6be
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
9ee836fc8cf54d26e1e0819d1467d4d39bb9295c 25-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Remove acoustics from AudioSystem::getInput()"
20010053daabfa43fcfe781bbf004473b4c08538 22-Jun-2012 Glenn Kasten <gkasten@google.com> Remove acoustics from AudioSystem::getInput()

Change-Id: I29fb3ee5664c1f0ee0409c1bb2be087ecca637db
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.h
5f12136299918ea30555f3481668ec0dbb775e5f 15-Jun-2012 Eric Laurent <elaurent@google.com> audio policy: acquire lock for volume functions

Acquire the AudioPolicyService mutex when executing
setStreamVolumeIndex() and getStreamVolumeIndex().

These functions have become more complex and iterate on the
list of opened outputs and it is safer to acquire the
AudioPolicyService mutex to avoid concurrency with other
functions.

Bug 6626532.

Change-Id: Ifdcbbbf13338fd9a59f694d43faa7ade143f94bf
udioPolicyService.cpp
eb15716b59020f342df62bce5b293f0603b94861 13-Jun-2012 Glenn Kasten <gkasten@google.com> Change definition of warmup period

Previously, warmup was considered done as soon as any write() took
more than 0.5 nominal cycle time. In practice, this was always the
first write() that turned on power to the output path, and it didn't
accurately account for filling the full kernel buffer queue, or for
buffering in the HAL sample rate conversion.

Now warmup is considered done when a write() _after_ the first write
takes more than 0.5 nominal cycle time.

This will throttle the initial pull rate after coming out of standby.
When combined with another change to throttle the pull rate for
devices with HAL sample rate conversion, it may help reduce some of the
notification glitches. The only downside is that it will increase the
warmup time a bit.

Bug: 6508317, 6650846, 6607056
Change-Id: I39f324c5195578170a55308e9601d3a1b41db3e0
astMixer.cpp
972af221ae7253e406e0e1ea853e56a3010ed6b1 14-Jun-2012 Glenn Kasten <gkasten@google.com> FastMixer compensates for SRC jitter in audio HAL

Force a sleep if audio HAL write() returns too quickly.

Bug: 6661275
Change-Id: Ie810f5a087b89fb24dab229a0e500af1dee53571
astMixer.cpp
0a14c4ce1a41bc09eb7855fa531a3af629a69139 13-Jun-2012 Glenn Kasten <gkasten@google.com> Make CPU frequency statistics optional

Certain CPUs with dynamic cluster swapping and hotplug
don't report CPU frequency accurately. The file descriptors
used to read the frequency become stale and report bogus data.
So make this feature a build time option for debugging only.
This will also improve performance of the fast mixer loop.

Change-Id: I602f81ec3281a37992769208be08084ed1469e8c
ndroid.mk
astMixer.cpp
astMixer.h
362ebcbf100f7fccd37551c77e67c4faa7241b63 24-May-2012 Glenn Kasten <gkasten@google.com> DO NOT MERGE Remove log spam for fast track denied

Bug: 6531054
Change-Id: Iedf58e810a157aae88b5900da27c81054c437058
udioFlinger.cpp
e6adde403480333b613452ae0df442df9da4a5b2 14-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Shorten dumpsys media.audio_flinger output" into jb-dev
49dd5cf3469cd755321f8ec10013ad4fcfaf723d 14-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Log track name on obtain/releaseBuffer warnings" into jb-dev
3d51d5cb53cc630709a0ba78d0e60501a675f2d5 13-Jun-2012 James Dong <jdong@google.com> Add NOTICE and MODULE_LICENSE_APACH2 to libs build under /frameworks/av/

Change-Id: I0a3af3e2abdedebd5934f3d941d01c32cfc75e26
related-to-bug: 6647465
ODULE_LICENSE_APACHE2
OTICE
868c0abe9f26852c217bc201b337e72c68f829b8 13-Jun-2012 Glenn Kasten <gkasten@google.com> Shorten dumpsys media.audio_flinger output

Don't include in FastMixer if it's not present.
This removes confusing clutter especially for devices
with a separate deep buffer output thread, or for the
duplicating thread and A2DP output thread.

Change-Id: I84933f5555593256f11ba0895ec915c09cf16963
astMixer.cpp
0c9d26d187017f7fb028ab52a0fbc6395142faa4 31-May-2012 Glenn Kasten <gkasten@google.com> Log track name on obtain/releaseBuffer warnings

This should help diagnose problems by allowing us to correlate
the logs with the dumpsys media.audio_flinger output.

Change-Id: I8c7c592b4f87d13b0f29c66ce7a2f301a0f063c9
udioFlinger.cpp
c15d6657a17d7cef91f800f40d11760e2e7340af 30-May-2012 Glenn Kasten <gkasten@google.com> Add audio watchdog thread

Change-Id: I4ed62087bd6554179abb8258d2da606050e762c0
ndroid.mk
udioFlinger.cpp
udioFlinger.h
udioWatchdog.cpp
udioWatchdog.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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
onoPipe.cpp
onoPipe.h
a4f7e0e9a0e92a063f1b3a08988cf46e2cf1fa94 08-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: fix duplicating thread standby

The code that waits for a track presentation to be complete
before disabling it caused a regression for duplicating threads.
Because of the way output tracks activity is managed, the number
of frames output by the duplicating thread would never
reach the target set for a track to be considered presented.
The track would not be removed from active list and the thread would
not go to standby and keep its wakelock held.

Bug 6606922.

Change-Id: I4b46b420ac4cbf79a86b6791ae6589d407b01c92
udioFlinger.cpp
e35a55fbdff5a695ee35ff43f1466a62fb75662b 07-Jun-2012 Marco Nelissen <marcone@google.com> Merge "Take latency and current time into account for visualization" into jb-dev
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
udioFlinger.cpp
udioFlinger.h
9a0d82df8fd681257bc5b29fb5e6c65fcc7cef5a 06-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: modify fast mixer overrun management

Do not force sleep when an overrun occurs. This was for non
blocking audio HAL and is unused.
Keep statistics on overruns.

Bug 6605215.

Change-Id: I295455d4562201aa3814c88bdd6e52c9226712af
astMixer.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
ab9071b8d1b375418eb797c9a790da71de644344 04-Jun-2012 Eric Laurent <elaurent@google.com> audioflinger: fix active sleep time calculation.

When an audioTrack underruns, the audioflinger mixer thread
sleeps for a certain time to give the app a chance to recover.
This time is based on the reported audio HAL latency.
Some audio HALs implementing deep buffering have a variable
latency and this creates a problem if the sleep time is cached
when the output stream is opened and not updated afterwards.

This change derives the active sleep time from the mix buffer
framecount instead of the latency. This is more conservative
but works for variable latency.

Bug 6588525.

Change-Id: Ia892fc290fe06f836565c3ae15f7a2ce026c88c6
udioFlinger.cpp
399930859a75d806ce0ef124ac22025ae4ef0549 31-May-2012 Glenn Kasten <gkasten@google.com> State queue dump

Bug: 6591648
Change-Id: Iac75e5ea64e86640b3d890c46a636641b9733c6d
ndroid.mk
udioFlinger.cpp
udioFlinger.h
tateQueue.cpp
tateQueue.h
1295bb4dcff7b29c75cd23746816df12a871d72c 31-May-2012 Glenn Kasten <gkasten@google.com> Fast track dumpsys

Bug: 6591648
Change-Id: I696f51c682e7233ba690d97da26012084989b412
udioFlinger.cpp
astMixer.cpp
astMixer.h
bf0d21fb1310e8677caa53b90e8c3aecebc7fc13 31-May-2012 Glenn Kasten <gkasten@google.com> Count underruns for normal tracks also

Bug: 6591648
Change-Id: Iff9cabe392bb2ce97062603adb9c9dc7aa4170d5
udioFlinger.cpp
81787e56f8f21407eade5accc50c6da39b8af9b2 03-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Was calculating measured warmup time wrong" into jb-dev
7dc5b165d4f98a2059eaf1c7fec20b3b5773cd4c 01-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Fix fast track leak if out of normal track names" into jb-dev
0c22272f1c97fd4b7e106030a1fd5e6b50680b61 01-Jun-2012 Glenn Kasten <gkasten@google.com> Merge "Pipe throttle based on requested frame count" into jb-dev
04a4ca4217e9b30342d5865024c340013d7184e8 01-Jun-2012 Glenn Kasten <gkasten@google.com> Was calculating measured warmup time wrong

Bug: 6592923
Change-Id: I980c6fc69d78c569147ea44ce33a7f8a41739c91
astMixer.cpp
893a05479c96f911d02beb0443da3ed6508143a7 30-May-2012 Glenn Kasten <gkasten@google.com> Fix fast track leak if out of normal track names

Bug: 6580402
Change-Id: I3ac7f012062c35833147f47ba822eb4bf532a824
udioFlinger.cpp
udioFlinger.h
820ba70df8ba595ae9055dfd34fdbfa32f70f14d 31-May-2012 Glenn Kasten <gkasten@google.com> Pipe throttle based on requested frame count

Now does throttling based on the requested frame count, but
still permits overfilling pipe up to the rounded-up frame count.
Also still uses the larger frame count for non-blocking arithmetic.

Bug: 6585323
Change-Id: Ic2420a071419905524a14c22ebe1ce0e32d70a9d
onoPipe.cpp
onoPipe.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
udioFlinger.cpp
udioFlinger.h
f436fdcf93bd417fd3c9d2a8b19fd221d894b5e3 24-May-2012 Eric Laurent <elaurent@google.com> audioflinger: change session check in createTrack.

Do not refuse to create a track on an output thread if the same session
is present on another thread. It is now possible that two tracks
with the same session ID are on different threads if one can use deep
buffering and the other can't.

In this case, move effects attached to this session to the output
thread ion which the new track is created.

Bug 6530324.

Change-Id: I9019b3ee382e374c89d2319033afcfa7f886e4c4
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
onoPipe.h
fbae5dae5187aca9d974cbe15ec818e9c6f56705 21-May-2012 Glenn Kasten <gkasten@google.com> Keep a copy of most recent audio played

Change-Id: I6b2f97881c39998a2fae9ab79d669af6c0a37e94
ndroid.mk
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
astMixerState.cpp
astMixerState.h
ipeReader.cpp
6d8aabe8a3be1ac0789d00b82c3ca8b81381f5ab 18-May-2012 Glenn Kasten <gkasten@google.com> Add throttle to have pipe fill at more stable rate

Change-Id: Ibff9ab62764e2acd04518a4a00e25f19e28aff4a
onoPipe.cpp
onoPipe.h
99c99d00beb43b939dedc9ffb07adb89f6a85ba5 15-May-2012 Glenn Kasten <gkasten@google.com> systrace for audio

Trace fast track buffer fill status for underruns etc.

Move the definition of macro to Android.mk.

No overhead if disabled.

Change-Id: If0e83e21b61b059ca38f543f8a6ffb58e08c79ee
ndroid.mk
udioFlinger.cpp
astMixer.cpp
552477608b137fb66af126655c6865207a82d888 18-May-2012 Glenn Kasten <gkasten@google.com> Merge "Display pipe underrun counters in dumpsys" into jb-dev
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
udioFlinger.cpp
udioFlinger.h
c059bd4246c1b3944965be921e5b334d51cd236c 15-May-2012 Glenn Kasten <gkasten@google.com> Skip bad kHz values, and display them accurately

One device reports zero CPU kHz occasionally, so skip those values.

Preserve accuracy of the low-order 4 bits of the the CPU frequency.

Change-Id: I7d934f697412277462464fca82d112d0306a214e
astMixer.cpp
9017e5e0ebad9664bb7b6f2057e5bb29c852c64f 15-May-2012 Glenn Kasten <gkasten@google.com> Increase normal mixer's pipe to fast mixer

Change-Id: I330925c7d07b6adb30b773bda3657e4efef9ae9b
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
4adcede0dc54a85c31abaf139921aebd7a072d8e 14-May-2012 Glenn Kasten <gkasten@google.com> Reduce video frame drop rate

The video playback engine depends on having relatively precise audio
progress updates for its A/V sync and frame drop calculations. For small
audio HAL buffer sizes, this was not a problem, but when the HAL buffer
size was > 12 ms, the normal mix buffer size became > 24 ms and this
then caused video problems. The new formula tries to keep the normal
mix buffer size within a closer tolerance of 20 ms to 24 ms.

Also use consistent term: multiplier instead of multiple.

Bug: 6479613
Change-Id: I903bad74461908e8c8f0a61e99ab5e24d5c44433
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
astMixer.cpp
astMixer.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
udioFlinger.cpp
udioFlinger.h
808e7d16504cbe5b28bb88c31afb2542ab488965 12-May-2012 Eric Laurent <elaurent@google.com> AudioFlinger: fix global effects suspend logic

Audio effects on the output mix should not be suspended when effects
on the output stage (post processing) are enabled.

Change-Id: I2e1c08fa9358ea3cbaec68856738d504b1be54e4
udioFlinger.cpp
e58ccce45598bcf4b4874b0e87cd1eb8d05ba9a9 12-May-2012 Glenn Kasten <gkasten@google.com> Fix 2 bugs in fast mixer statistics

Was losing the upper half of the bounds, and MHz was off.

Change-Id: I61c98027b35ce7c3578ea6f3acf05aa5c48a5831
astMixer.cpp
d8e6fd35ec2b59ee7d873daf1f1d9d348221c7bc 07-May-2012 Glenn Kasten <gkasten@google.com> Use audio tag for system tracing

Disabled by default; uncomment ATRACE_TAG to enable

Change-Id: I99af894022a859ee5644bd853cfd8a48e4735ff9
udioFlinger.cpp
astMixer.cpp
42d45cfd0c3d62357a6549c62f535e4d4fe08d91 02-May-2012 Glenn Kasten <gkasten@google.com> Update fast mixer statistics

Compute statistics on fast mixer elapsed time and CPU load per cycle using a
simple moving average rather than by fixed blocks. This has a couple advantages:
- remove burstiness of CPU usage due to former floating-point calculations in fast mixer
- gives us flexibility in how to report (e.g. could report over just the last 1 second)

Disadvantage is increased RAM, and since the samples are not updated
atomically, it is possible to have an error in the statistics. This
should not be much of an issue due to the relatively large number of samples.

Also add CPU raw ns and adjusted MHz statistics.

Change-Id: Iaa2cd13f18250c3162aff40409b3694b769d9505
astMixer.cpp
astMixer.h
e213c86d36414a8fc75e37c52999522fe09c7328 25-Apr-2012 Glenn Kasten <gkasten@google.com> dumpsys fCnt and flags

Previously displayed TrackBase::mFrameCount but not control block frameCount.
Now displays both.

Also display the track flags in control block.

Change-Id: Ie53781d4784633d78b6f928d69ebd494d8f110ec
udioFlinger.cpp
31dfd1db7a4d2228d9642008af6f3dd744368eb6 01-May-2012 Glenn Kasten <gkasten@google.com> Disable fast track log spam

except for "denied by client" and "denied by server"

Change-Id: I133ab747933729cc1f386813ee06ece055bdb294
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
xtendedAudioBufferProvider.h
astMixer.cpp
astMixer.h
astMixerState.h
ourceAudioBufferProvider.cpp
ourceAudioBufferProvider.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
udioFlinger.cpp
udioFlinger.h
300a2ee9327c05fbf9d3a5fd595b558097c7c5e8 25-Apr-2012 Glenn Kasten <gkasten@google.com> Fast mixer configuration

Add compile-time option for when to use fast mixer.

Double HAL frame count for fast tracks due to SRC, and make the normal
frame count multiplier an even number for compatibility. Sample rate
conversion can result in underruns if the HAL frame count is used as is,
due to jitter.

Change-Id: Ia1f8da1b8ac247d9807acfce3c318161db000905
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
e0fa467e1150c65a7b1b1ed904c579b40f97c9df 24-Apr-2012 Glenn Kasten <gkasten@google.com> Move frame count calculations for fast tracks

For fast tracks: move the default and minimum frame count calculations
from client to server. If accepted, the default and minimum frame count
is the fast mixer (HAL) frame count. If denied, the default and minimum
frame count is the same as it currently is for normal tracks.

For normal tracks: there is no change yet, preserve legacy behavior for
now but add a FIXME to change this later.

Bug fix: the test for buffer alignment matches channelCount was wrong.

Bug fix: check for 8-bit data in shared memory, which isn't supported.

Optimizations:
- in set(), only call AudioSystem::getOutputSamplingRate() when needed
- in createTrack_l(), only call AudioSystem::getSamplingRate() and
AudioSystem::getFrameCount() when needed

Change-Id: I79d2fe507db1a8f7bb094c71da8a129951dbb82f
udioFlinger.cpp
1dc28b794587be22c90a97070d928f94586db638 24-Apr-2012 Glenn Kasten <gkasten@google.com> Use scheduling policy service

Change-Id: I3c09da1dc0de5039d0c15ce7fb2bc373fa398712
ndroid.mk
udioFlinger.cpp
SchedulingPolicyService.cpp
SchedulingPolicyService.h
chedulingPolicyService.cpp
chedulingPolicyService.h
58912562617941964939a4182cda71eaeb153d4b 03-Apr-2012 Glenn Kasten <gkasten@google.com> AudioFlinger normal mixer uses FastMixer

Change-Id: I3131bb22d2d057e9197a2ebfa6aa1cfaab9e5321
ndroid.mk
udioFlinger.cpp
udioFlinger.h
oaker.h
3acbd053c842e76e1a40fc8a0bf62de87eebf00f 28-Feb-2012 Glenn Kasten <gkasten@google.com> Configure policy of mediaserver threads

Change-Id: Ifd825590ba36996064a458f64453a94b84722cb0
ndroid.mk
udioFlinger.cpp
udioFlinger.h
c95cfbb87d0ac5e773037019a96bfc29972d4b4e 12-Apr-2012 John Grossman <johngro@google.com> TimedAudioTrack: Optimize the queue trim operation.

Hand merge from ics-aah

> TimedAudioTrack: Optimize the queue trim operation.
>
> Don't perform the end PTS calculation for each buffer during trimming.
> Instead, only calculate the ending PTS of a buffer if there is no next
> buffer in the queue. This optimization assumes that the buffers being
> queued are in monotonic media time order (a fair assumption for now)
> and that the timestamps in the audio are contiguous (not a requirement
> for this API, but a reality of how it is being used right now).
>
> In the case where the audio is discontinuous on purpose, it is
> that this optimization will cause the system hold one extra buffer
> which it could have safely trimmed. It should not be much of an issue
> since in real life the audio is almost always contiguous, and as long
> as the media clock is running and the mixer is mixing, the buffer will
> be used up and discard as part of the normal flow anyway.
>
> Change-Id: I00061e85ee7d5651fcf80751646c7d7415894a14
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: I0054b58e1389fa005aa990cb5710caf4af7b706a
Signed-off-by: John Grossman <johngro@google.com>
udioFlinger.cpp
8d314b709fdd81bb64bdaa8d72a0b19c355cefb9 19-Apr-2012 John Grossman <johngro@google.com> TimedAudioTrack: Fix continuity threshold handling.

Hand merge from ics-aah

> TimedAudioTrack: Fix continuity threshold handling.
>
> Fix issues with continuity threshold handling; notably
> + If the steady-state continuity threshold is exceeded, be sure to
> clear the on-time flag. Failure to do this will result in the
> system picking a new mix point which simply satisfies the
> steady-state continuity threshold instead of the startup threshold.
> Since we are putting a discontinuity in presentation anyway, we
> really want to pick a perfect point, not just an OK point.
> + Tighten the steady-state continuity threshold. It was currently set
> to 100mSec which is enormous. 4mSec (the new setting) is much more
> appropriate. On systems with a VCXO (like tungsten) this should
> never be wrong by more than a sample. If TimedAudioTracks are ever
> to be used on VCXO-less systems, this threshold should probably be a
> a parameter configurable by applications on a track by track basis
> so they can make the tradeoff between allowed error and frequency of
> disruptive corrections.
> + Reset the on-time flag if the mixer provides no PTS during a mix
> operation. This makes for a convenient way for the HAL to reset
> timed tracks when it makes changes for delay compensation across
> multiple outputs.
>
> Change-Id: I2cb23de5a3d1f75618abc1c8ab903db883837aa8
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: Ibd28c9d290494b0b19eb01caf2d9bfdef606a9b4
Signed-off-by: John Grossman <johngro@google.com>
udioFlinger.cpp
21e8c50bd13ebe44f3088e26c9c6df0e163c469c 12-Apr-2012 Glenn Kasten <gkasten@google.com> FastMixer update

Updates:
- Add support for mono fast tracks
- Add support for optional sample rate conversion on fast tracks
- Log sample rate and frame count
- Enable statistics

Change-Id: Ife014edf4f452da361f3eaaae19209ef6ff6958b
ndroid.mk
astMixer.cpp
astMixer.h
astMixerState.cpp
astMixerState.h
9bd23229fdec1657398abc682ccccfce1c95f8aa 16-Apr-2012 Jean-Michel Trivi <jmtrivi@google.com> Fix multichannel downmix pause bug on video player

Pausing a video player will cause the track audio mixer to be
disabled, which causes the downmixer to be deleted. When reenabled,
the track channel mask hasn't changed but the downmixer is there
anymore.
Fixed by:
- instanciating a downmixer when the AudioMixer track
gets initialized (in getTrackName(), now taking a channel mask
as input), and deleted when in deleteTrackName().
- when the channel changes on a track, check whether it
needs a downmixer or not. Preparing a track for downmix
automatically removes the old downmixer if there was one.

Also: initialize the track downmixerBufferProvider field
when AudioMixer is instanciated, so we can safely call
delete on it in AudioMixer's destructor, in case
deleteTrackName() wasn't called before the mixer was
destroyed.

Change-Id: I589b0781cda5b3c82f85b561c52b08546cac21f8
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
astMixer.cpp
0ca3cf94c0dfc173ad7886ae162c4b67067539f6 18-Apr-2012 Eric Laurent <elaurent@google.com> rename audio policy output flags

Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
acb86cccbd9d245439a04cef0bcefa589addaa4c 16-Apr-2012 Jean-Michel Trivi <jmtrivi@google.com> Configure the resampler with the correct channel count when downmixing

When a track needs to be downmixed and resampled, it gets downmixed
first before being resampled. Therefore the resampler needs to
be configured with the channel count of the output of the downmixer
instead of that of the track.
Removed frame size checks that don't apply anymore now that we support
frame sizes that are not powers of 2 (e.g. 12 for 5.1 16bits), and
changed test performed for every buffer during playback into an
assert.

Change-Id: Ia220f00ee382f4f7848b661c58555bdca664e194
udioFlinger.cpp
udioMixer.cpp
97b5d0d5b5ef766eb5dd680d05a5d199662d4ae0 24-Mar-2012 Glenn Kasten <gkasten@google.com> Fast mixer

Change-Id: I61552f83507e08e4c706076b9fb15362869e6265
ndroid.mk
astMixer.cpp
astMixer.h
astMixerState.cpp
astMixerState.h
tateQueueInstantiations.cpp
0845682ff93c9765b74b53dc404d0954efc28c2e 18-Apr-2012 Glenn Kasten <gkasten@google.com> Merge "Add template class StateQueue"
dc998c809e084b617990b281e2ed5271830cc2e0 24-Mar-2012 Glenn Kasten <gkasten@google.com> Add template class StateQueue

Change-Id: Iccc5eb42bc295a22b2e429a4551f083cd7b6831a
ndroid.mk
tateQueue.cpp
tateQueue.h
f7ffb8bf0a58037f0bc9662c5275005a4e539948 14-Apr-2012 Eric Laurent <elaurent@google.com> audioflinger: update to new audio HAL.

Updated audio flinger to new function prototypes
for open_output_stream() and open_input_stream().

Check audio hw device version when loading a module and
reject devices with a version different from current one.

Change-Id: I9d4c81a1f59a15db78b3989417c2a411c638fe88
udioFlinger.cpp
4e2293f29f2e719af1245d365747ea06d074b345 12-Apr-2012 Glenn Kasten <gkasten@google.com> AudioMixer new cmd: remove sample rate converter

Add a new command REMOVE to remove any sample rate converter
on a track, without having to delete the track name.
Add comments.
Remove some dead code.
Fix whitespace and comparison to NULL.

Change-Id: Id55a23ab5ee673189e99675b4e6fa5df7b617987
udioMixer.cpp
udioMixer.h
a5e821439996de6005b2fa36b3bdd31f003ce23f 16-Apr-2012 Eric Laurent <elaurent@google.com> AudioMixer: fix crash in destructor

Commit deeb1282 made that track->resampler is only set to NULL when
getTrackName() is called. It remains uninitialized for all unused tracks
causing a crash when deleted by Audiomixer destructor.

Issue 6309441.

Change-Id: I49451387a6afe81299b8368ef206524df32f74c4
udioMixer.cpp
b388e531613730572067e193b6b66afb5d042233 14-Apr-2012 Eric Laurent <elaurent@google.com> Fix ALOG_ASSERT in AudioFlinger

Fix broken ALOG_ASSERT in updateFramesPendingAfterTrim_l() introduced by
commit 1c345196.

Change-Id: Ie1b2653069283f23ff0367f2628828e37fb0749c
udioFlinger.cpp
d3030da2ac3c0ebb8b7bdf38418263caf405b863 12-Apr-2012 John Grossman <johngro@google.com> Fix the build

forgot to upload final fixup during merge. sry about that

Change-Id: I2ddd2c08d8efa83c0a8d1e378ae4c28686145154
udioFlinger.cpp
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>
udioFlinger.cpp
udioFlinger.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>
udioFlinger.cpp
udioFlinger.h
3f9c84c0a5af83fceb8669390e2d71b75ec7b550 04-Apr-2012 Eric Laurent <elaurent@google.com> audio pre processing: test code for dual mic

Added functional test code to validate effect API for
multi mic simplementations.

Also fixed warning in AudioFlinger.

Change-Id: I07be4d2e4d17791d3626c804ba3e9f87ff26d05a
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
3f502bfc6d04d08369cf147284c5c4c2ac7c9a0e 06-Apr-2012 Glenn Kasten <gkasten@google.com> Merge "Non-blocking audio I/O interface, WIP"
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
73d227557ba5192735356bacab9f77b44980793b 19-Mar-2012 Glenn Kasten <gkasten@google.com> AudioFlinger track flags and server's fast policy

Change-Id: I72358c8e6829d173b3e60ced8a8babc089869fac
udioFlinger.cpp
udioFlinger.h
0bf65bdde04b8e66c998ff37e2b2afafddddfa33 29-Feb-2012 Glenn Kasten <gkasten@google.com> const methods and comments

Change-Id: Ifd16750174fdb15b72507787502b587562ffc99e
udioFlinger.cpp
udioFlinger.h
010662326b9c43c703725f933e95e0897f8a6bdd 27-Feb-2012 Glenn Kasten <gkasten@google.com> Non-blocking audio I/O interface, WIP

Yet another abstraction similar to AudioTrack::Buffer and AudioBufferProvider,
but with support for streaming, non-blocking, and eventually PTS.

This is intended to be used as follows:
- primary HAL output stream implements a Sink
- primary HAL input stream implements a Source
- Pipe implements a Sink
- PipeReader implements a Source or TimedSource (not shown yet),
which supports "read at PTS"
- fast AudioTrack on server side will implement a Source using cblk
- normal AudioTrack on server side will not be changed initially
- fast AudioRecord on server side will implement a Sink using cblk
- normal AudioRecord on server side will not be changed initially
- fast mixer thread will read from Sources and write to a Sink,
or (unlikely) implement a Source and multiple Sinks
- Visualization and PCM logger will read from Source or TimedSource
- A2DP normal mixer will be connected directly to its output stream
and there will be a kind of OutputTrack for duplication that will
read from a Sink with non-blocking write fed by the fast mixer.

Patch set 3 changes:
- Add more implementations of NBAIO interfaces:
added SourceAudioBufferProvider, MonoPipe, MonoPipeReader.
- Added Format_sampleRate and Format_channelCount.
- Extract out the roundUp() method.
- Respond to most comments from previous code review.
- The new classes are untested.

Patch set 4 changes:
- Fix bugs in MonoPipe::write() and MonoPipeReader::read()
- Fix bug initializing mFrameBitShift too early
- renamed roundUp() to roundup()
- Fix Android.mk
- Add LOG_TAG an LOG_NDEBUG, use ALOG_ASSERT and utils/Log.h instead of assert
- Fix build warnings
- Move constructor and destructor bodies from .h to .cpp
- Line length 100
- Following naming conventions for #include double-include protector macros
- Include what you use
- More NBAIO logging
- MonoPipe write can be blocking

Patch set 5 changes:
- Address code review comments
- Use a static library so unused implementations don't take memory
- Comment out libsndfile dependency
- Remove debugging LOGV and LOG_NDEBUG

Patch set 6 changes (would be 6 at old location, actually 2 at new location):
- Address code review comments on patchset 5
- For MonoPipe, allow the full pipe to be used, no need to omit one slot
- Don't do atomic releasing stores unless needed

Still to do:
- I'm not happy with the Pipe class names
- Update build/ for new static library?

Change-Id: Ie6c61f05ce06b676b033be448a8ef9025a2ffcfd
ndroid.mk
udioBufferProviderSource.cpp
udioBufferProviderSource.h
udioStreamInSource.cpp
udioStreamInSource.h
udioStreamOutSink.cpp
udioStreamOutSink.h
ibsndfileSink.cpp
ibsndfileSink.h
ibsndfileSource.cpp
ibsndfileSource.h
onoPipe.cpp
onoPipe.h
onoPipeReader.cpp
onoPipeReader.h
BAIO.cpp
BAIO.h
ipe.cpp
ipe.h
ipeReader.cpp
ipeReader.h
ourceAudioBufferProvider.cpp
ourceAudioBufferProvider.h
oundup.c
oundup.h
deeb1282621f3177ad667360b40eef8e4fedb298 25-Mar-2012 Glenn Kasten <gkasten@google.com> AudioMixer default track parameters

Move the default initialization of track parameters from the AudioMixer
constructor to getTrackName(). This fixes a bug where the defaults were
only valid the first time a name was allocated.

Also added a switch case for parameter FORMAT.

Change-Id: I07abd3aaf7f4efe9825a761d2bc662aaee2c6db0
udioMixer.cpp
a1472d9883e35edd280201c8be3191695007dfd4 30-Mar-2012 Marco Nelissen <marcone@google.com> Make AudioTrack/AudioRecord handle more than 2^32 frames

b/6160363
Change-Id: I471815012c6a113ec2c4dd7676e8fa288a70bc76
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
b83d38feeeb88a8a2a6219e1fca2480b5a14fb0d 26-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "IAudioFlinger::createTrack and openRecord flags"
d12c68ad699ce0ed822a4d4db86e8e02324c6b03 23-Mar-2012 Glenn Kasten <gkasten@google.com> Revert "AudioFlinger does not need libmedia any more"

This reverts commit c920dee060ac69684be33210ee44b99a5fc3e8b2
ndroid.mk
4f5da11df06802856bf526f16563df7d5755f653 22-Mar-2012 Glenn Kasten <gkasten@google.com> AudioFlinger does not need libmedia any more

Change-Id: Ifd2c61882109ec36ca68072a2bf6506e08c8cf34
ndroid.mk
c5c49398584f2399af905a931e556ed6e0a29cd4 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up Track constructor"
ccf89b54f973f11082150d02ed957f7e967fbc8b 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "AudioMixer can be configured for fewer max tracks"
63c1faa8dea7feb90255d31ef2a133d8f2818844 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Update comments"
7153494670bdac8b650cb10b8b1838651e0ca418 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Whitespace"
a26ff6f22f4e86d09514c2819237bd9748455018 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "new doesn't fail on Android"
9a5f413a21b320fea0607e653bc75b1a4f0e7a2e 21-Mar-2012 Eric Laurent <elaurent@google.com> am a48285c4: am 165ee4c5: am 14958e21: Merge "audioflinger: fix issue with camcorder and A2DP" into ics-mr1

* commit 'a48285c4f22ffc43f1771ebd1ff35dcec48db2c7':
audioflinger: fix issue with camcorder and A2DP
5c94b6c7689a335e26a86e8a0d04b56dc627738e 21-Mar-2012 Glenn Kasten <gkasten@google.com> AudioMixer can be configured for fewer max tracks

Change-Id: I371b17cef071d083eecf35cd3627a3adff907a33
udioMixer.cpp
udioMixer.h
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
udioFlinger.cpp
udioFlinger.h
ea7939a079b3600cab955760839b021326f8cfc3 14-Mar-2012 Glenn Kasten <gkasten@google.com> Whitespace

Fix indentation, and add blank lines in key places for clarity

Change-Id: I57a0a8142394f83203161aa9b8aa9276abf3ed7c
udioFlinger.cpp
udioMixer.cpp
2ee367e444e7b62e02bde8a2e47603a9ad342c6e 20-Mar-2012 Glenn Kasten <gkasten@google.com> Add libmedia_native

Change-Id: I3ac357c78fb89f108d15c6e5b9fa317de0e9fb9a
ndroid.mk
17a736c3e1d062d7fc916329eb32aef8935614af 14-Feb-2012 Glenn Kasten <gkasten@google.com> Update comments

Change-Id: I327663a020670d0a72ff57bd0b682e2ce0528650
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
a03567676e8766828ff970b87e13bc4c97b23473 19-Mar-2012 Glenn Kasten <gkasten@google.com> new doesn't fail on Android

Change-Id: I5079a3bf31097dd0807b2d806d5f8d3cff2077ab
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
9d7b4c074205609271f61e1a4741ac0c524a1795 19-Mar-2012 Eric Laurent <elaurent@google.com> am 14958e21: Merge "audioflinger: fix issue with camcorder and A2DP" into ics-mr1

* commit '14958e21c12f922d7501d32c3bec05109eb342d5':
audioflinger: fix issue with camcorder and A2DP
89d94e79dad032fb18ddc655e6068e4231d3f0aa 17-Mar-2012 Eric Laurent <elaurent@google.com> audioflinger: fix issue with camcorder and A2DP

Some audio HALs do not support well a device selection of 0 (no device)
received on an input stream.

This can happen because of a problem in the audioflinger code that handles
the forwarding of the output device selection to the record thread for use by
the pre processing modules that need it. If the output device is 0 (meaning
no op, which happens when stopping playback over A2DP) audioflinger could not
detect it was an output device selection and would forward it to the input
stream (see AudioFlinger::setParameters() and RecordThread::checkForNewParameters_l().

Issue 6179641.

Change-Id: Idae534521866538e0d12ba259a2834f402a922e2
udioFlinger.cpp
b12153e36ae5e514d96c77d660b327d1a8f5000f 16-Mar-2012 Glenn Kasten <gkasten@google.com> Add libmedia_native

Change-Id: Ib8cff8abd73723b793f08da99ad59549f219e0e7
ndroid.mk
33b383948e8f270bff30378476f00dce289004eb 13-Mar-2012 Glenn Kasten <gkasten@google.com> Remove dependency on audio_* location

Change-Id: I4bc66115fcb9ba22b057bd72db3f561dcb18a0d8
ndroid.mk
dfaf549e3e310bc22444f4404b19f4907b24c286 15-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "AudioFlinger playback thread CPU measurement in Hz"
190a46f7c84e160386610c0c4cecb9767fb5503b 06-Mar-2012 Glenn Kasten <gkasten@google.com> AudioFlinger playback thread CPU measurement in Hz

Log statistics on CPU usage in Hz in addition to wall clock time

Use CPU statistics for all playback threads, not just MIXER
(but they are disabled by default by a compile-time debug macro).

ThreadCpuUsage library:
- Move statistics out of the library and leave that up to the caller
- Add API to determine a CPU's frequency

Change-Id: Ia1011123146e641fcf210ef26e78ae2b4d3b64ad
udioFlinger.cpp
3b229ed97c0dfc85a8cf881341e29e595e0edea7 14-Mar-2012 Eric Laurent <elaurent@google.com> Merge "audioflinger: more info in dumpsys"
612bbb57c59397a540e96f06bdd16e437a583af5 14-Mar-2012 Eric Laurent <elaurent@google.com> audioflinger: more info in dumpsys

Added TID and io handle to AudioFlinger threads dump.

Change-Id: Ib1a856f3bad55c73e4c395b5e59d57435f4b9a4c
udioFlinger.cpp
d3cee2f0f649c01e1153d593cbe723887b8e0ba0 14-Mar-2012 Glenn Kasten <gkasten@google.com> Break circular dependency on media player service

Bug: 6165157
Change-Id: I3c85bbcaf31f3cb9a009e273f7b6284015eb3bd8
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
udioResampler.cpp
udioResampler.h
udioResamplerCubic.h
udioResamplerSinc.cpp
fd83fbf5ead098070bae674b20e6f87f45ab5d4c 13-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up assertion checks"
aa4397f07c43bd83bc3100b749401dc3d15e7622 13-Mar-2012 Glenn Kasten <gkasten@google.com> Fix bug where mMixerStatus was set to IDLE

Change-Id: I55df1738fb7ba17ba6caeea6a17557526eac17a7
udioFlinger.cpp
5798d4ebf236357a4b13246f40e52b90a34d09a4 08-Mar-2012 Glenn Kasten <gkasten@google.com> Clean up assertion checks

Use ALOG_ASSERT instead of assert.
Use compile-time asserts where appropriate.
Fix typo in an ALOGV.

Change-Id: I58f1c1ffc14319a022c88b5a88b8d0368660da8b
udioFlinger.cpp
udioMixer.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
d69549665d412f1f6ebad48ad8cd05133ada8728 09-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Replace hard-coded 3 by FCC_2 to simplify searches"
688aac7675f18bdd7bff13334759e20bc4e6c390 09-Mar-2012 Glenn Kasten <gkasten@google.com> Remove virtual from methods that don't need it

Change-Id: I30e17e61aae25b036436c0e270313c80c43e5f06
udioFlinger.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
udioFlinger.h
083c154162c88a9f63aeaa10a4b52dd454bda9ff 09-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Don't ask policy manager about invalid stream type"
b3dfcf483a96816fe2e949dd86fed26e52ad7404 09-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "AudioPolicyService InputDesc minor cleanup"
a19ffb656616feec70613ba67ddfe15a504a4e76 09-Mar-2012 Eric Laurent <elaurent@google.com> Merge "audio policy: use audio_devices_t when appropriate"
81872a2ce65653ae980621ba2907da56a83ba9a7 08-Mar-2012 Glenn Kasten <gkasten@google.com> AudioPolicyService InputDesc minor cleanup

Add a non-default constructor to set the mSessionId, and make mSessionId const.

Remove explicit clear on mEffects - it is automatically cleared by the destructor.

AudioPolicyService::setPreProcessorEnabled:
- parameter is const *
- use an alias instead of making a Vector copy

Destructor doesn't need to be virtual since there are no subclasses.

Change-Id: Ibc3c3bea8259839430b1cf5356186c7d96f1082f
udioPolicyService.cpp
udioPolicyService.h
53d76dbe7c55821e89d9da02e7a563f7fb45de87 08-Mar-2012 Glenn Kasten <gkasten@google.com> Replace hard-coded 3 by FCC_2 to simplify searches

Change-Id: I92881d04e8378307f849fb343071a58d181a68b4
udioFlinger.cpp
udioFlinger.h
6374252107fd6539397598195ea6defd5870fafb 08-Mar-2012 Eric Laurent <elaurent@google.com> audio policy: use audio_devices_t when appropriate

Change-Id: I1b3a5879e81c789fb53d356af3d3a1ee2dca955f
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
639dbee79140956c43926344c23af765f6e0c9a5 07-Mar-2012 Glenn Kasten <gkasten@google.com> Don't ask policy manager about invalid stream type

Change-Id: If50fbff9d34045d1398984da48da7e6428a74491
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.h
92b8360fe9c3174dc0edaaab4b746d8a3d3f831f 07-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Fix indentation for re-organized code"
438b036deaf4413503567a75a2861c000d21da5b 06-Mar-2012 Glenn Kasten <gkasten@google.com> Rename updateWaitTime since a lock is held

Change-Id: I9bb978cbd0debf5b21676467060f72eebafea3e6
udioFlinger.cpp
udioFlinger.h
952eeb27682a9b2ddfa761f24b6eb5e18fe5d814 06-Mar-2012 Glenn Kasten <gkasten@google.com> Fix indentation for re-organized code

Change-Id: I63471cebdbd095b7ad4e481611b785f9b02c7941
udioFlinger.cpp
012ca6b4f69fb24385025c0e84b8f816525a3032 06-Mar-2012 Glenn Kasten <gkasten@google.com> Rename fields of AudioSessionRef

Change-Id: I9f2a66094135c4ac6bec2d3e9db3ac5fbf988ede
udioFlinger.cpp
udioFlinger.h
000f0e39b4d0c88441297a05ab5f8da6832c1640 02-Mar-2012 Glenn Kasten <gkasten@google.com> threadLoop merge

Change-Id: Id8e6330ac6be76f9c2debba94f856de87e2d98f7
udioFlinger.cpp
udioFlinger.h
3030fcefcfcfc48789612659206b957cd0489a54 01-Mar-2012 Eric Laurent <elaurent@google.com> renamed audio policy output flag.

Renamed AUDIO_POLICY_OUTPUT_FLAG_INDIRECT to AUDIO_POLICY_OUTPUT_FLAG_NONE
which is more appropriate.

Change-Id: Ia14d60397df0f2dcd9bea0186400a09da35bc104
udioPolicyService.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
udioFlinger.cpp
udioFlinger.h
bc4b08ba67a0245e092aee8f08ba30ef22d421bf 29-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Update AudioFlinger comments"
91cda8bdf8358a8b977a44e016b60a70bc1a5ee9 29-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Pull in declaration of effectChains to inner block"
73ca0f5837d5448f7a5eb159a09cd0ebe82b4de9 29-Feb-2012 Glenn Kasten <gkasten@google.com> Pull in declaration of effectChains to inner block

Change-Id: I09eacf72124942abd604132b9f4e774b1236fcf3
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
688a64030834ea2f52cc9765676ddf6aa34df767 29-Feb-2012 Glenn Kasten <gkasten@google.com> Mark similar and different sections in threadLoop

Most of these comments will be removed after the threadLoop merge.

Note: the trivial change in assignments to mixBufferSize, and the
comments about "tracks to remove" is to make them all identical.

Change-Id: I3b1a33a7f2cd12ad557a1986bb71f6171161974a
udioFlinger.cpp
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
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
a3873833d518e032138cf70188b6f33cd7acec3d 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Unlock effect chains in the middle of two if's"
3e9c3a1d34960cd258f294d31135ab6bf76179d5 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify removeNotificationClient"
a17c820c556fddf7ddd96b82b3e9874e340ffafd 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "AudioFlinger const methods and parameters"
cfbd62616ab2b12f0fee603658f04e5827cc7f8f 28-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix theoretical race condition in addOutputTrack"
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"
e628d515888baadba75442128678e747e930ed58 27-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Make threadLoop() logs identical"
d3cee0b1f77baa4fb7a049eb757e9f5006890726 27-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Move declaration of mixerStatus to inner block"
a3b09254d44cd8d66ec947abe547538c4cfeaa89 20-Jan-2012 Glenn Kasten <gkasten@google.com> Simplify removeNotificationClient

No need to check for presence of item before removing
(but we do lose the log of the previous value).

Change-Id: I2838430824de5f257f2ee15db0c22b1920c67d08
udioFlinger.cpp
02fe1bf923bbe5789202dbd5810e2c04794562e6 25-Feb-2012 Glenn Kasten <gkasten@google.com> AudioFlinger const methods and parameters

Change-Id: I93ec28024005ed23aa141518092a012a4a7c44c5
udioFlinger.cpp
udioFlinger.h
c0b52836d07f823732f0ff98ca5ca9d7f5730cb8 24-Feb-2012 Glenn Kasten <gkasten@google.com> Make threadLoop() logs identical

Change the wording of the logs in the various copies of threadLoop()
to be identical. This will make it easier to merge them soon.

Change-Id: Idfa181e437738712c784dc7f746cac79f83d2931
udioFlinger.cpp
5d4eeeaf76ebe177b43e87b2a9df5e55e39021f0 24-Feb-2012 Glenn Kasten <gkasten@google.com> Move declaration of mixerStatus to inner block

mixerStatus was being declared (and initialized) too early,
which also resulted in a duplicate initialization. Moved
the declaration into the block where it is actually used.

Change-Id: Ifdcfefe362a5efe3493dd616cdb44645c6f9aed5
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
04743e99e71c0da012508c7119f414027654ee94 24-Feb-2012 Glenn Kasten <gkasten@google.com> Unlock effect chains in the middle of two if's

As part of the upcoming threadLoop() merge, this CL makes it clearer
what are the similar and different parts before and after unlocking
effect chains.

In each threadLoop(), the old code was:

if (sleepTime == 0) {
// A
unlockEffectChains(effectChains);
// B
} else {
unlockEffectChains(effectChains);
// C
}

The new code is:

if (sleepTime == 0) {
// A
}
unlockEffectChains(effectChains);
if (sleepTime == 0) {
// B
} else {
// C
}

Also this is slightly slower by one "if", it has the advantage of making
it much more obvious about what is done before and after the unlock,
and also to see the similarities and differences among the various
copies of threadLoop().

Change-Id: I7bf4369d2dcb072573ec43b7e52c637f0097dc00
udioFlinger.cpp
5ce96d97feafc6989f6141bb2633eae3d87ddf28 24-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Pull CPU statistics code out of threadLoop()"
b6b740629c9f11535086e744465bada03f26df11 24-Feb-2012 Glenn Kasten <gkasten@google.com> Fix theoretical race condition in addOutputTrack

This is not a real race, because addOutputTrack was only called in two
places, and in both places there could be no other threads referencing
the DuplicatingThread instance.

Those two places are:
- the DuplicatingThread constructor, which is of course safe
- openDuplicateOutput - this is safe because it's called immediately
after the new DuplicatingThread, and there are no sp<> either in the
constructor or here which could cause onFirstRef() to do Thread::run().

But for safety in case addOutputTrack is ever called somewhere else,
or there are sp<> created earlier, it is safer to take the thread lock.

Change-Id: I1502d014fa37ec5dbf4bf40d3e2884af311cd5e9
udioFlinger.cpp
83efdd0fc08cd5aedf50b45741a8a87be8dc4b41 24-Feb-2012 Glenn Kasten <gkasten@google.com> Pull CPU statistics code out of threadLoop()

This is to prepare for the threadLoop() merge

Change-Id: I118c7d5c6b011b5d5b95ec7d63fb03feb166a9cf
udioFlinger.cpp
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
ndroid.mk
udioBufferProvider.cpp
udioBufferProvider.h
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
d6fd85a157ce2054b2304e6d171fa87ae09c363d 22-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Avoid wp<>::unsafe_get() with a few exceptions"
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
udioFlinger.cpp
udioFlinger.h
f063b49e95c28d63a58215ebda892a5fee4204cc 18-Feb-2012 Glenn Kasten <gkasten@google.com> Fix build warning

warning: pointer of type 'void *' used in arithmetic
warning: enumeral and non-enumeral type in conditional expression

Change-Id: I7b8d626a636145ef648e3b5d0e77068216dd012e
udioFlinger.cpp
3b81acab52b7140c1b8b20be2d67be3e221637e7 28-Jan-2012 Glenn Kasten <gkasten@google.com> Remove bit fields to improve performance

uint16_t enabled is (mostly) changed to bool in a separate CL

Change-Id: Ied9f8c034b2479cee9a8778cee7b8ff92ae75b7b
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
1b094ee8f7fe7eca65bf3d2f983ba95eef6db93d 17-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify code"
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioPolicyService.cpp
29dcfcd66d884801e9907d04e81d407ee770802c 17-Feb-2012 Mike Lockwood <lockwood@google.com> Merge "Put a bandaid on a segfault in timed audio track handling."
fe5b3ba4b332d5fc9aa4f453434329b9f38768c2 13-Feb-2012 John Grossman <johngro@google.com> Put a bandaid on a segfault in timed audio track handling.

Add a bandaid to prevent a segfault which can occur while handling
timed audio buffers. There is a deeper problem which should
eventually be addressed, but for now this fix should prevent any
crashing.

The deeper problem is as follows.

When the AudioFlinger mixer gets data to mix from an AudioTrack, it
ends up getting a structure filled out which points into an IMemory
region owned by the AudioTrack. Unfortunately, this structure is not
holding a refcount on the IMemory which it points into. If the
IMemory refcount hits 0 and the chunk of RAM is retuned to the binder
heap it came from, there can still be a Buffer object being held by
the AudioFlinger mixer which points into the region of memory which
was retuned to the binfer heap. If AF reads from this buffer, it
could read corrupt data (if the region of memory gets handed back out
to a writer), or it could segfault (if the heap has been freed and the
pages unmapped). Similar problems could happen if AF attempts to
write to the buffer, heap corruption in one case, segfaulting in the
other.

In the past, this has not been an issue for AF, because tracks
allocate a single IMemory (which serves as a ring buffer) and the
IMemory lives for as long as the track lives. As an artifact of the
way the code came out, the mixer cannot be holding a Buffer structure
pointing into the IMemory which used to be owned by a track if the
track no longer exists. Tracks cannot come into or out of existence
during a mix operation, which is the only thing which makes this safe.

TimedTracks work differently, however. Timed tracks each allocate a
small binder heap, and then hand out IMemory instances broken out of
this heap. The heap lives as long as the track, so the worst which
could happen here is that a TimedTrack's IMemory gets returned to the
heap while there is still a buffer structure in flight pointing into
the memory region, then the region gets handed out again and
overwritten by new data causing the mixer to mix the wrong audio. The
timing to cause this to happen is very difficult to encounter, and you
to generate the timing conditions required, you need to be in a pretty
bad failure state where audio is already breaking up and skipping, so
its unlikely that anyone would notice (which is why I'm band-aiding
the segfault and letting the deeper issue slide for now).

In general, however, it might be a good idea to revisit this buffering
design. On principal, if someone is going to hold pointers into a
refcounted object, they should be holding a ref on the object at the
same time. Failure to do this will usually lead to a situation where
there are corruption or segfault issues, or to a system where the
refcounted object's lifetime must be implicitly managed very carefully
in ways which are usually non-obvious and are easy to break by new
engineers on a project.

Change-Id: Ib391075395ed0ef46a03c37aa38a82d09e88abeb
udioFlinger.cpp
9fda4b87441fe17d90d8144639c9de6d9022c3c0 02-Feb-2012 Glenn Kasten <gkasten@google.com> Fixed possible heap corruption in EffectDesc

"EffectDesc *effect = new EffectDesc(*effects[i]);" was relying on the
default copy constructor for EffectDesc, but the default copy constructor
does a member-by-member copy. This works OK for mUuid, but a member
copy of mName and mParams shares pointers. This could result in heap
corruption later on due to a double free. Changed to add an explicit
copy constructor that does a deep copy of both mName and mParams.

A malloc() and strdup() were being freed by delete, but the correct
matching API for these is free(). Fortunately our current memory runtime
implementation ignores the difference. Changed to use free().

EffectDesc and InputSourceDesc member fields were being torn down by
the code that does delete. Changed to do the tear-down in ~EffectDesc()
and ~InputSourceDesc().

Added constructor EffectDesc() with name and UUID parameters, rather
than having caller fill in the object after construction.

Made ~EffectDesc() and ~InputSourceDesc() non-virtual to save memory,
since they have no subclasses.

Change-Id: Ibb5cc2e6760d72e0c4cf537068ac4432c717bafd
udioPolicyService.cpp
udioPolicyService.h
ef7740be67a4d7b6b033ebed59c3d4a9c74a2c18 09-Feb-2012 John Grossman <johngro@google.com> Fix a segfault in AudioFlinger.

Check the string returned by a HAL's implementation of get_parameters
for NULL before attempting to make use of it. That way, we won't
bring down the mediaserver because of a poorly written HAL.

Change-Id: Ic99d7b004520d7d6347842a681c0595e889b68ea
Signed-off-by: John Grossman <johngro@google.com>
udioFlinger.cpp
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>
ndroid.mk
udioBufferProvider.cpp
udioBufferProvider.h
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioResampler.cpp
udioResampler.h
udioResamplerCubic.cpp
udioResamplerSinc.cpp
6dad4378f2a78d967defc8912ecf47f6ed117584 14-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix races related to volume and mute"
d9b9b8d09e7471b0ffa21cfa9f944ef4ad300a71 14-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Update comments"
99e53b86eebb605b70dd7591b89bf61a9414ed0e 19-Jan-2012 Glenn Kasten <gkasten@google.com> Update comments

We no longer put the filename at start of file.

Change-Id: Ic435b159a23105681e3d4a6cb1ac097bc853302e
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
8d6a2449a91f5116d7243ab039393195ebd663fe 08-Feb-2012 Glenn Kasten <gkasten@google.com> Use size_t and ssize_t with Vector

Use size_t with size() and ssize_t with indexOfKey(). Exception:
use ssize_t for backwards loops, and indices that are overloaded as a
marker or error code.

Change-Id: Ibf2a360af4539b72b09c818dda22ea2a0de92431
udioFlinger.cpp
udioPolicyService.cpp
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
udioFlinger.cpp
udioFlinger.h
44deb053252a3bd2f57a007ab9560f4924f62394 06-Feb-2012 Glenn Kasten <gkasten@google.com> Factor out and speed up permission-checking code

Use the caching permission check for dump to save IPC.

Cache getpid() to save kernel call for other permission checks.

The C runtime library getpid() can't cache due to a fork
race condition, but we know that mediaserver doesn't fork.

Don't construct String16 on the stack.

Change-Id: I6be6161dae5155d39ba6ed6228e7683e67be34ed
ndroid.mk
udioFlinger.cpp
udioPolicyService.cpp
erviceUtilities.cpp
erviceUtilities.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
udioFlinger.cpp
udioFlinger.h
b6333aa8317ce5162ab006c4baed6b0890936dc7 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify ThreadBase::exit() aka requestExitAndWait"
3a144d08b713e3c0f6b7b8e95bc42cef5886f4fa 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Disable HQ resamplers for now until qualified"
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)"
95a87908ddf240760e8e8b35a6cafcc149c7f33f 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Remove aliasing"
c8ad36bbb30e99e49026cba78e5e0f83db5cb0f6 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use mul from audioutils"
31f0acff69efd46897221d847becca79ab15105f 11-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Mark fields const if only set in constructor"
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
udioFlinger.cpp
udioFlinger.h
9d1f02d74fd395ec4de6861147da289423f0ab6f 09-Feb-2012 Glenn Kasten <gkasten@google.com> Follow raw pointer and sp<> conventions

Unconditional delete for raw pointers.
Use "if (sp != 0)" not "if (sp.get() != 0)" or "if (sp != NULL)".
Use "if (raw != NULL)" not "if (raw)".

Change-Id: I531a8da7c37149261ed2f34b862ec4896a4b785b
udioPolicyService.cpp
0ba18ec1b343a8de70924f87630dd1f329b00fe6 10-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "No newline or space at end of ALOG format string"
12018d80add66f5558675614d73fa6549150806e 10-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Move declaration of stream_type_t up earlier"
8b5980798ca06e57b1284e6e23fa220e1207bf41 10-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix typos in ALOG for pid vs tid"
cdf2158f3b9498d6cd0eb228d8bee16e32399e16 02-Feb-2012 Glenn Kasten <gkasten@google.com> Disable HQ resamplers for now until qualified

This saves about 6500 bytes.

Change-Id: I87102fe561c95c19c9e615dea3de914f96639257
ndroid.mk
udioResampler.cpp
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
udioFlinger.h
004f719467c498942c40de9f260be601ee45e630 30-Jan-2012 Glenn Kasten <gkasten@google.com> Mark fields const if only set in constructor

Change-Id: Iacd06bb9efaf708cf965033be1f2297b58f7f75c
udioResampler.h
d198b61603d5fa9298edea4ddb5852ea45159906 02-Feb-2012 Glenn Kasten <gkasten@google.com> Remove aliasing

Code was aliasing mBuffer as buffer, but continuing to use both buffer
and mBuffer after that point. This was at best misleading, and at worst
could confuse the compiler into generating bad code. There was no
performance advantage to the alias, in fact removing it saves 16 bytes.

Change-Id: I55023ddba465d9be82f66745b088d18af658ac60
udioResamplerSinc.cpp
58123c3a8b5f34f9d1f70264a3c568ed90288501 03-Feb-2012 Glenn Kasten <gkasten@google.com> Camel case readability & private disconnect(bool)

Change-Id: If66516ed2703e048c5e6ccc6cd431446a024f4a1
udioFlinger.cpp
udioFlinger.h
5b9ff43995f6a6b819d9ad37dd8cdc5ad4a088d7 09-Feb-2012 Glenn Kasten <gkasten@google.com> Use mul from audioutils

I verified that the disassembled output is identical.

Change-Id: I34a76f0842ebc4aef2c923e079e38d0bc1f98b5c
udioFlinger.cpp
23d82a9bc9a43b49ba684ba40875b91db310d3b9 03-Feb-2012 Glenn Kasten <gkasten@google.com> Fix typos in ALOG for pid vs tid

Change-Id: I6dc70f137d0ff8a86427ab8882a81886e1de0782
udioFlinger.cpp
udioPolicyService.cpp
90bebef5669a9385c706b042d146a31dca2e5d9b 28-Jan-2012 Glenn Kasten <gkasten@google.com> No newline or space at end of ALOG format string

Change-Id: I0bef580cbc818cb7c87aea23919d26f1446cec32
udioFlinger.cpp
udioResampler.cpp
udioResamplerCubic.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
98ec94c5854daccc3474758524e7f4adfe535ce0 25-Jan-2012 Glenn Kasten <gkasten@google.com> Combine duplicate code & document wp<> in mClients

Change-Id: Iea8cfe8e57563337fb2484a1246ef79d6ad3db18
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
dbfafaffe2e97eaf8d74ec6b6c468418a1ad2443 26-Jan-2012 Glenn Kasten <gkasten@google.com> Simplify destructors

Remove explicit clear() when the order doesn't matter.

Change-Id: I5931bc7ef5f681c7ce329aa9ec0a6e46d34a56c5
udioFlinger.cpp
5e92a7861196ddae14638d4b7a63fc4892b7ef59 30-Jan-2012 Glenn Kasten <gkasten@google.com> Effect UUID inputs passed by pointer are const

Change-Id: I1f5c338bcb7368e3dd8cd5f804b2e6d9fbe087f8
udioFlinger.cpp
udioFlinger.h
0a20fa9c41c96e31fa20e071074a4b6e7f6c41c3 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use pid_t not int"
b61ec89bb0c701b3bd06eb658f854230681f8b39 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Don't double destruct audio_track_cblk_t"
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"
e616d4e6de6d53ddebbc3d7fb381af94589c2232 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Improve performance for sp<> on stack"
1579d7948117e3e6541b0cfda02cc5234a3280ea 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use 0 not NULL for sp<> and wp<>"
b5a66e15f371143f48665bbd462d75309582845d 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use bool instead of int"
e98bbd36d67243fe987b09904956550a68af1cc7 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Declare more IAudioFlinger methods const"
1a0ae5be3d1273cba12584b33830d859510fbf82 03-Feb-2012 Glenn Kasten <gkasten@google.com> Don't double destruct audio_track_cblk_t

Fortunately audio_track_cblk_t doesn't have a destructor, but for clarity
remove the double destruction.

Also add warning not to add any virtuals to audio_track_cblk_t.

Change-Id: I70ebe1a70460c7002145b2cdf10f9f137396e6f3
udioFlinger.cpp
bb001926447d0b7dc71ca8bb3c9856f3136d8f4c 03-Feb-2012 Glenn Kasten <gkasten@google.com> Use pid_t not int

Change-Id: Iad1c2fd4152e94080ad8c65c13ddf4519fc2ed27
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioResampler.cpp
udioResampler.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
udioFlinger.cpp
udioFlinger.h
4c340c6521b634f159d2d6bc4e9359226fd8edf8 27-Jan-2012 Glenn Kasten <gkasten@google.com> Use bool instead of int

The .h is not modified to avoid increasing data size.

Change-Id: Ide4a821a5b16424ffa03471dfff98dc3e9b5f751
udioMixer.cpp
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioResampler.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
udioFlinger.h
udioMixer.h
udioResamplerSinc.h
7378ca506e4e20c2b2d4e94a131cf1b95831adb5 20-Jan-2012 Glenn Kasten <gkasten@google.com> Use 0 not NULL for sp<> and wp<>

Change-Id: Id1f0c89acefaceed6cb9ca7c165fce895e46d85b
udioFlinger.cpp
udioPolicyService.cpp
787bae0578fbaab6219ebf23494866b224d01438 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_in_acoustics_t consistently"
ff3c83e04ae459c4252b86dd4440b4e37ee92c16 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use ToneGenerator::tone_type consistently"
a0d68338a88c2ddb4502f95017b546d603ef1ec7 28-Jan-2012 Glenn Kasten <gkasten@google.com> Use NULL not 0 for raw pointers

Use if (p != NULL) instead of if (ptr)

Change-Id: Iaec3413a59ccbf233c98fcd918cc7d70ac5da9fa
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
87f155d6655b2d3b27e69281a29e85c6407e4d26 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "For performance, return large objects by reference"
f81e97e4ec8b01965a5b36987f886cf5001f71ff 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "No need to check a wp<> for 0 before promote()"
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
5c0ad10b14ec2287f90f95912d98e66eef006e2a 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Cleanup thread types"
62da7fbd60bee2dd57f503126266e9f04311d400 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Make AudioTrack control block volume field private"
d45ee9d9d61af0791c7c3c51f8d4fe6794ef02a5 02-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Fix const sp<>& in parameter list and return value"
d05397144be774f2f3623c754e865f51753e4e31 30-Jan-2012 Glenn Kasten <gkasten@google.com> For performance, return large objects by reference

Change-Id: Ibf737018ef1d3c7d717584615dcb2d4ecdb50c99
udioFlinger.cpp
udioFlinger.h
090f01963e215f895020a31e22368cd44e086ce3 30-Jan-2012 Glenn Kasten <gkasten@google.com> Improve performance for sp<> on stack

Combine default constructor for sp<> immediately followed by assignment,
as the reference-counting is relatively slow. Also return sp<> directly
rather than via local variable, for the same reason.

Change-Id: If55931f1e407994f6591ddde41b53db72fb4fc40
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
e9dd0176933d6233916c84e18f3e8c0d644ca05d 28-Jan-2012 Glenn Kasten <gkasten@google.com> Unconditional delete

Don't check that pointer is non-NULL before delete.

Don't leave deleted member fields non-NULL, except in a destructor,
since it could be misleading in a dump or debugger. (mRsmpOutBuffer)

Change-Id: Ic0492a6b752f74a67f4c96dfb89ca2de4e69eecf
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
77c1119ea0b5cb32287088ceeeb7e3b6bd14a85d 25-Jan-2012 Glenn Kasten <gkasten@google.com> No need to check a wp<> for 0 before promote()

Also remove unnecessary wp<> local variable.

Change-Id: I620e67b5d559d28616f8e00609a525cfe19c5ddc
udioFlinger.cpp
3d2f877c1cb4e4ae4ddde7f57f4353de9341f11b 28-Jan-2012 Glenn Kasten <gkasten@google.com> Use ToneGenerator::tone_type consistently

Also remove defaults in startToneCommand(), they're not needed and the
default for tone type was nonsense.

Change-Id: I70fa8cee4f3dbb8c66ceb3719c8d3d2f447f05b9
udioPolicyService.cpp
udioPolicyService.h
de9719b3ec71472e6bf75117152176af51d1a515 27-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_in_acoustics_t consistently

Change-Id: I0a9dd668fb2e57b1c3ece3190588194974b99062
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
fd267d7cf640225bb57f0ed1af44efc153275f6d 27-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_source_t consistently"
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"
eba51fb3a361f67a6a64d5a16eba6084fe27d60e 23-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_source_t consistently

Was a mix of audio_source_t, uint8_t, and int.

Related fixes:
- fix comments in MediaRecorder.java
- AudioPolicyService server side was not checking source parameter at
all, so if the client wrapper was bypassed, invalid values could be
passed into audio HAL
- JNI android_media_AudioRecord_setup was checking source for positive
values, but not negative values. This test is redundant, since already
checked at Java and now checked by AudioPolicyService also, but might
as well make it correct.

Change-Id: Ie5e25d646dcd59a86d7985aa46cfcb4a1ba64a4a
udioPolicyService.cpp
udioPolicyService.h
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
29c23c3aee5ae799b3480dc6876a46c46b019710 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum mixer_state consistently

Change-Id: I5b71ed20f939dfc4b98143334b7aa064d282f584
udioFlinger.cpp
udioFlinger.h
28243dd563fee1c82f0fff6cc27b5cbf21fa2585 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum effect_state consistently

Also fix indentation

Change-Id: I393ef9e37ffceed5ad4a78df439726ae1fe139df
udioFlinger.h
b853e986caf43408ad95b9014f194aadff385e3c 26-Jan-2012 Glenn Kasten <gkasten@google.com> Use enum track_state consistently

Change-Id: Ie5ebb7befa092e1de1e4df9c6e2d51e6bcfd176a
udioFlinger.cpp
udioFlinger.h
9365ea9bf2e439b3e71abbabe22ce7382ebc4b3a 25-Jan-2012 Eric Laurent <elaurent@google.com> am 535b0264: am 7eeaf3f0: Merge "AudioFlinger: refine mixer sleep time logic" into ics-mr1

* commit '535b0264a4cfa790e549bd9cd09980788f1375f4':
AudioFlinger: refine mixer sleep time logic
84e19873fde204d73628ba1b5ca9e3f5778574fa 24-Jan-2012 Eric Laurent <elaurent@google.com> am 7eeaf3f0: Merge "AudioFlinger: refine mixer sleep time logic" into ics-mr1

* commit '7eeaf3f07aa6fb10639d9f96c1367eb98c3e8839':
AudioFlinger: refine mixer sleep time logic
7c5aea0a8d9b422999483f96a2566f77ff11abf2 24-Jan-2012 Eric Laurent <elaurent@google.com> am 41773d46: Merge "DO NOT MERGE Revert "Revert "AudioFlinger: mix track only when really ready (2)""" into ics-mr1

* commit '41773d46556aa47d4322ff89fdaf7d1345c2d1f2':
DO NOT MERGE Revert "Revert "AudioFlinger: mix track only when really ready (2)""
21e4b6ed00e814bffc70895847a4944d7a190020 24-Jan-2012 Eric Laurent <elaurent@google.com> AudioFlinger: refine mixer sleep time logic

When an AudioTrack is in underrun state, the AudioFlinger mixer will
sleep for a short period of time to give the app a chance to fill the
AudioTrack buffer. If the AudioTrack is still not ready during next mixing round,
the mixer will proceed with other tracks.

If an application keeps a steady underrun condition, the AudioFlinger mixer will
alternate between ready and not ready states. In the longer term this will cause the
audio HAL to underrun.
There is a mechanism to reduce the sleep period if the mixer is not ready several times in a
row but this mechanism is defeated by the alternating ready/not ready conditions.

The fix consists in only increasing sleep time if the mixer is ready for at least two
consecutive times.

Issue 5904527.

Change-Id: Id0139bca9be8c4e425ec6d428515c4d8f718e8c9
udioFlinger.cpp
eaa0b5cc2f7723e9b25298126d0dcb48c56d5dac 24-Jan-2012 Eric Laurent <elaurent@google.com> DO NOT MERGE Revert "Revert "AudioFlinger: mix track only when really ready (2)""

This reverts commit b918035d34422a2041b6ec8c09c566bb93345b40.

Change-Id: I093bcfa56ad54a080b930208b6b79169d33581fb
udioFlinger.cpp
udioFlinger.h
15dfda272eec983508b89fb8bc9ca6f2bb825496 24-Jan-2012 Justin Ho <justinho@google.com> am fee5a860: Merge "DO NOT MERGE Revert "AudioFlinger: mix track only when really ready (2)"" into ics-mr1

* commit 'fee5a860a8355cda071ff23644e943414ba7f65d':
DO NOT MERGE Revert "AudioFlinger: mix track only when really ready (2)"
7baf7894bc2f1a62440f381eeb50143f210a5d61 23-Jan-2012 Justin Ho <justinho@google.com> DO NOT MERGE Revert "AudioFlinger: mix track only when really ready (2)"

This reverts commit 71c4496a9757438afd30b4404824f296f6158a49.

Change-Id: Iff10c49ea728bb10023ddeb50a3b708db770fff2
udioFlinger.cpp
udioFlinger.h
335787fe43596f38ea2fa50b24c54d0823a3fb1d 21-Jan-2012 Glenn Kasten <gkasten@google.com> Remove AudioFlinger dependencies on client

Change-Id: Ibb591e41a3ca5d7015e2b66b98b8fef5f415fb37
udioFlinger.cpp
udioFlinger.h
83d86538c4c479a9225c75ab27938e8f05abb9c8 17-Jan-2012 Glenn Kasten <gkasten@google.com> Make AudioTrack control block volume field private

This is part of the process of abstracting the control block
to make it easier to maintain.

Change-Id: Idb8f461e68dab3bcf268159cc0781651c6fb7094
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
d967f0a099db2b71597a3127134afd4a46287a4a 20-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Remove redundant get()"
7fc9a6fdf146ded90b51c52f4a05d797294dcb85 10-Jan-2012 Glenn Kasten <gkasten@google.com> Remove redundant get()

get() is almost always unnecessary, except in a LOG.
Also no need to check for != 0 before calling get().

Change-Id: Ib06e7a503f86cf102f09acc1ffb2ad085025516d
udioFlinger.cpp
ea3cc3bca949139e401b77f2ac0cce7ac6e76f8f 20-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Remove dead setRingerMode(mode, mask)"
a3db30f7c53936a3acb87d2c44807ee2f0cfa16e 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am 9d25b82d: Merge "Rename LOG_ASSERT to ALOG_ASSERT"

* commit '9d25b82d280c2d979d500e7da4447148f32f820b':
Rename LOG_ASSERT to ALOG_ASSERT
d746737921074e2a6c39c52b06022c5166689df5 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am 6df477be: Merge "Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF)"

* commit '6df477be186233e36fc370c4d2db6c1ed928a740':
Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF)
daef36f5d4934bd055c694a8d54b86e2b50a6159 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am a826f9e2: Merge "Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF)"

* commit 'a826f9e2c4f6329d8d48c927f6e942e78ffaf92f':
Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF)
3734cbca25c6d902677cfb5e59dff7a1cb17a45d 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am 4f367f33: Merge "Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF)"

* commit '4f367f3387887c538c81c34cc8becaea6fa5e430':
Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF)
e744a90eb52bf9547848c08380cfb7ba7e63ffbc 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am ba7f0d2a: Merge "Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)"

* commit 'ba7f0d2a03643ce429421b81febf18fd50473070':
Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)
ca05a87f4c69670a06bdee4b4f98bcdcd838beda 20-Jan-2012 Jean-Baptiste Queru <jbq@google.com> Merge ee4618bc

Change-Id: Ie1dc6ad38e7c30636d80f6caef11cf6673144940
39fd8eb956dea32692d3d72b10b64a8597df0a40 09-Jan-2012 Steve Block <steveblock@google.com> Rename LOG_ASSERT to ALOG_ASSERT

Change-Id: Ie2c7ea6560656d65bad791a61996174c75677517
udioResampler.cpp
udioResamplerCubic.cpp
9a8ded7348c5b2302dd27b285b395416bc842c49 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF)

Change-Id: I1de629b4632a4b3187ca1a28d6416daccd35f924
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResampler.cpp
aa70226152d2084f85a96b52359dbc8476a86a45 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF)

Change-Id: I8fbdfa7a7581f481968dbb65aa40f7042936d7cb
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResamplerCubic.cpp
53feeb42c721e8fc9285e35e679906a951f3277c 04-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF)

Change-Id: I26f76452ac49e2890b14d133c065493d8df0fb4a
udioFlinger.cpp
udioPolicyService.cpp
52546c0ef96aa3e7e21482e0f9b6e982557c8da9 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)

Change-Id: I44f267700356967dc51e8f85ebf457dc85cfb229
udioFlinger.cpp
udioMixer.cpp
udioResampler.cpp
3812256de32e73e38ba16e50ac0451c10223d4eb 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF)

Change-Id: I5321ebd12e9c6248a108529e82c4e1af2a4405e3
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResampler.cpp
aeeb7e219e34d2d657d829913659a4e10e976375 19-Jan-2012 Eric Laurent <elaurent@google.com> resolved conflicts for merge of 05683c85 to master

Change-Id: I7846b7da8c5813b7a9b1f3f71aede0229689ff0d
86905f445c96743b037eed6360afa956a85b019c 19-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Add units to time periods"
ca42b286a162f5cd6a4a916bfe429abe95780730 19-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use const const strings for arrays and pointers to strings"
22ecc912a87099cff8cadc424cd12f85c118673f 09-Jan-2012 Glenn Kasten <gkasten@google.com> Add units to time periods

Change-Id: Ib980e2676cecf5d9b0c2e388da6dc8e370df8abb
udioPolicyService.cpp
8dad0e31c2366c501bd1d600261d0af35a6ca786 09-Jan-2012 Glenn Kasten <gkasten@google.com> Use const const strings for arrays and pointers to strings

Change-Id: I0a073e17ebf6ad59e7edbedac104c6fa4bcaf9c9
udioPolicyService.cpp
udioPolicyService.h
f1d4592d4c3c99ebab55559e164ff102e825283e 14-Jan-2012 Glenn Kasten <gkasten@google.com> For booleans, use ! instead of == false

Change-Id: Ibc115936d2d0b0b7744ebe9b52839ea5b42c4edd
udioFlinger.cpp
udioPolicyService.cpp
0b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7 18-Jan-2012 Glenn Kasten <gkasten@google.com> Remove dead setRingerMode(mode, mask)

Change-Id: Ia4cc8be8424a40b3dcb7ebd0264fdff4e5247f7f
udioPolicyService.cpp
udioPolicyService.h
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
udioFlinger.cpp
udioFlinger.h
04eaf3e5f20d7faa956c0d672024ffb5117f4c26 18-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Track volume cleanup"
63ad6aacc6ce6b729bf25f41376cfea731a2c1eb 18-Jan-2012 Eric Laurent <elaurent@google.com> Merge "audio framework: manage stream volume per device"
b1cf75c4935001f61057989ee3cf27bbf09ecd9c 17-Jan-2012 Glenn Kasten <gkasten@google.com> Track volume cleanup

Always read and write track volumes atomically. In most places this was
already being done, but there were a couple places where the left and
right channels were read independently.

Changed constant MAX_GAIN_INT to be a uint32_t instead of a float.
It is always used as a uint32_t in comparisons and assignments.
Use MAX_GAIN_INT in more places.

Now that volume is always accessed atomically, removed the union
and alias for uint16_t volume[2], and kept only volumeLR.

Removed volatile as it's meaningless.

In AudioFlinger, clamp the track volumes read from shared memory
before applying master and stream volume.

Change-Id: If65e2b27e5bc3db5bf75540479843041b58433f0
udioFlinger.cpp
83844cc2f95dc279015b47fd1e18c7cb4eabe9a1 19-Nov-2011 Eric Laurent <elaurent@google.com> audio framework: manage stream volume per device

Improve volume management by keeping track of volume for each type
of device independently.
Volume for each stream (MUSIC, RINGTONE, VOICE_CALL...) is now maintained
per device.

The main changes are:
- AudioService now keeps tracks of stream volumes per device:
volume indexes are kept in a HashMap < device , index>.
active device is queried from policy manager when a volume change request
is received
initalization, mute and unmute happen on all device simultaneously
- Settings: suffixes is added to volume keys to store each device
volume independently.
- AudioSystem/AudioPolicyService/AudioPolicyInterface: added a device argument
to setStreamVolumeIndex() and getStreamVolumeIndex() to address each
device independently.
- AudioPolicyManagerBase: keep track of stream volumes for each device
and apply volume according to current device selection.

Change-Id: I61ef1c45caadca04d16363bca4140e0f81901b3f
udioPolicyService.cpp
udioPolicyService.h
ad0f6cc5e115ca167ff122c83451b46d85c590ac 17-Jan-2012 Glenn Kasten <gkasten@google.com> Remove dead setVolume() and mVolume[2]

Change-Id: I94b835434093e920432614eb5007101e87758f32
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
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"
0107954f72153db747a3727dc1157e9236dfed90 17-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_stream_type_t consistently"
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
udioFlinger.cpp
udioFlinger.h
05632a5fa4b88ca474294887fc92a9fcdf0e2352 03-Jan-2012 Glenn Kasten <gkasten@google.com> AudioTrack and AudioFlinger send level cleanup

Add an API to control block for getting/setting send level.
This allow us to make the mSendLevel field private.

Document the lack of barriers.

Use 0.0f to initialize floating-point values (for doc only).

Change-Id: I59f83b00adeb89eeee227e7648625d9a835be7a4
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
e3a067f8bc98134941ee1a4da8c2a92a15aaa9cc 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify range check for audio_mode_t"
c40256146bee58bff09e1c16ef99ea06d31f89f9 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use correct type for hardware call state"
2ea3410d0d3d592ce30c3ba0ce3e0e63b1244057 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use consistent style of & reference for AutoMutex"
9770988e61961d34033fd2c12f0de85a267df68f 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "AudioFlinger new can't fail"
02b2d2dddc9be339cf7647d4ead53cecd1c51038 11-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Fix build warning"
930f4caa1e311ef7ff538c421a324396157eb24f 07-Jan-2012 Glenn Kasten <gkasten@google.com> Simplify range check for audio_mode_t

AudioSystem::setMode previously allowed negative modes, but these were
then rejected by AudioFlinger.

Now negative modes (including AUDIO_MODE_INVALID and AUDIO_MODE_CURRENT)
are explicitly disallowed.

Change-Id: I0bac8fea737c8eb1f5b6afbb893e48739f88d745
udioFlinger.cpp
udioPolicyService.cpp
c1dc1cb1d1eaf84e88669f1a5f22579a0d9237c2 09-Jan-2012 Steve Block <steveblock@google.com> Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE

See https://android-git.corp.google.com/g/157519

Bug: 5449033
Change-Id: I8ceb2dba1b031a0fd68d15d146960d9ced62bbf3
udioFlinger.cpp
udioResampler.cpp
udioResamplerCubic.cpp
5f29ca38b71506ad7c7cb9925efbddf588e9655b 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "By convention const goes before the type specifier"
25b248eb52a0a16adaef6b79c9d92cb88b9a2bc2 04-Jan-2012 Glenn Kasten <gkasten@google.com> Use cached reference to media.player service

This save unnecessary binder calls

Change-Id: I93a60efc54d9c8fb8fab706cd4477bbfd00ffec8
udioFlinger.cpp
879bc64e43d62f2690c77a3282cef2e45d1b76e9 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Replace loop by __builtin_ctz"
febdbfec3b1ed0e20aa4f10bfdd82702d3e41f4b 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "suspended() and isSuspended() are const"
29357bc2c0dd7c43ad3bd0c8e3efa4e6fd9bfd47 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResampler.cpp
4a6f02833d8421b7d9b20f89729d8bb03b8b8102 07-Jan-2012 Glenn Kasten <gkasten@google.com> AudioFlinger new can't fail

Change-Id: I7dae05a5ea1c962a9975386eab1fedbbe106ffba
udioFlinger.cpp
a7d8d6fc5e102a08b262a1b78aa1abeeb097d9e4 06-Jan-2012 Glenn Kasten <gkasten@google.com> Use consistent style of & reference for AutoMutex

AutoMutex, which is a typedef for Mutex::Autolock, is overloaded for
either a reference (&) or pointer (*) parameter, but we prefer to use
the reference form when the mutex is known at compile time.

Change-Id: I3515e6d6ab7959b2356a27fa3b04fd49e42cb31e
udioFlinger.cpp
a4454b4765c5905f14186893b0688be375642283 04-Jan-2012 Glenn Kasten <gkasten@google.com> Use correct type for hardware call state

Change-Id: Ic6d98b129e3ec653df1d8f7e829adf8dccb4f378
udioFlinger.cpp
udioFlinger.h
54c3b66444ebfb9f2265ee70ac3b76ccefa0506a 06-Jan-2012 Glenn Kasten <gkasten@google.com> By convention const goes before the type specifier

Change-Id: I70203abd6a6f54e5bd9f1412800cc01212157e58
udioFlinger.h
udioMixer.cpp
udioMixer.h
udioResamplerSinc.cpp
udioResamplerSinc.h
f9a27779634ce3a01e5957f234cd04eba74fa07f 06-Jan-2012 Glenn Kasten <gkasten@google.com> Fix build warning

Change-Id: Ic99608d0c14ed56c02f036e0bbaaae1b16bab8ba
udioMixer.cpp
5ff1dd576bb93c45b44088a51544a18fc43ebf58 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResamplerCubic.cpp
98dd542ffcd3424b1da58bd273c0c1ff5b8c8960 15-Dec-2011 Glenn Kasten <gkasten@google.com> Replace loop by __builtin_ctz

Using the builtin is faster on some platforms, for example on ARM it's
19 instructions instead of 13, and is O(1) instead of O(n). Of course,
track creation is an inherently slow operation, so this doesn't matter
much now. But if we add support for virtual tracks, then physical tracks
will be allocated/freed more frequently. Also just on principle ...

Change-Id: I3f590934092bd7a1869cbedbc7357928aa5cc8ff
udioMixer.cpp
8a08dcc0a5de19a904e77d5f31bed3dff9a59890 05-Jan-2012 Steve Block <steveblock@google.com> Merge "Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE"
a3a854868a80fd9b9b8720e06a172754943f9417 04-Jan-2012 Glenn Kasten <gkasten@google.com> suspended() and isSuspended() are const

Change-Id: I04b95970b5a645b64e7e64fffd46d868354dda66
udioFlinger.cpp
udioFlinger.h
88592eccaf6afcddd5f985955be92fe25205c680 05-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Remove the notion of "active track" from mixer"
a2a0a5d7d56baa831870f4bf2a0d942a477d92ef 05-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use the standard CC_LIKELY and CC_UNLIKELY macros"
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.h
7ab41c9f773ba599646f1b0d00955c1be80f92fd 05-Jan-2012 Eric Laurent <elaurent@google.com> resolved conflicts for merge of 1a4b9939 to master

Change-Id: I0c910d391a38a916d8431f7d1f5b82e39e1a66c2
df64d15042bbd5e0e4933ac49bf3c177dd94752c 04-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ib08fe86d23db91ee153e9f91a99a35c42b9208ea
udioFlinger.cpp
udioPolicyService.cpp
b8a805261bf0282e992d3608035e47d05a898710 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
udioFlinger.cpp
udioMixer.cpp
udioResampler.cpp
071ccd5a9702500f3f7d62ef881300914926184d 23-Dec-2011 Eric Laurent <elaurent@google.com> audioflinger: fix clicks on 48kHz audio.

The calculation done in prepareTracks_l() for the minimum amount
off frames needed to mix one output buffer had 2 issues:
- the additional sample needed for interpolation was not included
- the fact that the resampler does not acknowledge the frames consumed
immediately after each mixing round but only once all frames requested have been used
was not taken into account.
Thus the number of frames available in track buffer could be considered sufficient although
it was not and the resampler would abort producing a short silence perceived as a click.

Issue 5727099.

Change-Id: I7419847a7474c7d9f9170bedd0a636132262142c
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
udioResampler.h
9c56d4ae6212c21ce5fd71ed534eb195983a07c1 20-Dec-2011 Glenn Kasten <gkasten@google.com> Remove the notion of "active track" from mixer

This is a first step towards making the mixer more object-oriented.

Change-Id: Ifd445d0e471023a7f5c82e934736ffc95ba1b05b
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
12d9702773c8a3242a44dd6528126c9ff0dade43 20-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Remove dead code"
bbaf8673f1d1dd79d1b7f474ca7111da58e84aff 20-Dec-2011 Eric Laurent <elaurent@google.com> Merge "audio effects: rename configure command"
3d5188bd6abe55898f10a0edf3c05aff8aa2ef67 17-Dec-2011 Eric Laurent <elaurent@google.com> audio effects: rename configure command

Renamed audio effect library interface command for audio format
configuration from EFFECT_CMD_CONFIGURE to EFFECT_CMD_SET_CONFIG.
This makes the naming more consistent with other exixsting commands
and allow adding a new command to get the configuration (EFFECT_CMD_GET_CONFIG).
Same change for reverse channel configuration renamed from
EFFECT_CMD_CONFIGURE_REVERSE to EFFECT_CMD_SET_CONFIG_REVERSE.

Implemented EFFECT_CMD_GET_CONFIG in exisitng effect libraries.

Change-Id: Ia7b1c620f13797fe5aceb3b0b4acbacce09fb067
udioFlinger.cpp
81a028fef62bcadf13fc8550067a3d29c918b3ca 15-Dec-2011 Glenn Kasten <gkasten@google.com> Remove dead code

Change-Id: Icf23f7f90fdeb660f4015f22cf239e6d05f5d03c
udioMixer.cpp
udioMixer.h
f602a5f7f29e694a7da4c143737b74501c00477d 17-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Use constants for 2 and 32"
d1e672acd8fa1af899f85ee2321327237028adf8 17-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Extract out audio DSP code to utility library"
bf71f1e7948406492376c6cbd5e6a30c8cb670e4 13-Dec-2011 Glenn Kasten <gkasten@google.com> Use constants for 2 and 32

Change-Id: If820dfd58b6df258570750610a07af99598d9e53
udioMixer.cpp
udioMixer.h
b92bc47a05925c29efef0d66711b6d3f17f406e7 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Use switch in AudioMixer::setParameter"
788040c5189bbdaf567ce4b29ffd1db08ea1020c 05-May-2011 Glenn Kasten <gkasten@google.com> Use switch in AudioMixer::setParameter

Replace series of if/then/elses by easier-to-read switch. Also return
void instead of status_t, since callers weren't checking it. Assert on
bad input parameters.

Change-Id: Ie1f0a297977b28501d20e1af819afed9b4750616
udioMixer.cpp
udioMixer.h
237a624f674800d2300806b115eee8c9bb7db033 16-Dec-2011 Glenn Kasten <gkasten@google.com> deleteTrackName now asserts on bad input parameter

This is safe, as the input parameter is always track->name(),
which must be valid.

Change-Id: Iea8ea3a5706c27026335526ba8851030d00681f8
udioMixer.cpp
3b21c50ef95fe4e7ac3426ca14b365749e66ff08 15-Dec-2011 Glenn Kasten <gkasten@google.com> Extract out audio DSP code to utility library

Change-Id: Ib8ce72028a7ea30e82baa518e381370e820ebbd0
ndroid.mk
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
6d4bf6eda04888144ec59cba4816a2cbb79b9e5c 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "setActiveTrack and setBufferProvider can't fail"
b87c068727a15a3d3f0bfdcb758c76a097f5e869 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Simplify enable/disable mixing"
079123ee3d2e20bbc17a7ddbd96ca46bed27898f 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Improve resistance to leaks for ConfigEvent"
26fa039c3752eaaf74d1be53d9795f48e9f43de3 16-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Use NULL not 0 for pointers"
fba380a0b2c62684ce4272a05165965bae29d6a1 16-Dec-2011 Glenn Kasten <gkasten@google.com> setActiveTrack and setBufferProvider can't fail

Return void, not status_t, from setActiveTrack and setBufferProvider.

These methods returned status_t, but the callers never checked the
return value. Since these aren't externally visible APIs, they now
return void, and assert on bad input parameters.

Change-Id: I530ed29484596ae41e8659826ca425149c51c2a1
udioMixer.cpp
udioMixer.h
1c48c3c61970527b97892ab6a2daae8eaac26964 15-Dec-2011 Glenn Kasten <gkasten@google.com> Simplify enable/disable mixing

The MIXING enum isn't needed, and now returns void instead of status_t.

Change-Id: Ibe4ec24081d75ad4ab78b9c7191fc9077959c4e9
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
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
udioFlinger.cpp
udioFlinger.h
e0feee3da22beeffbd9357540e265f13b2119cbb 13-Dec-2011 Glenn Kasten <gkasten@google.com> Use NULL not 0 for pointers

Change-Id: Iab3f9abbdab617dc5a599e657ec46a0b0a002eef
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
42968939dfce0954d6540011199045ec4ed7de80 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Fix indentation and whitespace"
a06a9a50b37d60e9c43c9de9f8ea3a8649cd5691 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Improve AudioFlinger error logging"
53a166cabc956529d2336b04c26b9c03b550ab38 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "AudioMixer uninitialized simple fields"
0cfd8231e4c489392809bf44c174315df2690145 13-Dec-2011 Glenn Kasten <gkasten@google.com> AudioMixer uninitialized simple fields

Change-Id: I47e3849f048d4d990c9634f9c8a2ca2de0339e93
udioMixer.cpp
d879601ace079e3c0aed79cf3fa5fb4db6ad4a9f 28-Oct-2011 Glenn Kasten <gkasten@google.com> Improve AudioFlinger error logging

Change-Id: I8ce9aff4038cd7fa0067600faa8080b137db1939
udioFlinger.cpp
2eda60a8485cfe70a60e72156beffdc470ecb093 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Audio C++ comments"
c5ac4cb3a5124860ccfc7e4ff66251c55a5595ca 12-Dec-2011 Glenn Kasten <gkasten@google.com> Fix indentation and whitespace

Use git diff -w to verify.

Change-Id: Ib65be0a1ecf65d6cad516110604e3855bf68a638
udioFlinger.cpp
udioMixer.cpp
c23bd9b5b9e4be9c395789810fdd8522296fc50c 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Use const char correctly in AudioFlinger"
e5dfcd8c6792c4b64120fd03708729b70a887f2a 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Use units after all times"
b299dc4ded29a226daac07f195d1558e660d2f9f 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Remove redundant clear()"
362c4e697d8e9c034e964ac7b40227e054491547 14-Dec-2011 Glenn Kasten <gkasten@google.com> Audio C++ comments

Change-Id: I84906ebb9dfcfa5b96b287d18364b407f02a30c1
udioFlinger.cpp
udioMixer.h
d1d8f23dde239289ba8c0de0944baaca3586c880 08-Jul-2011 Glenn Kasten <gkasten@google.com> Fix includes

Remove unused #include dlfcn.h

Add #include String8.h
Forward class declaration is only for references and pointers.
In this case, we need the full class declaration,
and were incorrectly depending on another header file to do it.

Change-Id: Iff65cceb3982698cc1ebaeec405695fc190c03ff
udioPolicyService.cpp
udioPolicyService.h
91eb8bfbe253a6b6fe1aa23fb884a601c28991c4 13-Dec-2011 Glenn Kasten <gkasten@google.com> Remove redundant clear()

Change-Id: Ie5e4e63cbc8fa85ef50451dddf8f149fa864b132
udioFlinger.cpp
ec1d6b5e17281a066d618f7fcd2b63b3ce11f421 12-Dec-2011 Glenn Kasten <gkasten@google.com> Use const char correctly in AudioFlinger

Use const char [] instead of const char * to eliminate unnecessary pointer.
Make the array audio_interfaces also const, in addition to the strings.

Change-Id: I31f33d1dcb9a657ee136f4280fd2d46492496831
udioFlinger.cpp
7dede876998ff56351d495ec3a798c1b131193e8 13-Dec-2011 Glenn Kasten <gkasten@google.com> Use units after all times

Change-Id: I48d3f29c37228b5d03189e4c9600824c9360cac9
udioFlinger.cpp
2013d4d159bfc29b4143d3b5fd4735f51a03684c 06-Dec-2011 Eric Laurent <elaurent@google.com> am 5433e25f: am 7b6aff23: Merge "audioflinger: fix audio skipping over A2DP" into ics-mr1

* commit '5433e25f6ce013860ff2a074ad8d1158cc39ab91':
audioflinger: fix audio skipping over A2DP
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
udioFlinger.cpp
udioFlinger.h
926798f8c21ab002d9797ef8973852a2612c1f75 23-Nov-2011 Eric Laurent <elaurent@google.com> am f6422f5f: am 20398fac: Merge "audioflinger: reduce sleep time to avoid underrun" into ics-mr1

* commit 'f6422f5f5d04aab47f8f36a0ea92e2140bed0105':
audioflinger: reduce sleep time to avoid underrun
7cafbb32999049873d4746ba83bd20c88abe6ce6 23-Nov-2011 Eric Laurent <elaurent@google.com> audioflinger: reduce sleep time to avoid underrun

Progressively reduce the sleep time applied in MixerThread::threadLoop()
in case of consecutive application underruns to avoid starving the audio HAL.
As the default sleep time is longer than the duration of an audio buffer
we ended up writing less data than needed by the audio HAL if
the condition persisted.

Issue 5553055.

Change-Id: I2b23ee79c032efa945025db228beaecd1e07a2e5
udioFlinger.cpp
c23e2f2464eb3748599d47af7d8986b856f3c179 17-Nov-2011 Glenn Kasten <gkasten@google.com> Bug 5522189 re-enable ARM opts but disable inline

PIE did not work together with inlining. This change combines (almost
all of) the performance benefits of ARM optimizations together with PIE.

Change-Id: I4594d33ae5a0a7bac327ae08e30fb35343a06256
udioResampler.cpp
c4795ecad4e5a0b3ec54862a40c82ef1ba53cd59 14-Nov-2011 Eric Laurent <elaurent@google.com> am 25924f8f: am 030bb998: Merge "audioflinger: fix noise when skipping to next song" into ics-mr1

* commit '25924f8f6c0a4ca4a2eb257b72d9625f69d2525e':
audioflinger: fix noise when skipping to next song
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
udioFlinger.cpp
udioFlinger.h
6977ca7d5ffdbc1610a95c74653b1fbe6a665f32 10-Nov-2011 Eric Laurent <elaurent@google.com> am db7d79e6: am 2b7f91b9: Merge "Fix regression for SoundPool playback" into ics-mr1

* commit 'db7d79e6f1e1860a9bfe4756a03c753435fd0ddf':
Fix regression for SoundPool playback
a47b69c6f7c6fe0044ebcb2d0790ce3548de56fd 09-Nov-2011 Eric Laurent <elaurent@google.com> Fix regression for SoundPool playback

Commit 19ddf0eb introduced a problem with applications (like SoundPool)
relying on an underrun condition to detect end of playback instead of
stopping the track when all data is written.
AudioFlinger would keep waiting for new data in case of partial buffer
filling and never reach the underrun condition.

Added a mechanism to wait no more than once if not enough frames are present
in the track buffer.

Issue 5585490.

Change-Id: I131e605ff6070831a01ddf734e68459e3bf2354b
udioFlinger.cpp
3b86c964df855a9740c446e984309b719c3ec37c 08-Nov-2011 Eric Laurent <elaurent@google.com> am f3a892ab: Merge "AudioFlinger: mix track only when really ready" into ics-mr1

* commit 'f3a892ab9347ce733b81ccb4913a91c586f8f367':
AudioFlinger: mix track only when really ready
3dbe3201479828e84abe02e1fdd0a5d414c0ddb8 03-Nov-2011 Eric Laurent <elaurent@google.com> AudioFlinger: mix track only when really ready

The addition of low power audio playback mode made that audio buffer consumption
by audio HAL can now happen in bursts. This makes that requesting audio data
from an AudioTrack for mixing can happen at much shorter intervals than before.
This revealed an existing problem where AudioFlinger would consider a track ready
for mixing although not enough frames were ready to completely fill one output buffer,
thus creating short periods of silence.

The fix consists in waiting for enough frames to be ready in AudioTrack buffer before
declaring a track ready for mixing. This minimum is not applied when the track is stopped
to allow the buffer to be emptied completely.

Change-Id: I6d04f9b65db5af85b0b53f0a5674be7ec02f9e9f
udioFlinger.cpp
305f4b6dabe500b97062e72049a296d0699243d7 28-Oct-2011 Glenn Kasten <gkasten@google.com> Bug 5522189 temporary workaround

Change-Id: I21d91d7a24df7bb6e7fc3d0fbc4786d55391fc0e
udioResampler.cpp
3856b090cd04ba5dd4a59a12430ed724d5995909 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
udioFlinger.cpp
udioMixer.cpp
udioPolicyService.cpp
udioResampler.cpp
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
udioFlinger.cpp
udioFlinger.h
5c4e818c39ac2d2739675fe907904a874f7623c5 19-Oct-2011 Eric Laurent <elaurent@google.com> Limit AudioFlinger log.

AudioFlinger logs a warning when a write to the audio HAL
takes too long to return. The threshold for this warning is
a rule of thumb based on the assumption that the audio HAL will consume
buffers at a regular pace.
The introduction of low power audio mode with larger buffers and writes
occuring in bursts makes that this threshold is often exceeded resulting
in excessive and misleading warnings.

The threshold is raised to remove unwanted warnings but we should reconsider
the usefulness of this warning altogether.

Change-Id: I5ef6898ea28d879cede3e47da542a64092a3cca4
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
9d18ec574f5d847a86a21594ac39394ef5b108fc 27-Sep-2011 Eric Laurent <elaurent@google.com> Fix issue 5373658: memory leak in AudioFlinger.

Unlink PowerManagerService binder interface death recipient
in ThreadBase destructor.

Change-Id: Iab06ae9a8a6737bb002b6416a157b0fb50c11ad5
udioFlinger.cpp
6bffdb8b598a2399e57f6ca48660fb7bdb2490b5 23-Sep-2011 Eric Laurent <elaurent@google.com> Fix issue 5355047: Automated effect tests fail.

Fixed several regressions in automated audio effect tests due
to changes in effect framework and visualizer FFT output range.

- Do not suspend Volume effect on session 0 when effects are
enabled on specific sessions.
- Adapt energy detection thresholds to new visualizer FFT range.
- Leave more time for BassBoost and Virtualizer effects to ramp up
before measuring the effect.
- Removed second insert reverb left by mistake on the player session
in preset reverb test.

Change-Id: I7a1ad1372d783fa7900eb9dd1d3b47f54d8d766f
udioFlinger.cpp
eb8b914ad9d4331e1cdf4346731770ce69fd0e77 16-Sep-2011 Nick Kralevich <nnk@google.com> AudioResampler: use relative instead of absolute labels

This change is needed to allow Android to compile with -fPIE
Bug: 5328392

Change-Id: I84d947975776800a7b79c6ac75a881af461a631c
udioResampler.cpp
60cd0a0d488e604d27fc7dbb02b00348693dfde2 13-Sep-2011 Eric Laurent <elaurent@google.com> Issue 4345021: Audio routed to multiple devices...

There is a possiblility that the condition on which RecordThread::checkForNewParameters_l()
waits after updating the command completion status is never signalled.
This happens if the thread executing ThreadBase::setParameters() has timed out waiting
for the status (for instance if the audio HAL takes too long to execute the setParameters()
command. Then the RecordThread is stuck forever.

The fix consists in waiting for the condition with a timeout in RecordThread::checkForNewParameters_l().

Change-Id: I7fc671bc2fc43ba4acb65a2beb33ee05742f091e
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
a1884f9e9ec3836683efd7eb333ee442e8bc9d56 23-Aug-2011 Eric Laurent <elaurent@google.com> AudioFlinger: add check for audio HAL init failure

Do not call audio HAL functions on the primary HW interface
if it could not be initialized properly.

Change-Id: If54059c8fd188d6c1686f9e0439994fe9411478a
udioFlinger.cpp
a5cc7cce9b8aee73b08f6532710e186c02fdd1c0 03-Aug-2011 Eric Laurent <elaurent@google.com> Issue 5081351: isWiredHeadsetOn() permission.

AudioManager.isWiredHeadsetOn() should not require permission MODIFY_AUDIO_SETTINGS.
Remove permission checks on all getters in audio policy manager as permission enforcement
is really usefull for setters.
Also deprecate AudioManager.isWiredHeadsetOn() which name and implementation are deceptive.

Change-Id: I38f8df7c26c0d417bf0e2b74e4c11c2d143f2ecd
udioPolicyService.cpp
0270b188aa3929cc512ec6869caba1d6b60cc08c 12-Aug-2011 Marco Nelissen <marcone@google.com> Don't remove effects on session 0

b/5159902
Change-Id: Id6f29fb1c687069f7480dd81d4745a558f202226
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
6dbe883644940badc684957cfc381bfd115f205e 28-Jul-2011 Eric Laurent <elaurent@google.com> Fix issue 5090721: audio record broken

Commit 6dbdc40 introduced a deadlock when exiting the
AudioFlinger RecordThread.

Change-Id: I1f63e54c5aeff05da4e4d028b53f734c62c78677
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.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
ndroid.mk
udioFlinger.cpp
udioFlinger.h
57dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfc 24-Jul-2011 Eric Laurent <elaurent@google.com> Added APIs for audio preprocessing

Added APIs to control pre processes applied on captured audio.
Those APIs are still hidden until reviewed by API council.

Three types of standard pre processes are supported:
- Automatic Gain Control (AGC) by AutomaticGainControl class
- Acoustic Echo Cancellation (AEC) by AcousticEchoCanceler class
- Noise Suppression (NS) by NoiseSuppressor class

A method is added to AudioEffect class to query audio pre processings
applied by default by the platform on a given AudioRecord session ID.

Change-Id: I0b9fceeb8c704dd06319c3b52b85c96fe871d51d
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.h
edc15ad8fcde12dc4f642d80d077239b1532eeca 22-Jul-2011 Eric Laurent <elaurent@google.com> Fix issue 4988574: 8 bit PCM audio playback broken.

Fixed regression in audio track control block frame size
calculation introduced by commit c310dcb.

Change-Id: Ia731b946ae4e43316b98d80229e3b08a696e47d6
udioFlinger.cpp
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
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
e0b5bb23f0a26d248275d203885b820659da7320 16-Jul-2011 Glenn Kasten <gkasten@google.com> Merge "Log CPU usage"
4d8d0c30abfa4b8d75866d42094cc797e05068fa 09-Jul-2011 Glenn Kasten <gkasten@google.com> Log CPU usage

Change-Id: Ie447e59be139153e526b7ad467c46c659d26816f
ndroid.mk
udioFlinger.cpp
81eedd1746be590d5d506dfb9ff23619f9d9898f 13-Jul-2011 Mike Lockwood <lockwood@android.com> Remove some #ifdef HAVE_ANDROID_OS that were needed for the simulator build

Change-Id: I13d9f251f86c05ae5405f37adbf6b8e9660935ba
Signed-off-by: Mike Lockwood <lockwood@android.com>
udioPolicyService.cpp
5e0067b486c3862316aa1f293cf9690c0cf54bda 12-Jul-2011 Jeff Brown <jeffbrown@google.com> Remove the simulator target from all makefiles.
Bug: 5010576

Change-Id: I04d722f258951a3078fe07899f5bbe8aac02a8e8
ndroid.mk
6c21234e3d254fc58227cd2063500a0dcd173689 08-Jul-2011 Glenn Kasten <gkasten@google.com> Merge "Fix build warning; LOG_TAG was misplaced"
5159c7ec97b575c0486159f0543d2da90c3c3b68 08-Jul-2011 Glenn Kasten <gkasten@google.com> Fix build warning; LOG_TAG was misplaced

Change-Id: I4fb0590f626445188f9053367707878b2fa0fa30
udioResamplerCubic.cpp
6d8b694d999e9be7d5dcc336535832a80fb6f61f 24-Jun-2011 Eric Laurent <elaurent@google.com> Moved and renamed effect API header files

Moved specific effect header files to
system/media/audio_effects/include/audio_effects
and renamed to lower case (effect_xxx.h).

Change-Id: Icfc2264bfd013cab0395d7e310ada636b9fe3621
ndroid.mk
udioFlinger.cpp
671a636931295d9c33ffca74551a804479d01241 17-Jun-2011 Eric Laurent <elaurent@google.com> Added audio_bytes_per_sample() helper function

Change-Id: Ibfcd75c4c241a53d5f052c25ada091904991048a
udioFlinger.cpp
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>
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
0512ab559d4670c2204078470d7ef5d376811c57 05-May-2011 Glenn Kasten <gkasten@google.com> Remove dead code related to gettid

The gettid system call is always available now.

Change-Id: Ib78b41781eda182dc8605daf456bbea7ff7c2dc0
udioFlinger.cpp
udioPolicyService.cpp
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
udioFlinger.cpp
udioFlinger.h
udioMixer.cpp
udioMixer.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
udioFlinger.cpp
udioFlinger.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
udioFlinger.cpp
udioFlinger.h
162f7d15ac5c8c23d1c3de171239f3a4e6e06b2a 23-May-2011 Glenn Kasten <gkasten@google.com> Merge "HAVE_ANDROID_OS AUDIOFLINGER_SECURITY_ENABLED dead"
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
udioFlinger.cpp
udioFlinger.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>
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
249c6a61f21bc90e25e4b77f18c98af1ac363e69 05-May-2011 Glenn Kasten <gkasten@google.com> HAVE_ANDROID_OS AUDIOFLINGER_SECURITY_ENABLED dead

Remove dead code from the days when Android ran in emulator.

Change-Id: Ibadbbde0538239ad9b2811a3a2e8f8a6d3b6389c
udioFlinger.cpp
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>
udioFlinger.cpp
udioFlinger.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>
udioFlinger.cpp
udioFlinger.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>
ndroid.mk
udioFlinger.cpp
udioFlinger.h
udioPolicyService.cpp
udioPolicyService.h
6b80e0be94d3f92ec4aa2b7cace816780d3f338d 20-Apr-2011 Dima Zavin <dima@android.com> audioflinger: move legacy audio hw/policy out to libhardware_legacy

Change-Id: I4adcec73d3c08bcbe15bb19e1ba2ff18b195af45
Signed-off-by: Dima Zavin <dima@android.com>
2dpAudioInterface.cpp
2dpAudioInterface.h
ndroid.mk
udioDumpInterface.cpp
udioDumpInterface.h
udioHardwareGeneric.cpp
udioHardwareGeneric.h
udioHardwareInterface.cpp
udioHardwareStub.cpp
udioHardwareStub.h
udioPolicyManagerBase.cpp
dab0bea38ab2c2d6b52907b7f5684834c4979251 26-Apr-2011 Eric Laurent <elaurent@google.com> am 48dca4de: am 969357e3: am 223995dc: Fix issue 4335692: HDMI media volume

* commit '48dca4de70890d324b5830a58bb9fa273164151a':
Fix issue 4335692: HDMI media volume
5bfdfd1e7b4514c6f6143b6b97ef37013f6e53a9 26-Apr-2011 Eric Laurent <elaurent@google.com> am 969357e3: am 223995dc: Fix issue 4335692: HDMI media volume

* commit '969357e31c93e168e7a4cb3b41c33a6ec26f4a26':
Fix issue 4335692: HDMI media volume
023eeac54c428d78b755fa3c856f20d17abb8a40 25-Apr-2011 Eric Laurent <elaurent@google.com> Fix issue 4335692: HDMI media volume

Forced music stream volume to max when not muted and output device is HDMI.

Change-Id: Ibd287cea8ae1d3f36fea6651a113bd5cf2dbad13
udioPolicyManagerBase.cpp
5820e52f9bf3c40839d33457975b6c9629ab1c79 12-Apr-2011 Brad Fitzpatrick <bradfitz@android.com> am 07c25b65: am 4430670f: am ca7ad44a: Merge "audioflinger: Enable ARMv5TE optimized resampler"

* commit '07c25b651216daac884bd503c02b788418165b50':
audioflinger: Enable ARMv5TE optimized resampler
4d0243980123378e9dd69022bf4ddca729d84126 12-Apr-2011 Brad Fitzpatrick <bradfitz@android.com> am 4430670f: am ca7ad44a: Merge "audioflinger: Enable ARMv5TE optimized resampler"

* commit '4430670f48f75661293371dab8db55865f5f56e0':
audioflinger: Enable ARMv5TE optimized resampler
0c0a1c0c37dbd2646a732da706d6777283c83e44 06-Apr-2011 Jim Huang <jim.huang@linaro.org> audioflinger: Enable ARMv5TE optimized resampler

Previously, the optimized asm option is only enabled when
__ARM_ARCH_5E__ is defined, which is assigned in armv5te.mk
rather than armv7-a series targets. This patch checks the ARM CPU
feature about half-word multiply instructions to enable ARMv5TE
resampler optimization routines properly.

Change-Id: I4c5a5d8c932416f23bedb0b389db958349f21ea4
udioResampler.cpp
c30268b9d118309a0514bcf280a03ee69f81403f 06-Apr-2011 Glenn Kasten <gkasten@google.com> Merge "Miscellaneous code cleanup in audio framework"
4bcae82f9b07d1a39956c45a6f5bec0b696c4dd1 04-Apr-2011 Glenn Kasten <gkasten@google.com> Miscellaneous code cleanup in audio framework

Changes:
- Move declaration of kClassPathName to top of file so it can be used
in more than one place, instead of "android/media/AudioSystem".
- Make private methods static.
- Add comment to stream_type, audio_mode, force_use types that they must match
values in AudioSystem.java.
- Add comment about unused types mp3_sub_format and vorbis_sub_format.
- Fix typos.
- Use @ in javadoc comments.
- Delete dead APIs setMode, getMode, setRouting, getRouting in AudioSystem.java
(they are all hidden, deprecated, and unused by rest of framework)
- Delete unused private log method.
- Fix pathname for android_media_AudioSystem.cpp.
- Improve code formatting for space after == and !=.
- Add logging of delta for changing audio policy manager ref count.

Change-Id: I18037c7beb8ab76d1fda08c11e589f6e591d36e1
udioFlinger.cpp
udioPolicyManagerBase.cpp
38ccae2c0324daa305f3fe77d25fdf5edec0b0e1 29-Mar-2011 Eric Laurent <elaurent@google.com> New fix for issue 4111672: control block flags

The first fix (commit 913af0b4) is problematic because it makes threads
in mediaserver process block on the cblk mutex. This is not permitted
as it can cause audio to skip or worse have a malicious application
prevent all audio playback by keeping the mutex locked.

The fix consists in using atomic operations when modifying the control
block flags.

Also fixed audio_track_cblk_t::framesReady() so that it doesn't block
when called from AudioFlinger (only applies when a loop is active).

Change-Id: Ibf0abb562ced3e9f64118afdd5036854bb959428
udioFlinger.cpp
33797ea64d067dfeaacbfd7ebe7f3383b73961b5 17-Mar-2011 Eric Laurent <elaurent@google.com> Fix issue 4111672: AudioTrack control block flags

Make sure that all read/modify/write operations on the AudioTrack
and AudioRecord control block flags field are protected by the
control block's mutex.

Also fix potential infinite loop in AudioTrack::write() if the
written size is not a multiple of frame size.

Change-Id: Ib3d557eb45dcc3abeb32c9aa56058e2873afee27
udioFlinger.cpp
ce80563f6fb49b0c40281f9a527e288799b4a577 15-Mar-2011 Eric Laurent <elaurent@google.com> Improvement for issue 3489986: BT SCO volume

This change makes sure that the VOICE_CALL stream volume tracks
the BLUETOOTH_SCO stream volume when SCO audio is enabled.
The down link audio volume now reflects what is being displayed
when pressing volume hard keys on the device while in a video chat
with a BT SCO headset.

Volume settings on the headset and the device are still independent as
we do not support handsfree profile yet.

Change-Id: Ie0d2714730ea359b9318b9cbe6f0b2557ef0f976
udioPolicyManagerBase.cpp
4f46fed004b76d462ef859aa94a3c056b0e79b60 03-Mar-2011 Gloria Wang <gwang@google.com> Merge "- To track the usage of all audio output devices - To track the currently used audio device - The devices are separated as speaker and other audio devices - Provide the collected data to battery application through pullBatteryData()"
9ee159b79022b2e1a050acb3890ce948e99e9ccb 24-Feb-2011 Gloria Wang <gwang@google.com> - To track the usage of all audio output devices
- To track the currently used audio device
- The devices are separated as speaker and other audio devices
- Provide the collected data to battery application through pullBatteryData()

Change-Id: I374c755266b5ac6b1c6c630400f4daf901ea8acc
udioFlinger.cpp
1c4967155109ab083a4149347596f7ebd3662a67 03-Mar-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 3388775."
c0bff9b96152179650dc9508799a38e35ef2a321 01-Mar-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 3479042."
532492cd60a3ee2613cd3d664c9f4581d9929bc5 01-Mar-2011 Eric Laurent <elaurent@google.com> Fix issue 3388775.

Do not select A2DP output for media strategy when it is suspended because
BT SCO is active. Media audio will be routed to speakers or SCO HS
(depending on phone state and activity on stream VOICE_CALL) which is less
confusing than not hearing anything while music progress bar is moving.

Change-Id: Iff8cc1ea9bf9bde0b33035c4d91398db0934b836
udioPolicyManagerBase.cpp
243f5f91755c01614a8cafe90b0806396e22d553 01-Mar-2011 Eric Laurent <elaurent@google.com> Fix issue 3479042.

The problem is that when an AudioRecord using the resampler is restarted,
the resampler state is not reset (as there is no reset function in the resampler).
The consequence is that the first time the record thread loop runs, it calls the resampler
which consumes the remaining data in the input buffer and when this buffer is released
the input index is incremented over the limit.

The fix consists in implementing a reset function in the resampler.

A similar problem was also present for playback but unoticed because the track buffer is always
drained by the mixer when a track stops. The only problem for playback was that the initial
phase fraction was wrong when restarting a track after stop (it was correct after a pause).

Change-Id: Ifc2585d685f4402d29f4afc63f6efd1d69265de3
udioFlinger.cpp
udioMixer.cpp
udioMixer.h
udioResampler.cpp
udioResampler.h
043b22dbe3b98a8fdd6b0ea77df4089ff44b6539 28-Feb-2011 Jean-Michel Trivi <jmtrivi@google.com> Fix bug 3376700 Volume too loud at lowest setting

Change volume attenuation curve to provide more attenuation at
low volume settings, and finer steps at high volume.
See bug entry for link to doc with curve values.

Change-Id: I750548b2161a4c550ef982ba793156e4518119e8
udioPolicyManagerBase.cpp
586b21780680c4d19723b5a9484e55ec47464c5f 11-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3400751.

Add a delay before restoring output path when a notification ends so that
short sounds can be heard on proper device before the path is actualy switched.

Change-Id: I1d2dd8e7e28e15fbcab344256f88499b26297372
udioPolicyManagerBase.cpp
727a6f859841a1d421b680f56d4d4ca5ff8c6e4b 11-Feb-2011 Eric Laurent <elaurent@google.com> Merge "Fix issue 3425342."
12932bfdc7163e654d5ef25f1cb1802ded2704f1 11-Feb-2011 Eric Laurent <elaurent@google.com> Fix issue 3425342.

Change the device selection order as follows to enable easier use of
A2DP while the device is docked:
1 - wired Headset
2 - A2DP Headset
3 - SPDIF/HDMI
4 - Dock

Also do not limit notifications volume when on dock.

Change-Id: I55ea6bea9f2d9ff284b54023e541b2788d0f1eb8
udioPolicyManagerBase.cpp
6b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3 04-Feb-2011 Glenn Kasten <gkasten@google.com> Bug 3352047 Wrong message when adjusting volume

Add hidden AudioManager.getDevicesForStream and output device codes.

Change-Id: I4d1c1d3b6a077cd117720817d1f733dda557b947
udioPolicyManagerBase.cpp
udioPolicyService.cpp
udioPolicyService.h
8473bb556421ac08f4e03abd5d149852114c9238 07-Feb-2011 Brad Fitzpatrick <bradfitz@android.com> am be806fe8: am cc8f87e9: am f664d6f9: am b083d3b8: Merge "Initialize resampling buffer per track."

* commit 'be806fe8c1c7bb3ae70ae27dce41d672410af26a':
Initialize resampling buffer per track.
802da7bc462f6f9df6e681cc75c51dc0a056a4a1 04-Feb-2011 Glenn Kasten <gkasten@google.com> Merge "Bug 3366668 Use BinderService template"
e08d819989d394ed171ba6f1e6d0fa14c29fc42d 04-Feb-2011 Brad Fitzpatrick <bradfitz@android.com> am cc8f87e9: am f664d6f9: am b083d3b8: Merge "Initialize resampling buffer per track."

* commit 'cc8f87e9410dd4de9a2fda4738429e6c6087c789':
Initialize resampling buffer per track.
e26308ad434c575b2985ac442d2990bb1bc19f5d 04-Feb-2011 Brad Fitzpatrick <bradfitz@android.com> am b083d3b8: Merge "Initialize resampling buffer per track."

* commit 'b083d3b816378ef3b9dceb33b2c2e20510b2632b':
Initialize resampling buffer per track.
2151d7b8c2dd77c9887691db30396937be778141 04-Feb-2011 Yuuhi Yamaguchi <yuuhi.x.yamaguchi@sonyericsson.com> Initialize resampling buffer per track.

When resampling too short sound, AudioMixer uses previous
tracks buffer. So we re-initialize the temporary buffer per
loop to avoid it.

Change-Id: I55a59a3b14faa8445e09c450478fe79cef704760
udioMixer.cpp
117cd9286424888c1c5bf202ebf1e08ae1e6affe 04-Feb-2011 Glenn Kasten <gkasten@google.com> Merge "Bug 3366885 Remove LVMX switch"
8782cb4dc783cdcac8498148ab1894b4780c18df 04-Feb-2011 Eric Laurent <elaurent@google.com> am 6f1bd261: am 9c0a1003: Merge "Fix issue 3371080" into honeycomb

* commit '6f1bd261b7fd86ac7817ca061dfb55b95150b836':
Fix issue 3371080
db130fbd3ccd37e247e49494a84f8a9841ecd593 04-Feb-2011 Glenn Kasten <gkasten@google.com> Bug 3366885 Remove LVMX switch

Change-Id: I0bf98c6f85f00b3296874571e1c049dcc4e2fcca
ndroid.mk
udioFlinger.cpp
udioFlinger.h
d2dcb08808aed82218b258726fa66f8e095a3f9c 04-Feb-2011 Glenn Kasten <gkasten@google.com> Bug 3366668 Use BinderService template

Change-Id: I93d7f3fc9dc9b6a365723d8a51a73a5aabdb4f93
udioPolicyService.cpp
udioPolicyService.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
udioFlinger.cpp
udioFlinger.h
udioPolicyManagerBase.cpp
udioPolicyService.cpp
udioPolicyService.h
2a30be33a39b07bf4f945d9506ffda0fd076e6c2 29-Jan-2011 Jean-Baptiste Queru <jbq@google.com> Merge 0ef57993 from gingerbread

Change-Id: If10fee1ae387a8130356dd62fe678495402d5edf
144f78906f1eefaf8cbde9298a1422fcea094447 29-Jan-2011 Jean-Baptiste Queru <jbq@google.com> am 4eeb1047: Merge 13212f83 from gingerbread-plus-aosp

* commit '4eeb10470ffafe8c508027f363ac66b58da5bf00':
Fix issue 2988031.
2ef89309d41daac3d69fa78b31cd09cb2c262ca1 29-Jan-2011 Jean-Baptiste Queru <jbq@google.com> Merge 13212f83 from gingerbread-plus-aosp

Change-Id: I9a8ee0c7e7896aea85e7a7c18ee82927091cb670
5092d8c066a1a98343bbc16e33a6753e577b5e7f 27-Jan-2011 Eric Laurent <elaurent@google.com> Fix issue 2988031.

Limit SYSTEM stream volume when a headset is connected and music is playing.

Change-Id: Ieb44ae5bb53ffa9cd5fe8e317798eed279b78df8
udioPolicyManagerBase.cpp
bfa2f13fd3f463dbceea4d3a18c3124e70df0a05 15-Nov-2010 Jean-Michel Trivi <jmtrivi@google.com> do not merge bug 3370834 Cherrypick from master

Cherripick from master CL 79833, 79417, 78864, 80332, 87500

Add new audio mode and recording source for audio communications
other than telelphony.

The audio mode MODE_IN_CALL signals the system the device a phone
call is currently underway. There was no way for audio video
chat or VoIP applications to signal a call is underway, but not
using the telephony resources. This change introduces a new mode
to address this. Changes in other parts of the system (java
and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
state variable directly, but to use two new convenience methods,
isInCall() and isStateInCall(int) instead.

Add a recording source used to designate a recording stream for
voice communications such as VoIP.

Update the platform-independent audio policy manager to pass the
nature of the audio recording source to the audio policy client
interface through the AudioPolicyClientInterface::setParameters()
method.

SIP calls should set the audio mode to MODE_IN_COMMUNICATION,
Audio mode MODE_IN_CALL is reserved for telephony.

SIP: Enable built-in echo canceler if available.
1. Always initialize AudioRecord with VOICE_COMMUNICATION.
2. If echo canceler is available, disable our echo suppressor.

Note that this CL is intentionally not correcting the
getAudioSourceMax() return value in MediaRecorder.java as the
new source is hidden here.

Change-Id: Ie68cd03c50553101aa2ad838fe9459b2cf151bc8
udioFlinger.cpp
udioHardwareInterface.cpp
udioPolicyManagerBase.cpp
61dca6702ce50d937fc764c55bb0842b40dcd0e4 25-Jan-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 3376700 Add support in APM for stream-specific volume curves

The stream volume was handled the same way for all different stream,
the only potential difference between each of them being the number
of steps available to the user to change the volume. This was
mapped to 99 steps of 0.5dB amplitude, offering a maximum attenuation
of -49.5dB.
This change consists in defining for each stream a curve with two
knees (3 segments) for conversion from volume index to attenuation.
This curve is defined in the AudioPolicyManager in
initializeVolumeCurves(), and can therefore be overridden by the
platform.
Note that this change doesn't modify the volume curves: this CL
enables the curves to be changed by overriding this default
behavior.

Change-Id: I575b66799c52df2906db248943b15120b8a79ea2
udioPolicyManagerBase.cpp
b517e006b51c95db9c44bf5f104f562d431ae597 20-Jan-2011 Eric Laurent <elaurent@google.com> do not merge - Fix issue 3371096.

EffectModule::process() was copying effect chain input buffer to
output buffer if no effect was active instead of accumulating it.

Change-Id: If4ca75601ea69a088d0f71d88aec53e90a1dec89
udioFlinger.cpp
73337489229cc9b50371c7a9fcd86e9f00ea46d0 20-Jan-2011 Eric Laurent <elaurent@google.com> Fix issue 3371096.

EffectModule::process() was copying effect chain input buffer to
output buffer if no effect was active instead of accumulating it.

Change-Id: I2838af2e7b6654d0a76547625929a5453da68d02
udioFlinger.cpp
935752053ef2691dbb6d5a6d149e0e362c6e3c74 19-Jan-2011 Eric Laurent <elaurent@google.com> Tentative fix for issue 3362362.

The problem is likely that one method is called on the AudioPolicyManagerBase
instance while it is still being constructed by AudioPolicyService.

To avoid this, the AudioPolicyService mutex is held by the constructor until the
platform specific AudioPolicyManager is constructed and the member
mpPolicyManager initialized.

Also added an initCheck() method to AudioPolicyInterface to verify successful
initialization of AudioPolicyManager.

A similar change is done in AudioFlinger constructor.
Also added some missing protections in AudioFlinger methods where the
playback thread list is parsed.

Change-Id: I006b244ec057e1bb0aa5ebe426ef006e3b171056
udioFlinger.cpp
udioPolicyManagerBase.cpp
udioPolicyService.cpp
eb0d0c48ebfcee5e8141ae25fe42a9eac6aae230 10-Jan-2011 Eric Laurent <elaurent@google.com> Fix issue 3317627.

The fix consists in selecting the digital audio device (SPDIF/HDMI)
when available if the routing strategy is STRATEGY_PHONE.

Change-Id: Ie500ae92f5c01f2511988543852ba559c6e5994b
udioPolicyManagerBase.cpp
626c85f3a9ec8e34a1e4af31eddf118d75ee6416 17-Dec-2010 Eric Laurent <elaurent@google.com> Fix issue 3217707.

The problem is that when the A2DP headset is disconnected, there is a transition
period during which the A2DP sink pumps data at a very high pace.
This makes that:
1 the audio flinger mixer thread spins and starves binder threads thus delaying
the completion of the A2DP output stream shutdown
2 we read the audio http audio stream faster than normal and we reach the end of stream
for audio while video is still playing if the streamed file is small enough.

The fix consists in detecting abnormal short write intervals and sleep to restore
a normal write pace.

Change-Id: Iab127882494ab0e26266371dc0ce5c2ff6fa476e
2dpAudioInterface.cpp
2dpAudioInterface.h
0b456a6a33de8cb7c641724579382a31a1beaa2c 16-Dec-2010 Eric Laurent <elaurent@google.com> Fix speakerphone routing to analog dock

The audio routing policy when speakerphone is on and a dock with built-in
speakers is connected should be to output audio to teh dock speakers

Also removed route to SCO car kit if forced usage is not SCO as the SCO
socket might not be established.

Change-Id: I1aa2954092e28de935304b90f7a7a64d661934c7
udioPolicyManagerBase.cpp
f3a8d32fd475ec68d966fa6f12a4c975ba80b659 15-Dec-2010 Eric Laurent <elaurent@google.com> Change audio routing policy for HDMI

HDMI device should have a higher priority than analog dock audio but a lower priority
than wired headsets.
Also modified AudioService so that HDMI is mapped to DEVICE_OUT_AUX_DIGITAL device and not
DEVICE_OUT_DGTL_DOCK_HEADSET as before to enable discrimination between SPDIF going to
digital dock and SPIDF going to HDMI.

Change-Id: I887d0c73479784dd2edaf41ce1a7d8d0bdcbb4bd
udioPolicyManagerBase.cpp
b3fd981d5f8bbf629dd8a07b06b4b656b70cb944 10-Dec-2010 Eric Laurent <elaurent@google.com> Fix audio mode log.

Since the new audio mode IN_COMMUNICATION was added, the audio mode log
was broken.

Change-Id: I4fdafc3b98a1b0ceb55058a9e47fed99b3dbe6ad
udioHardwareInterface.cpp
ed7c671a57f89d389c9d6cd67e0698f160f69916 01-Dec-2010 Eric Laurent <elaurent@google.com> Fix issue 2641884: Bluetooth volume is dependent on in call volume.

The problem is that the code in AudioPolicyManagerBase::checkAndSetVolume() that forces
voice volume to max when setting bluetooth SCO volume is not called if the bluetooth stream
volume did not actually change. So even if we re apply volumes when switching to bluetooth
device, the volume voice volume is not changed and remains what it was when routed to earpiece
What makes things worse on Passion is that stream volumes are limited when connected to bluetooth
and their actual value does not change as soon as they exceed the limit threshold.

Change-Id: Id7c317db45b392a1c20dca2859678e3c64a371ed
udioPolicyManagerBase.cpp
094b148b8587a67c19585e2af2cc7b53868bfb89 01-Dec-2010 Eric Laurent <elaurent@google.com> resolved conflicts for merge of 0d28be68 to master

Change-Id: Iec5f810c366d3e1c14a6f6294b0aea4ffb30ae3e
075a1f660b77fe47b165db1aff97cdd05e300391 02-Nov-2010 Eric Laurent <elaurent@google.com> Fix issue 3142808.

There is a bug in the way audio policy manager handles A2DP interface suspend/restore
when SCO is used. This bug is not new but has been triggered by a change in the timing
of the events received by audio policy manager when a call is setup and torn down
introduced by commit 164a8f86c7e48992691368c4895709c3bdb835a4.

The fix consists in grouping the control of A2DP suspended state in a single function
that is called systematically when conditions affecting this state are changed:
- call state change
- device connection/disconnection
- change in forced usage.

Change-Id: I46ee2399ee5547b60511fc6cfd32e2720091b0f8
udioPolicyManagerBase.cpp
32cb1ba657a1094bb815f4d39f3e4bf12ce8437e 24-Nov-2010 Eric Laurent <elaurent@google.com> Fix issue 3225810.

Take a wake lock whenever A2DP output stream is active.

Change-Id: Ie50e6d4cb34c8a1ba97b301ef25e10aeb153d8f3
2dpAudioInterface.cpp
2dpAudioInterface.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
udioFlinger.cpp
udioFlinger.h
f1fb01a7f00b8da90a36268aba8584a872e99175 15-Nov-2010 Jean-Michel Trivi <jmtrivi@google.com> Add new audio mode for audio communications other than telelphony.

The audio mode MODE_IN_CALL signals the system the device a phone
call is currently underway. There was no way for audio video
chat or VoIP applications to signal a call is underway, but not
using the telephony resources. This change introduces a new mode
to address this. Changes in other parts of the system (java
and native) are required to take this new mode into account.
The generic AudioPolicyManager is updated to not use its phone
state variable directly, but to use two new convenience methods,
isInCall() and isStateInCall(int) instead.

Change-Id: Id744cd26520ea1d1a4795eabe6a1f0c58789af76
udioFlinger.cpp
udioPolicyManagerBase.cpp
56ecd20263d7f63476f756fc5d8b043b325c7bfb 09-Nov-2010 Jean-Michel Trivi <jmtrivi@google.com> Add support for audio recording source in generic audio policy mgr.

Update the platform-independent audio policy manager to pass the
nature of the audio recording source to the audio policy client
interface through the AudioPolicyClientInterface::setParameters()
method.

Change-Id: I6b4fd0f8a3acea0d7d30bbad98edd1977dc012bf
udioPolicyManagerBase.cpp
c643d77a099b0e86ad12de9b498f6f780e03184e 09-Nov-2010 Jean-Michel Trivi <jmtrivi@google.com> Add recording source for voice communication

Add a recording source used to designate a recording stream for
voice communications such as VoIP.

Change-Id: I4091d67069b1a0170c1a5ca5e6acd51eb0aa08f9
udioPolicyManagerBase.cpp
b235dee7be544a6c990ba4f8d89ab03e38c826f8 06-Oct-2010 Praveen Bharathi <pbharathi@motorola.com> Added support for dock headset observer

Change-Id: I06b2e65e3bfa10735e6c7fd3349afa9ae7d45292
Signed-off-by: Praveen Bharathi <pbharathi@motorola.com>
udioPolicyManagerBase.cpp
173e75df12ad5398f3650a30e430dcac0cbcf278 07-Oct-2010 Eric Laurent <elaurent@google.com> am ce2e2184: am 37947afe: Merge "Fixed AudioFlinger not always pausing tracks" into gingerbread

Merge commit 'ce2e2184bbc5530f4fac3220fdf3d1b3fc08a4c3'

* commit 'ce2e2184bbc5530f4fac3220fdf3d1b3fc08a4c3':
Fixed AudioFlinger not always pausing tracks
af59ce2407fa4e6e5d8f1664a4df2daf1badd407 05-Oct-2010 Eric Laurent <elaurent@google.com> Fixed AudioFlinger not always pausing tracks

If the pause request is received before the AudioTrack buffer was
completelly filled and the track ready for mixing, the pause is
not executed: the track just underruns and stays in pausing state.

The fix consists in considering the track ready for mixing immediately
if pausing.

Change-Id: Ia6cb4703fee2126e41011a6400ea8eeb3a3e5456
udioFlinger.cpp
9ad6e8bd9fab860e639f6ce95479e4b2a9b03ff5 01-Oct-2010 Eric Laurent <elaurent@google.com> am de12c3cf: am 220ab887: Merge "Issue 3032913: improve AudioTrack recovery time" into gingerbread

Merge commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9'

* commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9':
Issue 3032913: improve AudioTrack recovery time
44d9848d6656777a18019223e0d35f2fcc67719a 01-Oct-2010 Eric Laurent <elaurent@google.com> Issue 3032913: improve AudioTrack recovery time

This issue showed that when an AudioTrack underruns during a too long period
of time and is therefore disabled by audioflinger mixer, it takes an additional
delay of up to 3 seconds to recover.
This fix adds a simple mechanism to recover immediately when the client application
is ready to write data again in the AudioTrack buffer

Also throttle warnings on record overflows

Change-Id: I8b2c71578dd134b9e60a15ee4d91b70f3799cb3d
udioFlinger.cpp
9e2e2d2bc86372bde4673c31ef416b2f29d87ac2 29-Sep-2010 Eric Laurent <elaurent@google.com> am b047e3cd: am aeb2c62e: Merge "Fix several audio effects problems." into gingerbread

Merge commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c'

* commit 'b047e3cdf24b32e26f366fcd4cd0eee8ae6c592c':
Fix several audio effects problems.
dac69110ed1073bf0a9827a3f78698896dd05d97 28-Sep-2010 Eric Laurent <elaurent@google.com> Fix several audio effects problems.

Fixed the following issues in LVM effect bundle wrapper:
- memory leaks in EffectCreate() in case effect creation fails at various stages
- Added saturation when accumulating to output buffer
- Fixed problems with enabled effects count when an effect is released while enabled
- Do not allocate temporary buffer for accumulation each time process() is called

Fixed the following issues in effects framework (AudioFlinger)
- Release effect synchronously in the library when deleted from effect chain
- Do not call the effect process function if no tracks are present in the same
audio session

Change-Id: Ifbd80a163415cfb3c0a337c12082853ea45d9c91
udioFlinger.cpp
f43c92f8d7b1d81cc7248031970d68dc65579be0 24-Sep-2010 Eric Laurent <elaurent@google.com> am 692dfafe: am 880dfe4f: Merge "Fix issue 3007862" into gingerbread

Merge commit '692dfafe02d04cdbab5367546e166580c92e4d2e'

* commit '692dfafe02d04cdbab5367546e166580c92e4d2e':
Fix issue 3007862
84e9a10fde8a4ae3da4f88d7911c154933aa457f 24-Sep-2010 Eric Laurent <elaurent@google.com> Fix issue 3007862

Removed a cross deadlock condition between audioflinger and audio policy
service mutexes.
Audioflinger::createEffect() locks audioflinger mutex and then calls
AudioSystem::getOutputForEffect() which ends up in
AudioPolicyService::getOutputForEffect() which locks audio policy service
mutex. If at the same time, the command thread in audio policy service is
processing a command(set volume, set route...), the mutex is locked and the
command will call one audioflinger method which in turn will attempt to
lock audioflinger mutex.
The fix consists in releasing audioflinger mutex before calling
getOutputForEffect().

Change-Id: Id44e7feb36e0a295731f6aa97cf32d022edd34d0
udioFlinger.cpp
cc08406f74b67b1b7e532ef8ed534c0476ced636 23-Sep-2010 Eric Laurent <elaurent@google.com> am 11746caa: am 08959c63: Merge "Request permission for global audio effects." into gingerbread

Merge commit '11746caaa852984ff186bf5b8807e2c14cd7c1bc'

* commit '11746caaa852984ff186bf5b8807e2c14cd7c1bc':
Request permission for global audio effects.
fac4895de4ae63928ff0cf2ccece106eb6d33f72 22-Sep-2010 Eric Laurent <elaurent@google.com> Request permission for global audio effects.

Applications creating an audio effect on the output mix must
have the MODIFY_AUDIO_SETTINGS permission.

Change-Id: I57d88533f91ad0d33680107d79abcec28f7263b5
udioFlinger.cpp
d20b4cfde2848052cf93ed13df14d75347ec64fd 13-Sep-2010 Eric Laurent <elaurent@google.com> am 4d987850: am bd2e9ec6: Merge "Fix volume problems with insert revert" into gingerbread

Merge commit '4d9878502f7661ed34540a485a5942d859e209c7'

* commit '4d9878502f7661ed34540a485a5942d859e209c7':
Fix volume problems with insert revert
e0aed6ddcb4e3c301b80aa26706b6052dab42c41 11-Sep-2010 Eric Laurent <elaurent@google.com> Fix volume problems with insert revert

- Use a constant input level to the reverb engine and implement volume control in the
insert reverb. This avoids the volume spikes when an effect that was inserted after
the reverb is disabled or removed.
- Fix clicks (one silent buffer) at the end of the reverb disable period.
- Modified volume management in audioflinger so that the volume ramp is also done by
the insert effect if present when the track is paused (avoids clicks).
- Increased room level for all presets.

Also fixed problems with output stage session (-1):
- effect bundle wrapper was not designed to support session -1
- the permission check in audioflinger for using session -1 failed due to a wrong usage of
getCallingPid()

Change-Id: Id1ff51327263364bf71d3f2668fa5cde4311d84f
udioFlinger.cpp
e5fe2601b25e3220c3c4cfb79695ddb8a2f817ac 02-Sep-2010 Eric Laurent <elaurent@google.com> am 937056c1: am 32ec1ad1: Merge "Fix problem in AudioEffect::command() status." into gingerbread

Merge commit '937056c1a7ce71e6881305a31f76e62a76685f24'

* commit '937056c1a7ce71e6881305a31f76e62a76685f24':
Fix problem in AudioEffect::command() status.
aeae3de947fa0b1e670c8472b32288962f97b4f5 02-Sep-2010 Eric Laurent <elaurent@google.com> Fix problem in AudioEffect::command() status.

The *pReplyData argument of the command() function was left unitialized by EffectHandle::command()
when command was EFFECT_CMD_ENABLE, EFFECT_CMD_DISABLE and EFFECT_CMD_SET_PARAM_COMMIT.

Change-Id: I91a19817ead2a8cfbdd8e2d77ca270c7ce9d5bd4
udioFlinger.cpp
1040127473ee48c1c3b8c279ae05d38dbfb6e4c2 01-Sep-2010 Eric Laurent <elaurent@google.com> am 55e79374: am f560ceab: Merge "Audio Effects: fix problems in volume control." into gingerbread

Merge commit '55e7937462d107b469a58651d3d51e15086f8e9e'

* commit '55e7937462d107b469a58651d3d51e15086f8e9e':
Audio Effects: fix problems in volume control.
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
udioFlinger.cpp
udioFlinger.h
ea798dd9f37b34acfa3cf8d945dbe7f7e90e7196 31-Aug-2010 Eric Laurent <elaurent@google.com> am 44217848: am ae6bdc23: Merge "Fix issue 2952766." into gingerbread

Merge commit '4421784895a58bb7bcf90236a9e443b372b5b80e'

* commit '4421784895a58bb7bcf90236a9e443b372b5b80e':
Fix issue 2952766.
c1c88e27a6f07a530fca184f515c16d51e46d56f 28-Aug-2010 Eric Laurent <elaurent@google.com> Fix issue 2952766.

The problem is that the audio policy manager does not handle the input devices
when forced use for telephony is changed.
The problem does not appear in a call over PSTN becasue only teh output devices drives the
routing of in call audio to/from the base band.

The fix consists in modifying AudioPolicyManagerBase::setForceUse() to check for active inputs
and update the input device if needed.

Change-Id: I0d36d1f5eef1cce527929180c29b025439902f10
udioPolicyManagerBase.cpp
69e0b8c5556df1d4db1a730db1c13409a96749c7 21-Aug-2010 Eric Laurent <elaurent@google.com> am 3a899b85: am 0b9a12bf: Merge "Fix issue 2929440" into gingerbread

Merge commit '3a899b85102f6d51585b3d46ced3038c8602f202'

* commit '3a899b85102f6d51585b3d46ced3038c8602f202':
Fix issue 2929440
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
udioFlinger.cpp
udioFlinger.h
a1a6cba3664a04d214b372526658ba227e4d5366 14-Aug-2010 Eric Laurent <elaurent@google.com> am f28608cd: am c8d0d630: Merge "Fix issue 2909189: System property ro.audio.silent no longer mutes system." into gingerbread

Merge commit 'f28608cdf4f6a0075d0811ccd32123baf4daec31'

* commit 'f28608cdf4f6a0075d0811ccd32123baf4daec31':
Fix issue 2909189: System property ro.audio.silent no longer mutes system.
571d49c1c316f5e07b74ed7b5df6bdec7cbc1a14 11-Aug-2010 Eric Laurent <elaurent@google.com> Fix issue 2909189: System property ro.audio.silent no longer mutes system.

Fixed regression introduced by commit 2a6b80bc65c4782b5a7168b300e1dc5ec9f617ee:
master mute was not working if no effect chains were present on session 0.

Change-Id: I66d107e045d159cb94d29c7476fa1e12d92f2ae7
udioFlinger.cpp
bc417c0531332635df9525df4683274a08fb987f 10-Aug-2010 Eric Laurent <elaurent@google.com> am 1ece7d68: am 2a6b80bc: Fixed several audio effects problems.

Merge commit '1ece7d6873027068a3e7b055597045e9387b217c'

* commit '1ece7d6873027068a3e7b055597045e9387b217c':
Fixed several audio effects problems.
8569f0d3bf4c6787707e348a7cf73b9c4199cb32 30-Jul-2010 Eric Laurent <elaurent@google.com> Fixed several audio effects problems.

- Fixed constant inversions in AudioEffect.java
- Do not return error when enabling an already enabled effect
- Update cached effect state in native AudioEffect class when effect is enabled/disabled by command() method
- Remove click when restarting effect during disable sequence
- Fixed problem in master mute management when volume control is delegated to effect.

Change-Id: I6df4ce9fcc54fdc7345df858f639d20d802d6712
udioFlinger.cpp
e679114b6c7e087a59c2b2c3b55603c43da4ef38 29-Jul-2010 Eric Laurent <elaurent@google.com> am ba676a00: am a54d7d3d: Fixed underrun in audioflinger mixer.

Merge commit 'ba676a00c1b9ba59b30fe805b83d03d1768fffbd'

* commit 'ba676a00c1b9ba59b30fe805b83d03d1768fffbd':
Fixed underrun in audioflinger mixer.
60e182437228312cc28469a5b0dfde77ac848e1a 29-Jul-2010 Eric Laurent <elaurent@google.com> Fixed underrun in audioflinger mixer.

When all audio tracks have been disabled and the mixer is running idle before the output stream is placed in standby,
the mixer sometimes fails to write to the output stream on time to avoid underrun.

This is because the sleep period used to wait before the next write to output stream is too close to the actual buffer duration.
In fact this sleep time is not critical as if we write too early to the output stream, the kernel driver will wait for free buffers
from the audio DSP DMA and we will sleep anyways.

The fix consists in dividing the calculated wait period by 2 to increase the margin.

Change-Id: I5730887dc2ccce2a511bc858494a6f7da6b392a0
udioFlinger.cpp
cc759794489c2c39aaef229fba4ace32e394bb81 29-Jul-2010 Eric Laurent <elaurent@google.com> am 45dc4f82: am 493941b8: Allow creation of an audio effect on a session with no audio tracks.

Merge commit '45dc4f82a00e52b12389b22a7cfbbee5609e8e28'

* commit '45dc4f82a00e52b12389b22a7cfbbee5609e8e28':
Allow creation of an audio effect on a session with no audio tracks.
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
udioFlinger.cpp
udioFlinger.h
ed0de3c123aaa86147993721d4794648a65aab75 28-Jul-2010 Eric Laurent <elaurent@google.com> am 6fa88882: am 62d83a0c: Merge "Audio effects: modified command() parameter types." into gingerbread

Merge commit '6fa8888254deb4961dc64c6ac03dc103c9cd8bcf'

* commit '6fa8888254deb4961dc64c6ac03dc103c9cd8bcf':
Audio effects: modified command() parameter types.
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
udioFlinger.cpp
udioFlinger.h
8184a5734690b30f4de0f6b6c16daf1e089f67df 20-Jul-2010 Eric Laurent <elaurent@google.com> resolved conflicts for merge of dd206093 to master

Change-Id: I21dd2321a4839d034d49092baccbf40986f17dae
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
udioFlinger.cpp
udioFlinger.h
udioPolicyManagerBase.cpp
udioPolicyService.cpp
udioPolicyService.h
bbf6dcd2aa8eb877e6412aaade25a077f62a6284 19-Jul-2010 Eric Laurent <elaurent@google.com> am 3c6ea955: am 7203272f: Merge "Fixed problems in audio effect volume control." into gingerbread

Merge commit '3c6ea95553d3a0e416874c583a41efff3f6fbc57'

* commit '3c6ea95553d3a0e416874c583a41efff3f6fbc57':
Fixed problems in audio effect volume control.
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
udioFlinger.cpp
udioFlinger.h
521bcb0ff5054e5be40f5194026da3463504ae3b 16-Jul-2010 Eric Laurent <elaurent@google.com> am f16b3f10: am b0374a0e: Merge "Several improvements in audio effects volume control." into gingerbread

Merge commit 'f16b3f104f60738447db60bcf2c44c7610e17199'

* commit 'f16b3f104f60738447db60bcf2c44c7610e17199':
Several improvements in audio effects volume control.
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
udioFlinger.cpp
udioFlinger.h
c0b9c87b2581af430e143822918935d15ac69911 15-Jul-2010 Mathias Agopian <mathias@google.com> am c74034b6: am 24651682: added BinderService<> template to help creating native binder services

Merge commit 'c74034b6bf0940dc80c4d4efa1e677ad0d2dfd6c'

* commit 'c74034b6bf0940dc80c4d4efa1e677ad0d2dfd6c':
added BinderService<> template to help creating native binder services
094c96da874d84eae46f76cc036fa7b7993eb999 15-Jul-2010 Mathias Agopian <mathias@google.com> am 78983a91: am 4055b780: Merge "move native services under services/" into gingerbread

Merge commit '78983a9133d3dd3f08b1ec462a7e2f9e7bfa9e2f'

* commit '78983a9133d3dd3f08b1ec462a7e2f9e7bfa9e2f':
move native services under services/
5462fc9a38fa8c9dff434cd53fa5fb1782ae3042 15-Jul-2010 Mathias Agopian <mathias@google.com> added BinderService<> template to help creating native binder services

Change-Id: Id980899d2647b56479f8a27c89eaa949f9209dfe
udioFlinger.cpp
udioFlinger.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
2dpAudioInterface.cpp
2dpAudioInterface.h
ndroid.mk
udioBufferProvider.h
udioDumpInterface.cpp
udioDumpInterface.h
udioFlinger.cpp
udioFlinger.h
udioHardwareGeneric.cpp
udioHardwareGeneric.h
udioHardwareInterface.cpp
udioHardwareStub.cpp
udioHardwareStub.h
udioMixer.cpp
udioMixer.h
udioPolicyManagerBase.cpp
udioPolicyService.cpp
udioPolicyService.h
udioResampler.cpp
udioResampler.h
udioResamplerCubic.cpp
udioResamplerCubic.h
udioResamplerSinc.cpp
udioResamplerSinc.h