History log of /frameworks/av/include/media/AudioTrack.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6d7b119a416c9f10288051e562f294365e5d954c 08-May-2016 Andy Hung <hunga@google.com> Improve timestamp jitter fix

Use last valid kernel timestamp on server side, not client side.

Bug: 28465713
Change-Id: I33590d6922980f288355f947bc56279245058429
/frameworks/av/include/media/AudioTrack.h
7aa45dd7fc5c2bd959f1571231556ac06b7ec8ae 03-May-2016 Andy Hung <hunga@google.com> Merge "AudioTrack: Fix timestamp jitter" into nyc-dev
b01faa31462e19957ae3c0c3ada07c9576a9494f 27-Apr-2016 Andy Hung <hunga@google.com> AudioTrack: Fix timestamp jitter

When HAL out_get_presentation_position returns error,
use server position adjusted for latency.

Bug: 28250436
Change-Id: I3dbcb9b7c4e56d34e7e161d1a02d8f64afd602b9
/frameworks/av/include/media/AudioTrack.h
ea38ee7742e799b23bd8675f5801ef72f94de0f4 18-Apr-2016 Glenn Kasten <gkasten@google.com> Can now indicate the desired number of notifications (sub-buffers)

per fast track buffer when using the default buffer size.

There is no change for normal tracks, or fast tracks with a non-default buffer size.

Also fix related bugs:
Notification period was not set correctly when fast multiplier is not 1.
Incorrect warning when client adjusted notification frames.

Bug: 27819623
Bug: 28117362
Change-Id: Ifc2121e874f51718cd56ec04e4bd5f89f4963132
/frameworks/av/include/media/AudioTrack.h
0c4a97e6e1470b2d8b8810792af8d66689020c51 13-Apr-2016 Andy Hung <hunga@google.com> Merge "NuPlayer: Reserve buffer for 8x max speed" into nyc-dev
f2c87b3f88d987d2af6322e9763eb8224a2bae48 08-Apr-2016 Andy Hung <hunga@google.com> NuPlayer: Notify if drain message time is unexpectedly long

Bug: 27940058
Change-Id: Id8897c30e21b6b9de545a710e7766ffceb491455
/frameworks/av/include/media/AudioTrack.h
ff874dc957f9ea70d87f4d627bf903e1fc86d58b 12-Apr-2016 Andy Hung <hunga@google.com> NuPlayer: Reserve buffer for 8x max speed

Affects Photos with Bluetooth and 240x recording.

Bug: 26986060
Change-Id: I228223221f9811e05c274d64cd42ac104db04c36
/frameworks/av/include/media/AudioTrack.h
e13f8a603867280de9b02ce4839202a182556416 30-Mar-2016 Andy Hung <hunga@google.com> NuPlayer: Play out remaining audio data when recycling isn't possible

Don't flush it immediately.

Bug: 26530291
Change-Id: I0427633402fa251ec62e2b70e47a0a7b451d3ea2
/frameworks/av/include/media/AudioTrack.h
ea2b9c07b34079f0dbd8610a511e006e69a15adc 13-Feb-2016 Andy Hung <hunga@google.com> Implement client playback timestamps with 64 bit accuracy

Provide server timestamps if the HAL doesn't provide it.
Provide monotonic - boottime translation.

Bug: 17472992
Bug: 26682703
Bug: 27749434
Change-Id: I6c9b213d9f9284092e34d57f52870e02c72df62a
/frameworks/av/include/media/AudioTrack.h
7a490e7ab39ef0b22baf24b03f2463c46dc068ed 23-Mar-2016 Andy Hung <hunga@google.com> Read from proxy for PCM direct and offloaded track position

Bug: 27776737
Change-Id: I721bf2b4d46271bf84ad9fc29ff5c4ecd4759206
/frameworks/av/include/media/AudioTrack.h
d848eb48c121c119e8ba7583efc75415fe102570 08-Mar-2016 Glenn Kasten <gkasten@google.com> Use audio_session_t consistently

Bug: 27562099
Change-Id: I328d8226191386b163f2ace41233607294c50dcd
/frameworks/av/include/media/AudioTrack.h
4d231dc0ee34380956c71cbe18a750e487a69601 12-Mar-2016 Eric Laurent <elaurent@google.com> audio: Fix race condition in AudioTrack underrun.

When audio flinger mixer removes an AudioTrack from the
active list in case of underrun, it is possible that the
client has written a full buffer just after the underrun detection and
is blocked waiting for more space to write. In this case, the client
will never detect the DISABLED flag and the track never be restarted.

Also implement missing DISABLE flag detection in server side audio tracks
(OutputTrack and PatchTrack).

bug: 27567768
Change-Id: I8d0753429d4113498258b1f61bd8ac5939a612f0
/frameworks/av/include/media/AudioTrack.h
ae34ed2bcc9fa49a22fe7497327adb689ef27e8d 28-Jan-2016 Haynes Mathew George <hgeorge@codeaurora.org> AudioTrack: Use original flags during track recreation

Also the OFFLOAD and DIRECT flags aren't denied by server.

authored-by: Pavan Chikkala<pavanc@codeaurora.org>
Bug: 27554925
Change-Id: I6fd6b129928af4513bb0cba271019288605310f8
/frameworks/av/include/media/AudioTrack.h
7fd0422fbd17af3b24eb04421d37fce50f3826e2 02-Feb-2016 Glenn Kasten <gkasten@google.com> Sample rate 0 means a route-dependent rate

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

Bug: 25641253
Bug: 21019153
Change-Id: I24a6677945987fc39a9bf93f70357e4bc7410f98
/frameworks/av/include/media/AudioTrack.h
d79072e9dff59f767cce2cda1caab80ce5a0815b 06-Jan-2016 Glenn Kasten <gkasten@google.com> Remove TimedAudioTrack and associated code

Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
/frameworks/av/include/media/AudioTrack.h
bbe98f009fc2c3181a8d4ab71b3e145f76c01755 17-Jan-2016 Phil Burk <philburk@google.com> Merge "AudioTrack: Add getUnderrunCount()"
27e583ba1d0d4fdc11d6eeee0c416e727045cbbc 17-Jan-2016 Phil Burk <philburk@google.com> Merge "AudioTrack: add setBufferSizeInFrames()"
33ff89ba94a527e4293ee5349da01483252d5c83 30-Nov-2015 Phil Burk <philburk@google.com> AudioTrack: lower Java latency

Add AUDIO_FLAG_LOW_LATENCY to enable Fast track.

Change-Id: Ib1bff635afaa57af7754cb751b57c6afc4c2ab2b
Bug: 21019153
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/include/media/AudioTrack.h
c0adecb800b197cb8c028513130ebabf2d0f37ba 08-Jan-2016 Phil Burk <philburk@google.com> AudioTrack: add setBufferSizeInFrames()

Also add getBufferCapacityInFrames().
These can be used to dynamically raise or lower latency.

Bug: 21019153
Signed-off-by: Phil Burk <philburk@google.com>
Change-Id: I02ca7f6f5cc4e089fcd81cc8a2b6ff234e0381a8
/frameworks/av/include/media/AudioTrack.h
2812d9ea3a3a33142dd8e23c9d949c498d6f7a12 04-Jan-2016 Phil Burk <philburk@google.com> AudioTrack: Add getUnderrunCount()

This allows an app to detect application-level output glitches.
Underrun counts survive track recreation.

Change-Id: I8eb14e92f6fc1007718a29b0666ab51ace30cdb8
Bug: 25641253
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/include/media/AudioTrack.h
90e8a97dd5c9d391d7a2ea6a2290ed976f928379 10-Nov-2015 Andy Hung <hunga@google.com> Use modulo position variables in AudioTrack and AudioRecord

More type safety, plus correct treatment for sanitization.

Bug: 25569906
Bug: 25232421
Change-Id: Id852277b81a1792c5e67392cd74bc39cba7ed1ad
/frameworks/av/include/media/AudioTrack.h
6653c935d2518a713587b3887ca09aa09ebfa7fd 08-Jun-2015 Andy Hung <hunga@google.com> Return DEAD_OBJECT if getTimestamp cannot restore track

Bug: 21699132
Change-Id: I90443f8674ed949e2546048b231be75cd6fe6615
/frameworks/av/include/media/AudioTrack.h
1f1db8356b599bc40703c907fb69e6e539343532 08-Jun-2015 Andy Hung <hunga@google.com> Fix AudioTrack comments relating to use of restoreTrack_l()

Bug: 21699132
Change-Id: Ib0d029a5e28676aeffbbbafc88c52a17367a413c
/frameworks/av/include/media/AudioTrack.h
c8e09c610fabc7390297ecb48e939acbdfe27325 04-Jun-2015 Andy Hung <hunga@google.com> Improve AudioTrack offload timestamp startup glitch detector

New or existing glitch behavior for Nexus 5 offload audio:
we receive several 0 timestamps,
then we get a stale timestamp (very large),
then a few ms later we get a correct nonzero timestamp.

We attempt to hide the glitch because the retrograde timestamp
correction makes the glitch "sticky".

Bug: 21633313
Change-Id: I39153af718c151f9435e7d315651a811f72743da
/frameworks/av/include/media/AudioTrack.h
a7f03353d5f172016f324e2a01f301cca6794152 01-Jun-2015 Andy Hung <hunga@google.com> Compute sleep time when AudioTrack client callback returns no PCM data

Callbacks can go into a sleep-wait cycle if the client/app is unable to
deliver data. This can happen if the buffer is large, or if
the client/app cannot keep the buffer filled, or upon a stream end condition.
We improve the sleep time computation for AudioTrack PCM callbacks.

This minimizes the number of callbacks to NuPlayerRenderer.

Bug: 21198655
Change-Id: I4247798a6638def2f0d8f1b46f60323482065cb2
/frameworks/av/include/media/AudioTrack.h
0eafa9d8ee4069aa709ff85ceffe94d12995956d 02-Jun-2015 Andy Hung <hunga@google.com> Merge "Store server latency, sample rate, framecount information in AudioTrack" into mnc-dev
9f9e21ed9a342e0ca945818bdc6c0c4fb3bfb9bd 01-Jun-2015 Andy Hung <hunga@google.com> Store server latency, sample rate, framecount information in AudioTrack

Bug: 21198655
Change-Id: I24590196642a97ea5d61bc6356f0aff782bd37d3
/frameworks/av/include/media/AudioTrack.h
679e56914e83f05780003c71b84cc5b340e8fc0a 01-Jun-2015 Glenn Kasten <gkasten@google.com> Remove EVENT_NEW_TIMESTAMP symbol until fully implemented

Change-Id: I8e5dda004580ee97258d8d82721edee24ec2b929
/frameworks/av/include/media/AudioTrack.h
faeb0f291330134dc4468359a36e099aae508449 21-May-2015 Ronghua Wu <ronghuawu@google.com> libmediaplayerservice: try to open audio sink in offload mode in error.

Bug: 19061432
Bug: 21370108
Change-Id: Iaa757555ef37fd1ac87b6e2d5a9969bb58cc5ebc
/frameworks/av/include/media/AudioTrack.h
296fb13dd9b5e90d6a05cce897c3b1e7914a478a 01-May-2015 Eric Laurent <elaurent@google.com> Implement audio device callback

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

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

Change-Id: I9e938adf025fa712337c63b1e02a8c18f2a20d39
/frameworks/av/include/media/AudioTrack.h
4c5a3675ed6b429dfaa2707acf2b3faf2808baf2 01-May-2015 Phil Burk <philburk@google.com> AudioTrack: reduce retrograde motion spew

Change-Id: I96aced52b136ceea924aa3d9ef56374dd4c49784
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/include/media/AudioTrack.h
3a474aa67fc31505740526dd249d96204c08bf79 25-Apr-2015 Lajos Molnar <lajos@google.com> stagefright: support setting/getting playback/sync config in MediaSync

Bug: 18249558
Bug: 19666434
Bug: 20057497
Change-Id: I5868b17423d7c20cfaf4a399f3eb67bfba440605
/frameworks/av/include/media/AudioTrack.h
1b42097f38e72574ed853a35f4e8a66e4739c421 22-Apr-2015 Phil Burk <philburk@google.com> AudioTrack: fix spurious retrograde messages

The retrograde motion was confused by some positions coming from
the DSP on offloaded tracks. So the retrograde check was moved up
into AudioTrack.cpp. This allows us to take advantage of the checks
for invalid positions based on timing.

Bug: 2047891
Change-Id: Ifcad2349201443a7f1711347c203297100449536
Signed-off-by: Phil Burk <philburk@google.com>
/frameworks/av/include/media/AudioTrack.h
466dc8ed6ca6b7f585104806c48613dd34e608c9 17-Apr-2015 Paul McLean <pmclean@google.com> Explicit routing in AudioRecord

Change-Id: I9cc5d54883a3e5c75d553fabb619fc8e49f4f9e5
/frameworks/av/include/media/AudioTrack.h
5a8a95de6dad1a3bcf3da5a37b35766e89086e13 18-Apr-2015 Ricardo Garcia <rago@google.com> Use AudioPlaybackRate to hold TimestretchBufferProvider parameters

Use this struct to handle the parameters for TimestretchBufferProvider all
across the system.
Add stretch mode and fallback mode to TimestretchBuffer Provider.

Change-Id: I19099924a7003c62e48bb6ead56c785cb129fba2
/frameworks/av/include/media/AudioTrack.h
8edb8dc44b8a2f81bdb5db645b6b708548771a31 27-Mar-2015 Andy Hung <hunga@google.com> Add playback rate to AudioTrack

Bug: 19196501
Change-Id: I6411e1d3ce652b711a71a6d9df020cb5f60d4714
/frameworks/av/include/media/AudioTrack.h
aa9811945f575614b3482d09e4d969792701cebb 21-Mar-2015 Paul McLean <pmclean@google.com> Adding explicit routing API to AudioTrack

Change-Id: I40c048c7644c46f4e4f7103875206c0785c4b1dc
/frameworks/av/include/media/AudioTrack.h
0f5d69123490bb3c4fe26129dfd23e21ce184c88 20-Mar-2015 Glenn Kasten <gkasten@google.com> Remove deprecation FIXMEs for TRANSFER_OBTAIN mode

Change-Id: I7f43aabdb092e1465d79cd0eea5944fff18b93db
/frameworks/av/include/media/AudioTrack.h
bfd318402924414fbde4d31c9d23cc423f10b630 20-Mar-2015 Glenn Kasten <gkasten@google.com> set() in AudioRecord and AudioTracks needs no lock

Change-Id: I9d61b3d117e9b21fbbfad772d8981a5abb8fafae
/frameworks/av/include/media/AudioTrack.h
a5017872000a938667c76d760a866547c3719d09 20-Mar-2015 Glenn Kasten <gkasten@google.com> Update AudioTrack constructor and set() comments

Comments were missing for recently added parameters.

Change-Id: I414594fed56317112be5f3b415871d77e7f7e282
/frameworks/av/include/media/AudioTrack.h
b882e936ead71ee407a5d6f1e7194115fc13c410 20-Mar-2015 Glenn Kasten <gkasten@google.com> Update AudioTrack comments to match AudioRecord

Change-Id: I176a4830513a0b37c38f86815fe637093b9ad52f
/frameworks/av/include/media/AudioTrack.h
85fc799d4cde549c7cc82d9e5c84f21e161ecfbe 20-Mar-2015 Glenn Kasten <gkasten@google.com> AudioTrack::dump() comment

Change-Id: Id3b5210293a77404189555a0c797fb099e3c6c04
/frameworks/av/include/media/AudioTrack.h
05163541326f51cefda91df5127d378c20b5a73f 20-Mar-2015 Glenn Kasten <gkasten@google.com> Remove dead AudioTrack::setAttributesFromStreamType()

Change-Id: I34feb3f9df49458f8a81ddcced4dd769fdaca945
/frameworks/av/include/media/AudioTrack.h
32860f77787f41abac08afdfc2592272ccc31bcb 20-Mar-2015 Glenn Kasten <gkasten@google.com> Deprecate AudioRecord::getInput() and AudioTrack::getOutput()

Does not completely fix the bug, but is a step in the right direction.

Bug: 12593118
Change-Id: Id591cd700ab58fd927ae44c71c81dac55b5cac2d
/frameworks/av/include/media/AudioTrack.h
a9757af8a140a1d5ae261c22f9d7eebef99cbe96 20-Mar-2015 Glenn Kasten <gkasten@google.com> Move AudioTrack::isOffloaded() and isDirect() variants

to be near each other.

Change-Id: Ic26681716ea48886f0bfed23803240466db5d8fa
/frameworks/av/include/media/AudioTrack.h
d2027336b45f524a196403d351ec317782793792 20-Mar-2015 Glenn Kasten <gkasten@google.com> Whitespace

Change-Id: I4640be948ad3caff0eb7525991398a1353e4bfe6
/frameworks/av/include/media/AudioTrack.h
6991ed25d8b5c2f75325ccd7cc522762da6f2b09 20-Mar-2015 Glenn Kasten <gkasten@google.com> Add FIXME to deprecate AudioTrack::getMinFrameCount()

Continuation of previous change, for all APIs that assume a route

Change-Id: Ia1315032cf6366f428db342b16b2e1c3b574f407
/frameworks/av/include/media/AudioTrack.h
d198b85a163330b03e7507c9e8bfeb5f4d958a6c 16-Mar-2015 Glenn Kasten <gkasten@google.com> Fix typos

Fix typos in comments
Add formal parameter name to declaration where it was missing
Fix out of order comments

Change-Id: I1de81ae82af5ca507864e4c7b959111bac898b98
/frameworks/av/include/media/AudioTrack.h
b46f394a85d704dd05287cf9bb77cf86e3c02a38 09-Mar-2015 Glenn Kasten <gkasten@google.com> AudioTrack::obtainBuffer() now returns number of non-contiguous frames

Change-Id: I1f61d7e3d057c3254babe456b4aa0f6a1809da55
/frameworks/av/include/media/AudioTrack.h
54a8a456c2b4b382b3ffe3d99e40703df79c0717 09-Mar-2015 Glenn Kasten <gkasten@google.com> AudioTrack::releaseBuffer parameter is const *

Change-Id: I31ac20863107de05b83cd7f8cd7dd61bed98e456
/frameworks/av/include/media/AudioTrack.h
3f02be2ceeaa4b67dc0b1a81aebcfa049276fad8 09-Mar-2015 Glenn Kasten <gkasten@google.com> AudioTrack obtain/release buffer comments

Change-Id: I0eb178d1ab4eea7f72f4c55852c19b216ca55f5f
/frameworks/av/include/media/AudioTrack.h
abdb990953ffe94a9dc544aea0bed17ef7d5f484 13-Jan-2015 Andy Hung <hunga@google.com> Allow AUDIO_FORMAT_PCM_8_BIT AudioTrack buffers

Previously conversion to AUDIO_FORMAT_PCM_16_BIT was required.
Client shared memory for static tracks and AudioFlinger track creation
and buffer delivery now use native 8 bit PCM data.

Change-Id: I485c07a4971fde9a25442bd43fed95019d39abcc
/frameworks/av/include/media/AudioTrack.h
3c09c78aabcb9d314dfb400258fb99a37c7b50c9 30-Dec-2014 Andy Hung <hunga@google.com> Event driven wake for AudioTrackThread notification changes

Used for setMarkerPosition and setPositionUpdatePeriod.

Change-Id: I0d94b929438a5cd94b295d7c1884f876fae8b5e7
/frameworks/av/include/media/AudioTrack.h
53c3b5fc1afe162a8669cb3d27d6bb14e1847e39 16-Dec-2014 Andy Hung <hunga@google.com> Improve AudioTrack EVENT_LOOP_END and EVENT_BUFFER_END accuracy

Fix timing computation to consider current position.
Fix EVENT_LOOP_END count accuracy (some could be dropped before)
for non-infinite loop static AudioTracks.

Change-Id: I255f692915b55ab6f08ccd6a2365fee3f5d0a4fe
/frameworks/av/include/media/AudioTrack.h
4ede21d9c1f957baf5e561849ff9bbe4bcbefc20 13-Dec-2014 Andy Hung <hunga@google.com> Fix loop and position restoration in static AudioTracks

Allow restoration of loop and position.
Make position and loop synchronously readable.

Bug: 17964637
Change-Id: I8cfb5036e665f55fdff5c67d27e1363ce9a8665d
/frameworks/av/include/media/AudioTrack.h
b187de1ada34a9023c05d020a4592686ba761278 30-Dec-2014 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: I6c8fe626a3825fa9e139319656d682a57b887c97
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
7f1bc8af1c46695191bf7e2aba6467f3616629c0 12-Sep-2014 Andy Hung <hunga@google.com> Fix AudioTrack offloaded timestamp handling.

getTimestamp for offloaded tracks now returns WOULD_BLOCK for
situations where the timestamp is unavailable due to the
previous track still flushing or the timestamp is stale.
It is fixed for normal playback conditions.

Bug: 14659809
Bug: 17428188
Change-Id: Ic9ec07ccabc604236979769db5c4ea2dec252660
/frameworks/av/include/media/AudioTrack.h
200092b7f21d2b98f30b800e79d152636f9ba225 16-Aug-2014 Glenn Kasten <gkasten@google.com> Clean up AudioTrack position and timestamp handling

Replace epoch concept by observing and accumulating server delta
positions. The advantage of using server deltas instead of absolute
values is that they (1) are not sensitive to 32-bit wraparound,
(2) are not sensitive to server behavior for stop(), and
(3) prepare for future 64-bit client positions without requiring 64-bit
positions on server.

Add comments to AudioTrack::getTimestamp() and friends
that the timestamp output parameter is undefined on error.

Don't allow getTimestamp to return a negative frame position after stop().

Accumulate the client released frames, which may be useful for a future API.

Bug: 11815245
Change-Id: I652940fa2db2f34a78c012a3ead0d9204fa29c6e
/frameworks/av/include/media/AudioTrack.h
d9d7fa0873796ac661c44a7fcd6ad5ff697ff01f 24-Jun-2014 Jean-Michel Trivi <jmtrivi@google.com> Support for audio attributes on audio output of media player

Change-Id: Iae4995c98e64add1ab9e6c8ae6501515032755f5
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
faabb51ceef13bf1e3f692219ac410c1cd75d0de 12-Jun-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioTrack construction with audio attributes

Store audio attributes in AudioTrack class.
When an AudioTrack is "set" with non null audio
attributes, derive a stream type that reflects
the attributes.
When an AudioTrack is "set" without attributes,
and only has a stream type, derive default
audio attributes.

Change-Id: I322b91fa9a7e193118960c5e78cdddd85d66f9ad
/frameworks/av/include/media/AudioTrack.h
b773038277ba328696832b690b91ce6e95bd1a6c 01-May-2014 Glenn Kasten <gkasten@google.com> Add client side support for more AUDIO_FORMAT_PCM_*

As much as possible, the checks for specific formats are done on server
side. The only exception is 8-bit, which needs a client side workaround.

Change-Id: I52fe086c039460c8dac009de03b67eb54c56a836
/frameworks/av/include/media/AudioTrack.h
c9b8d90dabdf1234be0117c592f635a92c4eb0d9 27-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>"
142f519aa1acd5804d111e60d100f170fed28405 26-Mar-2014 Glenn Kasten <gkasten@google.com> Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>

Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
/frameworks/av/include/media/AudioTrack.h
2301acc6a9c7a3af4ad01f3d1d0f76f13eca7350 17-Jan-2014 Glenn Kasten <gkasten@google.com> Update comments

Change-Id: I5776313b9b49072cd666d28880f0d07cc73f827b
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
c5a17425986b4ce3384e6956762c86018b49c4a0 13-Mar-2014 Glenn Kasten <gkasten@google.com> Remove name output parameter from createTrack

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

Change-Id: Ia440e02ae4a5a4019a9a2d08970e1ee93ac4c3a3
/frameworks/av/include/media/AudioTrack.h
c644345b0b8f5292a049c4cee2bb7a2a6159b884 11-Mar-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "AudioTrack non-blocking write"
7064fd2dcdfeafea53cd5a992bb78c413542f29f 08-Jan-2014 Haynes Mathew George <hgeorge@codeaurora.org> AudioTrack: When paused, return cached playback position

An offload output can be re-used between two audio tracks having
the same configuration. A timestamp query for a paused track
while the other is running would return an incorrect time.
To fix this, cache the playback position on a pause() and return
this time when requested until the track is resumed.

Bug: 12826612.
Change-Id: I324112ea9827e52fff53ef44cd8513c8d85a0bc4
/frameworks/av/include/media/AudioTrack.h
720ad9ddb2ac6b55b0dfbfcd2d8360151d8ac427 04-Feb-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioTrack non-blocking write

Bug 7531968

Change-Id: I6d0e79fa8cab5b6eb36bcc34977f4cf0d7eec8ea
/frameworks/av/include/media/AudioTrack.h
bce50bfc3846ab008bafa75c5d3f29fd7b5395f7 28-Feb-2014 Glenn Kasten <gkasten@google.com> Fix type of AudioTrack/AudioRecord parameter frameCount

It's size_t consistently

Change-Id: I29638ef59ac773218025f2403a3508a307b487e0
/frameworks/av/include/media/AudioTrack.h
838b3d8bafa4a781e277870dee4e0390165cff52 28-Feb-2014 Glenn Kasten <gkasten@google.com> Fix type of AudioTrack/AudioRecord parameter notificationFrames

It's uint32_t consistently

Change-Id: If8298c7e9aeea2b951fe47b675adbdf48d104846
/frameworks/av/include/media/AudioTrack.h
d457c970c8d08519cd77280a90b61ae1e342cfe3 11-Feb-2014 Marco Nelissen <marcone@google.com> Track pid for each session

so they can be properly freed.

Change-Id: I6f389035bc29e74e7c367c1c6d0252b180f666b3
/frameworks/av/include/media/AudioTrack.h
01d3acba9de861cb2b718338e787cff3566fc5ec 06-Feb-2014 Glenn Kasten <gkasten@google.com> Fix clang warnings in AudioFlinger

Change-Id: I0fa61025c979709ad7d655bc717df5f194b6089e
/frameworks/av/include/media/AudioTrack.h
363fb75db26698cbb50065506e0c80b61d1fbf92 15-Jan-2014 Glenn Kasten <gkasten@google.com> Remove the redundant parameters from createTrack_l()

AudioRecord::openRecord_l() code was refactored earlier to
remove the redundant parameters:
> Change-Id: I124dce344b1d11c2dd66ca5e2c9aec0c52c230e2

This changelist refactors AudioTrack similarly.

Change-Id: Iefd2bd662870ea81d04eff7b7c26f9c8b0dadd26
/frameworks/av/include/media/AudioTrack.h
38e905b3cbba4da443d799b16999989781afc6d8 13-Jan-2014 Glenn Kasten <gkasten@google.com> Refactor code related to I/O handles to reduce chance for leaks

The AudioRecord input handle code was refactored earlier
to fix a potential handle leak, and to simplify the code:
> Change-Id: I124dce344b1d11c2dd66ca5e2c9aec0c52c230e2

This changelist refactors AudioTrack similarly,
and adds further cleanup of both AudioTrack and AudioRecord.

We attempt to implement the rules for referencing counting I/O handles,
but there is still the possibility of a handle leak if the client process
dies after allocating the handle reference but before releasing it.
That issue is being tracked separately.

Details:
- AudioSystem::getOutput() is now called within createTrack_l
- restoreTrack_l was missing offload info
now it has the info available,
but is not yet being called for offloaded tracks
- AudioTrack::getOutput() is now const
- Remove getOutput_l()

Change-Id: I44a0a623d24fc5847bcac0939c276400568adbca
/frameworks/av/include/media/AudioTrack.h
1071915ad4ffb47825a946706f8fa73c0d22d7f8 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Make copy of audio_offload_info_t for future use"
543140eb709a07bc386eb5f667a4a72e31dba56c 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Move up initialization of mFormat, mStreamType, and mSharedBuffer earlier"
32a7e0a5f7b000951b9adb80b17796f35b024816 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Unify comments between AudioTrack and AudioRecord"
b5ccb2d99b2af400c70777a6452f090ac14f5a96 13-Jan-2014 Glenn Kasten <gkasten@google.com> Make copy of audio_offload_info_t for future use

Change-Id: I515970aa0660418d5d1640fb1bf477e112c89bdd
/frameworks/av/include/media/AudioTrack.h
dd5f4c8c4059f890e81b28b026a688febb4e1dd9 13-Jan-2014 Glenn Kasten <gkasten@google.com> Move up initialization of mFormat, mStreamType, and mSharedBuffer earlier

This will allow removal of most of the parameter list to createTrack_l.

Also check for valid stream type at client so we can log a better error
message.

Change-Id: Ia7176896d47fbb49106119fca26d9de8e7efe859
/frameworks/av/include/media/AudioTrack.h
ac1954cb9a480a409e8cee4193fc534a6a29fbb6 15-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Document AudioTrack mFrameCount and mReqFrameCount better"
5b27ccd67c845aa20a12a1fb58339e7e81e3d536 15-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Use AUDIO_SESSION_ALLOCATE instead of 0"
2b2165c75790050810460c8de3f414876bce4c0e 13-Jan-2014 Glenn Kasten <gkasten@google.com> Unify comments between AudioTrack and AudioRecord

Change-Id: I00a1025e2891a1c96218b3c2187eaddda6614ebc
/frameworks/av/include/media/AudioTrack.h
23a7545c4de71e989c2d8ebf1d5b9dcf463c36a9 13-Jan-2014 Glenn Kasten <gkasten@google.com> Document locking rules for mFlags, and fix discrepancies

Change-Id: Id45ba544cc84133ed5e578fb4fd8a11b62211dc1
/frameworks/av/include/media/AudioTrack.h
1c5977d03935be8c385e90501b34083714fbdab1 13-Jan-2014 Glenn Kasten <gkasten@google.com> Remove obsolete AudioTrack::processStreamEnd()

Change-Id: I7c01b9d2e109acf8c393d2c3b7b1985f6647d96c
/frameworks/av/include/media/AudioTrack.h
396fabdb6efcdac5aea3d9f559d1beedf6a4cedc 08-Jan-2014 Glenn Kasten <gkasten@google.com> Document AudioTrack mFrameCount and mReqFrameCount better

and remove unnecessary initialization of mFrameCount in set().

Change-Id: I9effeb0a6dd035ca02fe77f6992c55d9515b4df6
/frameworks/av/include/media/AudioTrack.h
66a0467fdddada4caabd0f0a999fbb367fea7bee 08-Jan-2014 Glenn Kasten <gkasten@google.com> Cleanup AudioTrack::getMinFrameCount error handling

Guarantee to return a non-zero frameCount for return status NO_ERROR;

Return the correct specific status_t if any of the AudioSystem APIs fail,
instead of the generic NO_INIT.

API change: getMinFramCount no longer defaults to zero on error, so
callers _must_ check the return status. This change makes
getMinFrameCount more like other APIs. All known callers were reviewed,
and they do check the return status.

Change-Id: I4a8342a75ee89a068c23c84b8380ed9d1b968507
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
7c7be1e05634d96d08210efb4bdeb012ffba440d 20-Dec-2013 Glenn Kasten <gkasten@google.com> Fix some (but not all) unused parameter warnings

Change-Id: Ia99e23a0b46db3f3e6aa46f9018e63c14f4af369
/frameworks/av/include/media/AudioTrack.h
6f59db12a64f4496866952a251122ccb77a36c6b 27-Jul-2013 Eric Laurent <elaurent@google.com> update offloaded audio track sampling rate

AudioPlayer must read the sampling rate from offloaded audio sinks
whenever a new time position is computed as the decoder can update
the sampling rate on the fly.

Change-Id: I997e5248cfd4017aeceb4e11689324ded2a5bc88
/frameworks/av/include/media/AudioTrack.h
462fd2fa9eef642b0574aa7409de0bde3fec8d43 14-Jan-2013 Marco Nelissen <marcone@google.com> Assign blame for playback wakelocks.

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

Change-Id: I7329f88a288a95a582a78005a1c3d16a5a611e31
/frameworks/av/include/media/AudioTrack.h
abe0948c7b9aa32dceb82cebbfca52beb782754b 17-Oct-2013 Glenn Kasten <gkasten@google.com> am b2059ff3: am f8f15b05: Merge "Fix race condition in AudioTrack::pause followed by start" into klp-dev

* commit 'b2059ff384eee8ffb70a7ec8fc5570405201c734':
Fix race condition in AudioTrack::pause followed by start
598de6c701e989385eeffa7c5dfd61f0459a2631 17-Oct-2013 Glenn Kasten <gkasten@google.com> Fix race condition in AudioTrack::pause followed by start

Bug: 11148722
Change-Id: Iec88f00c8510363d4418e4b8d5b34feb06ecf04d
/frameworks/av/include/media/AudioTrack.h
dd0a81253bcf4daef56e991c94dc3c0d1124ef90 20-Sep-2013 Glenn Kasten <gkasten@google.com> am f2c643c8: am 3b3cfcfa: Merge "Fix slow AudioTrack and AudioRecord destruction" into klp-dev

* commit 'f2c643c89e405b57c7ce42067b876fb80031e5fa':
Fix slow AudioTrack and AudioRecord destruction
5a6cd224d07c05b496b6aca050ce5ecf96f125af 20-Sep-2013 Glenn Kasten <gkasten@google.com> Fix slow AudioTrack and AudioRecord destruction

There were two causes for the slowness:

When thread was paused, it used nanosleep and sleep. These usually
run to completion (except for POSIX signal, which we avoid because it
is low-level). Instead, replace the nanosleep and sleep by condition
timed wait, as that can be made to return early by a condition signal.
Another advantage of condition timed wait is that a condition wait was
already being used at top of thread loop, so it is a simpler change.

The AudioRecord destructor was missing a proxy interrupt that was correct
in AudioTrack. This proxy interrupt is needed in case another thread
is blocked in proxy obtainBuffer.

Does not address the 1 second polling for NS_WHENEVER.

Bug: 10822765
Change-Id: Id665994551e87e4d7da9c7b015f424fd7a0b5560
/frameworks/av/include/media/AudioTrack.h
ec9ad1b0947f5d6b465281312dbe92f096a8f881 30-Aug-2013 Glenn Kasten <gkasten@google.com> am f94b2946: am 56b59224: Merge "Add IAudioTrack::getTimestamp()" into klp-dev

* commit 'f94b2946a511c5cbb6b9001449ca8278cb332bda':
Add IAudioTrack::getTimestamp()
6dc365f0d5a92084517f0c3846e4f07fc7206bab 30-Aug-2013 Glenn Kasten <gkasten@google.com> am 73e4f3d4: am 865f6f24: Merge "New AudioTrack C++ API for audio timestamps" into klp-dev

* commit '73e4f3d44f7022b03943ae34f08363e049e4b46f':
New AudioTrack C++ API for audio timestamps
53cec22821072719ee02c856e9ac2dda2496c570 29-Aug-2013 Glenn Kasten <gkasten@google.com> Add IAudioTrack::getTimestamp()

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

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

Change-Id: I9861d1454cff7decf795d5d5898ac7999a9f3b7e
/frameworks/av/include/media/AudioTrack.h
ce70374bf105f8a6160bf5dd70affea012b2a464 20-Jul-2013 Glenn Kasten <gkasten@google.com> New AudioTrack C++ API for audio timestamps

This new API is intended to replace latency(), especially for A/V sync.
The application will receive periodic timestamp notifications. The period
is unspecified, but will likely be more frequent after a pause or stop,
set position, underrun, display on/off change, route change, or when audio
framework notices drift. It will be up to the higher level application
(e.g. Stagefright) to reconstruct a clock that updates more frequently.

The current latency() method doesn't indicate when latency changes
due to screen on/off state, route changes, etc.

Includes squahsed change-Id: I2082f8752040be0c234b1a6f1be2e269abf2ce7c
Dummy implementation of AudioTrack:getTimestamp()
Rename AudioTrack::Timestamp to AudioTimestamp.
Renaming and pulling up to a higher level allows more modules to use it.

Change-Id: Ibf7f6a207c3f8d8697f25ede2cd5200697fadb86
(cherry picked from commit dd69eb893867634fd169c03204a6ad7c74b351e7)
/frameworks/av/include/media/AudioTrack.h
e198c360d5e75a9b2097844c495c10902e7e8500 13-Aug-2013 Glenn Kasten <gkasten@google.com> Whitespace

Change-Id: Id3ccc183a03421330d0498faaa62a45915cdc3d6
/frameworks/av/include/media/AudioTrack.h
2fc14730e4697a6f456b4631549c9981f6b0b115 05-Aug-2013 Glenn Kasten <gkasten@google.com> Comments

Change-Id: I56f82904cb3855bad6f33ad1ff4ddf66a61c5720
/frameworks/av/include/media/AudioTrack.h
f31abb4ee82050030b3e5a0793bb2b8e30f40d31 07-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Cleanup comments for the new control block implementation"
9b26847ed122a601ba857e0ef22ee2c818641120 05-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Make AudioRecord and AudioTrack comments more similar"
02de89293b74ab1e9a77ce2367c5c499ab038968 31-Jul-2013 Glenn Kasten <gkasten@google.com> Cleanup comments for the new control block implementation

There was some obsolete and incomplete text left over
after the new control block code was submitted.
This cleans up all those comments to be accurate again.

Change-Id: Ic52f5869cb723cde25d709514d6deea6aa6f20aa
/frameworks/av/include/media/AudioTrack.h
743732236ab84e94168378cdb293964861b1ed00 03-Aug-2013 Glenn Kasten <gkasten@google.com> Remove default parameters for AudioTrack

The defaults aren't needed; all users must know these values.

Change-Id: I0c1c97cb80bfea8e69a7cfa53ec85a91a8d48bb5
/frameworks/av/include/media/AudioTrack.h
6ca126d5c83386941c5cb9600099e5510e4430d6 31-Jul-2013 Glenn Kasten <gkasten@google.com> Make AudioRecord and AudioTrack comments more similar

Change-Id: I122a7cf7bfc162090cb27f37c325db7a23985bc7
/frameworks/av/include/media/AudioTrack.h
d054c32443a493513ab63529b0c8b1aca290278c 12-Jul-2013 Glenn Kasten <gkasten@google.com> Move control block mName to createTrack() output

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

Change-Id: I6e51003a1293b6800258c31b22cff2eba42162e7
/frameworks/av/include/media/AudioTrack.h
b1a270d1e926fb9a01b4265a7675ed0c2c8f4868 14-May-2013 Richard Fitzgerald <rf@opensource.wolfsonmicro.com> libmedia: offloaded playback support

- start() returns a status so that upper layers can
recreate a non offloaded track in case of error.

- Added states to handle offloaded tracks specific:
- waiting for stream end (drain) notification by
audio flinger
- allow pause while waiting for stream end notification

- getPosition() queries the render position directly from
audio HAL.

- disable APIs not applicable to offloaded tracks

- Modified track restoring behavior for invalidated
offloaded tracks: just send the callback and wait for
upper layers to create a new track.

- Added wait for stream end management in audio track client
proxy. Similar to obtainBuffer and should be factored in.

Change-Id: I0fc48117946364cb255afd653195498891f622bd
Signed-off-by: Eric Laurent <elaurent@google.com>
/frameworks/av/include/media/AudioTrack.h
fb1fdc9d6603aa228362e7349451f6455c9849c2 11-Jul-2013 Glenn Kasten <gkasten@google.com> Add comments

Change-Id: Ifbf3a46a4183c8abc0feee1c588953ab10303cc1
/frameworks/av/include/media/AudioTrack.h
ad3af3305f024bcbbd55c894a4995e449498e1ba 25-Mar-2013 Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Public API changes for audio offload support.

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

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

- CBlk flag for stream end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I4e9b7fa99858b488ac98a441fa70e31dbba1b865
/frameworks/av/include/media/AudioTrack.h
2799d743ee2ae5a25fe869a7f9c052acc029559f 30-May-2013 Glenn Kasten <gkasten@google.com> Use sp<AudioTrack> instead of raw AudioTrack *

This change prepares for the new implementation of AudioTrack client, which
will require clients to use only sp<AudioTrack>, not raw AudioTrack *.
A raw delete will cause a race condition during AudioTrack destruction.

AudioTrack was made a RefBase by commit b68a91a70bc8d0d18e7404e14443d4e4020b3635
on 2011/11/15, when it was needed by OpenSL ES (for the callback protector).
At that time, the only other client that was also converted from
AudioTrack * to sp<AudioTrack> was android.media.AudioTrack JNI in
project frameworks/base (file android_media_AudioTrack.cpp).

Details:
* Use .clear() instead of delete followed by = NULL.
* ALOG %p need .get().
* sp<> don't need to be listed in constructor initializer, if initially 0.
* Use == 0 for sp<> vs == NULL for raw pointers.
* Use if (sp != 0) instead of if (raw).

Change-Id: Ic7cad25795d6e862e112abdc227b6d33afdfce17
/frameworks/av/include/media/AudioTrack.h
61aa989a5768b9b0571ca14edaf15886509a0ec8 03-May-2013 Eric Laurent <elaurent@google.com> am 1641f328: am 4170f515: Merge "Remove timing jitter during startup of audio" into jb-mr2-dev

* commit '1641f328d4de3b2b61481607dc482ccaefe808a9':
Remove timing jitter during startup of audio
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
/frameworks/av/include/media/AudioTrack.h
660fbbb77f42745d2c05b436f1a09c5cbd3853c5 09-Mar-2013 Glenn Kasten <gkasten@google.com> Merge "Propose new interpretation for setPosition and setLoop"
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
/frameworks/av/include/media/AudioTrack.h
9c6745f128648f6e0144b74ee593911a9fa10d51 30-Nov-2012 Glenn Kasten <gkasten@google.com> Propose new interpretation for setPosition and setLoop

Add new API getBufferPosition to return position relative
to start of fixed buffer.

Change-Id: I7aca8e392d45b988545f07b36b5032691057b03e
/frameworks/av/include/media/AudioTrack.h
e3aa659e9cee7df5c12a80d285cc29ab3b2cbb39 04-Dec-2012 Glenn Kasten <gkasten@google.com> Start isolating control block accesses in a proxy

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

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

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

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

Simplify OutputTrack::obtainBuffer.

Change-Id: I2249f9d04f73a911a922ad1d7f6197292c74cd92
/frameworks/av/include/media/AudioTrack.h
083d1c1492d496960d5b28f4664ff02101736677 01-Dec-2012 Glenn Kasten <gkasten@google.com> Emphasize distinction between streaming and static

Update comments and improve error checks to match

Change-Id: I7370d6e59a7ef26dfb284a8b058d5ab2e0a42ccf
/frameworks/av/include/media/AudioTrack.h
4bae3649d504d590a546717a8e49f96a30d9a745 30-Nov-2012 Glenn Kasten <gkasten@google.com> flush() comments and checks

flush() is only useful for streaming mode.
It is a no-op if track is active or uses a static buffer.

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

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

Change-Id: I88a9b4f675b6dca2948549414f9ec2c192d29269
/frameworks/av/include/media/AudioTrack.h
01437b7cdaecf53acb46b50ff8b5d86b9d36eb20 29-Nov-2012 Glenn Kasten <gkasten@google.com> AudioTrack inline short const methods

Change-Id: I142917edb454d510bbe545e94e6eaea30b650fae
/frameworks/av/include/media/AudioTrack.h
a42ff007a17d63df22c60dd5e5fd811ee45ca1b3 14-Nov-2012 Glenn Kasten <gkasten@google.com> Clean up channel count and channel mask

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

Change-Id: I5dc2b18eb609b2c0dc3091994cbaa4628062c17f
/frameworks/av/include/media/AudioTrack.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
/frameworks/av/include/media/AudioTrack.h
e33054eb968cbf8ccaee1b0ff0301403902deed6 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use size_t for frame counts

Also fix typo: bufferCount should be frameCount.

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

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

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

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

Change-Id: I85d7d2f6381b251db5695202fec75128883a8662
/frameworks/av/include/media/AudioTrack.h
83a0382dc17364567667a4e6135db43f5bd92efc 12-Nov-2012 Glenn Kasten <gkasten@google.com> Move frame size out of the control block

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

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

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

Change-Id: Ie474557db7cb360f2d9a0f11600a68f5a3d46f07
/frameworks/av/include/media/AudioTrack.h
a47f3165f53c8e8fb8907a94de7417e2c3047eeb 07-Nov-2012 Glenn Kasten <gkasten@google.com> Simplify AudioTrack::restoreTrack_l()

Remove CBLK_RESTORING and CBLK_RESTORED from control block flags,
for AudioTrack only. They are still used by AudioRecord.

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

Change-Id: Iae4798f5b527c492bdaf789987ff3a1dadd0cb37
/frameworks/av/include/media/AudioTrack.h
659004c2949620d8adb29e1d950a2dd1c75ba9a9 08-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Add all-channel AudioTrack::setVolume() API"
d5ed6e88a9bea1879e41d7defaf1edea7c09f554 02-Nov-2012 Glenn Kasten <gkasten@google.com> Fix call to restoreTrack_l() without lock held

Also document lock order

Change-Id: I2c1f273a0a51fa79ee3dd766de8d23083e270051
/frameworks/av/include/media/AudioTrack.h
05d499958e4030938ed77a924ebdd9899f36752e 06-Nov-2012 Glenn Kasten <gkasten@google.com> Remove unused fields in AudioTrack::Buffer

Change-Id: Iab75f6e2348d8b6d1f3cec95aeb3fcd5135dfb50
/frameworks/av/include/media/AudioTrack.h
b1c0993b215c5c3eebd1c6bafc22bba23d57a70b 28-Feb-2012 Glenn Kasten <gkasten@google.com> Add all-channel AudioTrack::setVolume() API

Add combined channel APIs setVolume to AudioTrack,
and remove obsolete getVolume.

Change-Id: I0c87bfdbff4f4292259fa33e65f67badbafd270b
/frameworks/av/include/media/AudioTrack.h
847d05dc8fa144dcf8f4f435d6a6ac1727f00937 28-Feb-2012 Glenn Kasten <gkasten@google.com> Remove deprecated AudioTrack APIs

Change-Id: I88be6525f3e33df529c0c3cb701d12a484809477
/frameworks/av/include/media/AudioTrack.h
ad2f6dbe14e601ae69f3697bc17106f9fd7d59d6 01-Nov-2012 Glenn Kasten <gkasten@google.com> AudioTrack comments

Change-Id: I08988f635c5bc6f4c35e9c4188f3d6fa557bc4c2
/frameworks/av/include/media/AudioTrack.h
85ab62c4b433df3f1a9826bed1c9bec07a86c750 01-Nov-2012 Glenn Kasten <gkasten@google.com> Line length 100

Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
/frameworks/av/include/media/AudioTrack.h
c3ae93f21280859086ae371428ffd32f39e76d50 30-Jul-2012 Glenn Kasten <gkasten@google.com> Update audio comments

Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
/frameworks/av/include/media/AudioTrack.h
a997e7a7c5aa2fc7e95316218316f8b7b98786ba 07-Aug-2012 Glenn Kasten <gkasten@google.com> Revert "Swap the order of creating IAudioTrack and thread"

This reverts commit 5d464eb0b8cffb994a754ff108795e858a882414.
It caused the wrong thread ID -1 to be passed to IAudioFlinger::createTrack().

Change-Id: Ic221d2bb4af572d3d2d752af19238c52f6728e3a
/frameworks/av/include/media/AudioTrack.h
5d464eb0b8cffb994a754ff108795e858a882414 23-Jun-2012 Glenn Kasten <gkasten@google.com> Swap the order of creating IAudioTrack and thread

Simplifies the error recovery in case IAudioTrack fails.

Change-Id: I6aee41a2ac747a5689fb4836b04174e6107bf32f
/frameworks/av/include/media/AudioTrack.h
28b76b334f92a15a2be3cc9e2f7d229a3275d1ac 04-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_channel_mask_t for channel mask

Change-Id: I1c1896da48983aa9f1462a4b471f910498816f60
/frameworks/av/include/media/AudioTrack.h
d4070955e28ae62aa4be1657f9d32acde104bb86 12-Jul-2012 Glenn Kasten <gkasten@google.com> Remove dead code in libmedia

Change-Id: I7d8201590cda29c9fa99662a4fdba222091febfe
/frameworks/av/include/media/AudioTrack.h
a636433cbd09c0708b85f337ef45c0cdef3bcb4d 19-Apr-2012 Glenn Kasten <gkasten@google.com> Use C APIs instead of C++ APIs for policy

The C++ APIs are going away.

Note: we use tid == 0 which is not supported yet by the C APIs,
do not submit this until that is added.

Change-Id: I0e90789e6c81c69f2544e899c52421ea5d1342be
/frameworks/av/include/media/AudioTrack.h
3acbd053c842e76e1a40fc8a0bf62de87eebf00f 28-Feb-2012 Glenn Kasten <gkasten@google.com> Configure policy of mediaserver threads

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

Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
/frameworks/av/include/media/AudioTrack.h
4a4a0959bca78e03e3c3f486ba17829c28314d8c 19-Mar-2012 Glenn Kasten <gkasten@google.com> AudioTrack client fast policy

Change-Id: I42ce691df3f586ac061b62237f35a263a0116f1f
/frameworks/av/include/media/AudioTrack.h
291f4d505aff81969e6666049d3cc3446f836af2 19-Mar-2012 Glenn Kasten <gkasten@google.com> Remove enforceFrameCount

It was only used to decide whether to issue a warning.
The warning was issued the first time track was created but
not at re-creation. Now it is a verbose message every time,
not a warning since it happens all the time with key clicks on A2DP.

Change-Id: I9d39f53c0a7eb84b666e55b1b76ff830cf8f37ba
/frameworks/av/include/media/AudioTrack.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
/frameworks/av/include/media/AudioTrack.h
18868c5db2f90309c6d11e5837822135e4a0c0fa 07-Mar-2012 Glenn Kasten <gkasten@google.com> Use audio_policy_output_flags_t consistently

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

Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
/frameworks/av/include/media/AudioTrack.h
d8d6185c978c9b27ca69e7791785e0983ed9e8b8 06-Mar-2012 Eric Laurent <elaurent@google.com> AudioTrack: relax check on minimum buffer size

Current AudioTrack implementation enforces that the requested audio
buffer size is at least corresponding the audio latency.
This requirement is too strong and leads to problems with current
stagefright and AudioSink implementations when playing over output
streams with long latency.

Ultimately, the AudioSink design should be changed to specify a minimum
buffer size in time or frames units but not in buffer count units.

Change-Id: I8ba603956f92ac49143a8249572665aa548f2f0f
/frameworks/av/include/media/AudioTrack.h
4ff14bae91075eb274eb1c2975982358946e7e63 09-Feb-2012 John Grossman <johngro@google.com> Upintegrate Audio Flinger changes from ICS_AAH

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

Change-Id: Ide52d48809bdbed13acf35fd59b24637e35064ae
Signed-off-by: John Grossman <johngro@google.com>
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
38f5d71e72f3b76c5b519614d27f051d53cd2712 08-Feb-2012 Glenn Kasten <gkasten@google.com> Remove dead code AudioTrack::getLoop

Change-Id: I868329c52f31bc20125f068500d8f892b4ec9796
/frameworks/av/include/media/AudioTrack.h
4f9b0c54011eb8fd2ccfb393c2dcd51cd07800e0 08-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Remove dead mutex in AudioTrack/AudioRecord thread"
a5224f319e2ba4b51ddb4287705ccf8d4b8ecc51 04-Jan-2012 Glenn Kasten <gkasten@google.com> AudioTrack declare more methods const

Change-Id: I4999e984460893961d0d8092cff17f3cf07d7214
/frameworks/av/include/media/AudioTrack.h
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
/frameworks/av/include/media/AudioTrack.h
0e265cf36d201a7ccc0238b5c60b50f43d1dc450 02-Feb-2012 Glenn Kasten <gkasten@google.com> Remove dead mutex in AudioTrack/AudioRecord thread

The client callback threads had mutexes called AudioTrackThread::mLock
and ClientRecordThread::mLock. These mutexes were only used by start()
and stop(), and were unused by the thread itself. But start() and
stop() already have their own protection provided by AudioTrack::mLock
and AudioRecord::mLock. So the thread mutexes can be removed.

Change-Id: I098406d381645d77fba06a15511e179a327848ef
/frameworks/av/include/media/AudioTrack.h
335787fe43596f38ea2fa50b24c54d0823a3fb1d 21-Jan-2012 Glenn Kasten <gkasten@google.com> Remove AudioFlinger dependencies on client

Change-Id: Ibb591e41a3ca5d7015e2b66b98b8fef5f415fb37
/frameworks/av/include/media/AudioTrack.h
c813985abd8ba61e999b3505f6a332574f87a1be 18-Jan-2012 Andreas Huber <andih@google.com> Temporarily restore AudioSystem/AudioTrack APIs with their former signatures

until we get updated prebuilts from vendor.

Change-Id: I8aae81d2513edca0ab268053a11c8c4206879e61
/frameworks/av/include/media/AudioTrack.h
613882293184e575a44bff681a3decaefe889e69 17-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use size_t for frame size"
b9980659501d0428d65d8292f3c32da69d37fbd2 11-Jan-2012 Glenn Kasten <gkasten@google.com> Use size_t for frame size

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

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

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

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

Change-Id: Ia33bfd70edca8c2daec9052984b369cd8eee2a83
/frameworks/av/include/media/AudioTrack.h
4cc55d53d542c4f4ed645738cebb65b9e7eb6c44 12-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_format_t consistently"
e1c3962e268ffc12bfd1bd9ea84da1f135f36960 04-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_format_t consistently

Was int, uint32_t, uint16_t, and uint8_t with 2-bit bitfield.
Also replace 0 by AUDIO_FORMAT_DEFAULT and replace 1 by
AUDIO_FORMAT_PCM_16_BIT.

Change-Id: Ia8804f53f1725669e368857d5bb2044917e17975
/frameworks/av/include/media/AudioTrack.h
9a2aaf927e56a4b4acab23ef16b3f133a9f48a63 03-Jan-2012 Glenn Kasten <gkasten@google.com> Clean up AudioTrack::mActive and stopped()

mActive is protected by mLock; volatile is meaningless on SMP.

Fixed a couple of places where mActive was accessed without a lock:
- stopped()
- processAudioBuffer()

Added stopped_l() for cases where we already hold the lock.

Made mActive a bool not int.

Moved down a lock in setPosition that was being acquired too early.

Change-Id: I73ff368e991c0db9f9472df0b3f96fd33fcc7311
/frameworks/av/include/media/AudioTrack.h
362c4e697d8e9c034e964ac7b40227e054491547 14-Dec-2011 Glenn Kasten <gkasten@google.com> Audio C++ comments

Change-Id: I84906ebb9dfcfa5b96b287d18364b407f02a30c1
/frameworks/av/include/media/AudioTrack.h
c9260c15c1e7e2743039c964b8769379a3fff332 28-Nov-2011 Glenn Kasten <gkasten@google.com> Merge "Make AudioTrack a RefBase so wrappers not needed"
879135196fd1c97deefc538c888037c56c2879a7 23-Jun-2011 Glenn Kasten <gkasten@google.com> Bug 4903178 Restore priority and cgroup on stop

On AudioTrack and AudioRecord stop or failed start, restore the priority
and cgroup of the caller to their previous values, rather than forcing
to NORMAL. Dependent on new thread APIs.

Also fixes bug where priority was set to AUDIO but cgroup not set.

Change-Id: Ib83893918fb4fdf57c6b87884b51038997a631d8
/frameworks/av/include/media/AudioTrack.h
b68a91a70bc8d0d18e7404e14443d4e4020b3635 15-Nov-2011 Glenn Kasten <gkasten@google.com> Make AudioTrack a RefBase so wrappers not needed

Change-Id: I2305abe586ac41251af04a194bc818c110a1b293
/frameworks/av/include/media/AudioTrack.h
cfe2ba6b01a258e39f9c215ffc7b750e0b68f708 14-Sep-2011 Eric Laurent <elaurent@google.com> Issue 5298399: Lost speech after a crash in gTalk.

Fixed problem in AudioTrack::restoreTrack_l() causing a permanent
failure if the IAudioTrack interface to AudioFlinger could not be
restored at the first attempt.

Change-Id: I039d4fe2dca8d3baf71f1a6c51119f27a67b6611
/frameworks/av/include/media/AudioTrack.h
cd07594333cbe8b2c86c6609cce01a74d6cc33f8 26-Aug-2011 Jean-Michel Trivi <jmtrivi@google.com> Bug 4364249 Play position is 0 after flushing AudioTrack

AudioTrack::stop() is not synchronous, so a stop() followed
by flush(), which is synchronous, will not always report
a playhead position of 0 after being called.
This CL adds a flag to mark a track as flushed, and report the
correct playhead position in this state.
Bug 5217011 has been created to address the real issue in the
future, where flush could be made synchronous, to properly
address bug 4364249.

Change-Id: Icf989d41a6bcd5985bb87764c287f3edb7e26d12
/frameworks/av/include/media/AudioTrack.h
d217a8c4632b3e3065f8c2a26b9ce4dc4c97171f 02-Jun-2011 Glenn Kasten <gkasten@google.com> Revert "Use AudioTrack::event_type not int in callback"

This reverts commit 2225e4b7049fa3fb9d39a068b8268b63c952d7c1
/frameworks/av/include/media/AudioTrack.h
013b5a67d6f8e12a1b06e74863daec1bee4d99c1 05-May-2011 Glenn Kasten <gkasten@google.com> Use AudioTrack::event_type not int in callback

Change-Id: Ifefc708d46874e04fd0d01cb6e2d43b987ee796c
/frameworks/av/include/media/AudioTrack.h
0d255b2d9061ba31f13ada3fc0f7e51916407176 25-May-2011 Jean-Michel Trivi <jmtrivi@google.com> Use channel mask instead of channel count for track creation

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

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

Change-Id: I50d87bfb7d7afcabdf5f12d4ab75ef3a54132c0e
/frameworks/av/include/media/AudioTrack.h
fce7a473248381cc83a01855f92581077d3c9ee2 20-Apr-2011 Dima Zavin <dima@android.com> audio/media: convert to using the audio HAL and new audio defs

Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/include/media/AudioTrack.h
1703cdfee717b1b312bf8979816a9e2f16a82e5d 07-Mar-2011 Eric Laurent <elaurent@google.com> Fix issue 3439872: video chat and bluetooth SCO

This change fixes the stability problems experienced when using
a bluetooth headset supporting both A2DP and SCO. Problems occur
when starting the video chat at which time the A2DP output is being
stopped to start SCO. At that time, active AudioTracks are invalidated
by AudioFlinger so that a new AudioTrack binder interface can be
recreated by the client process on the new mixer thread with correct parameters.
The problem was that the process to restore the binder interface was not
protected against concurrent requests which caused 2 binder interfaces
to be created sometimes. This could lead to permanent client deadlock
if one of the client threads was waiting for a condition of the first
created binder interface while the second one was created (as the AudioFlinger
would only signal conditions on the last one created).
This concurrent request situation is more likely to happen when a client
uses the JAVA AudioTrack as the JNI implementation uses simultaneously the
native AudioTrack callback and write push mechanisms. By doing so, the code
that checks if the binder interface should be restored (in obtainBuffer()) is
much more likely to be called concurrently from two different threads.

The fix consists in protecting the critical binder interface restore phase
with a flag in the AudioTrack control block. The first thread acting upon the binder
interface restore request will raise the flag and the second thread will just wait for
a condition to be signaled when the restore process is complete.

Also protected all accesses to the AudioTrack control block by a mutex to prevent
access while the track is being destroyed and restored. If a mutex cannot be held
(e.g because we call a callback function), acquire a strong reference on the IAudioTrack
to prevent its destruction while the cblk is being accessed.

Modified AudioTrack JNI to use GetByteArrayElements() instead of
GetPrimitiveArrayCritical() when writing audio buffers. Entering a critical section would
cause the JNI to abort if a mediaserver crash occurs during a write due to the AudioSystem
callback being called during the critical section when media server process restarts.
Anyway with current JNI implementation, either versions do not copy data most of the times
and the criticial version does not guaranty no data copy.

The same modifications have been made to AudioRecord.

Change-Id: Idc5aa711a04c3eee180cdd03f44fe17f3c4dcb52
/frameworks/av/include/media/AudioTrack.h
f5aafb209d01ba2ab6cb55d1a12cfc653e2b4be0 18-Nov-2010 Eric Laurent <elaurent@google.com> Fix issue 3157123.

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

Change-Id: I6f55b2cabdcd93d64ef19446735b8f33720f8dbc
/frameworks/av/include/media/AudioTrack.h
2beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1 16-Jul-2010 Eric Laurent <elaurent@google.com> Added support for auxiliary audio effects to AudioTrack and MediaPlayer.

Added methods to AudioTrack and MediaPlayer java classes to enable use of
auxiliary audio effects. The effect can be attached and detached by specifying its
ID and the send level controlled.

Change-Id: Ie74ff54a453096a742688476f612ce355543b6f3
/frameworks/av/include/media/AudioTrack.h
33005a932c60a0780fe9b7307d5988df3d9f6c26 16-Jun-2010 Chia-chi Yeh <chiachi@android.com> media: add AudioTrack::getMinFrameCount().

Change-Id: If15162583d1d16d89f59be0793106afe77417f35
/frameworks/av/include/media/AudioTrack.h
be916aa1267e2e6b1c148f51d11bcbbc79cb864c 02-Jun-2010 Eric Laurent <elaurent@google.com> Issue 2667801: [Audio Effect Framework] AudioFlinger, AudioMixer AudioTrack modifications.

First drop of audio framework modifications for audio effects support.

- AudioTrack/AudioRecord:
Added support for auxiliary effects in AudioTrack
Added support for audio sessions
Fixed left right channel inversion in setVolume()

- IAudioFlinger:
Added interface methods for effect enumeraiton and instantiation
Added support for audio sessions.

- IAudioTrack:
Added method to attach auxiliary effect.

- AudioFlinger
Created new classes to control effect engines in effect library and manage effect connections to tracks or
output mix:
EffectModule: wrapper object controlling the effect engine implementation in the effect library. There
is one EffectModule per instance of an effect in a given audio session
EffectChain: group of effects associated to one audio session. There is one EffectChain per audio session.
EffectChain for session 0 is for output mix effects, other chains are attached to audio tracks
with same session ID. Each chain contains a variable number of EffectModules
EffectHandle: implements the IEffect interface. There is one EffectHandle object for each application
controlling (or using) an effect module. THe EffectModule maintians a list of EffectHandles.

Added support for effect modules and effect chains creation in PlaybackThread.
modified mixer thread loop to allow track volume control by effect modules and call effect processing.

-AudioMixer
Each track now specifies its output buffer used by mixer for accumulation
Modified mixer process functions to process tracks by groups of tracks with same buffer
Modified track process functions to support accumulation to auxiliary channel

Change-Id: I26d5f7c9e070a89bdd383e1a659f8b7ca150379c
/frameworks/av/include/media/AudioTrack.h
d1b449aad6c087a69f5ec66b7facb2845b73f1cb 14-May-2010 Eric Laurent <elaurent@google.com> Fix issue 2553359: Pandora does not work well with Passion deskdock / Cardock.

The problem is due to a too big difference between the buffer size used at the hardware interface and at the A2DP interface.
When no resampling occurs we don't notice problems but the timing is very tight. As soon as resampling is activated, the AudioTrack underruns.
This is because the AudioTrack buffers are not resized when moving the AudioTrack from hardware to A2DP output.
The AudioTrack buffers are calculated based on a hardware output buffer size of 3072 bytes. Which is much less than the A2DP output buffer size (10240).

The solution consists in creating new tracks with new buffers in AudioFlinger when the A2DP output is opened
instead of just transfering active tracks from hardware output mixer thread to the new A2DP output mixer thread.
To avoid synchronization issues between mixer threads and client processes, this is done by invalidating tracks
by setting a flag in their control block and having AudioTrack release the handle on this track (IAudioTrack)
and create a new IAudioTrack when this flag is detected next time obtainBuffer() or start() is executed.

AudioFlinger modifications:
- invalidate the tracks when setStreamOutput() is called
- make sure that notifications of output opening/closing and change of stream type to output mapping are sent synchronously to client process.
This is necessary so that AudioSystem has the new stream to output mapping when the AudioTrack detects the invalidate flag in the client process.
Previously their were sent when the corresponding thread loop was executed.

AudioTrack modifications:
- move frame count calculation and verification from set() to createTrack() so that is is updated every time a new IAudioTrack is created.
- detect track invalidate flag in obtainBuffer() and start() and create a new IAudioTrack.

AudioTrackShared modifications
- group all flags (out, flowControlFlag, forceReady...) into a single bit filed to save space.

Change-Id: I9ac26b6192230627d35084e1449640caaf7d56ee
/frameworks/av/include/media/AudioTrack.h
34f1d8ecd23169a5f299937e3aaf1bd7937578a0 04-Nov-2009 Eric Laurent <elaurent@google.com> Fix issue 2203561: Sholes: audio playing out of earpiece.

Create a new IAudioTrack interface to AudioFlinger when start() fails due to a broken pipe error.
Do the same if start fails due to the same error after time out in obtainBuffer().
Do not indicate that the AudioTrack is started to AudioPolicyManager if IAudioTrack start fails.
This avoids that an AudioTrack keeps a dead IAudioTrack after a media server crash.

Same modifications for AudioRecord.

Add a flag to ToneGenerator indicating that the callback thread can call Java. Without it, when the media server crashes and restarts, the AudioSystem error callback will crash in JNI if the IAudiotrack is created from AudioTrack callback thread.
/frameworks/av/include/media/AudioTrack.h
c2f1f07084818942352c6bbfb36af9b6b330eb4e 17-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1795088 Improve audio routing code

Initial commit for review.
Integrated comments after patch set 1 review.
Fixed lockup in AudioFlinger::ThreadBase::exit()
Fixed lockup when playing tone with AudioPlocyService startTone()
/frameworks/av/include/media/AudioTrack.h
349dba337e07e129f6ba49a132999f0b73fedbe3 07-Jul-2009 Eric Laurent <elaurent@google.com> am 88e209dc: Fix issue 1743700: AudioTrack: setPlaybackRate can not set the playback rate to twice of the ouputSR

Merge commit '88e209dcf8c2ebddda5c272f46d1bd5478bc639c'

* commit '88e209dcf8c2ebddda5c272f46d1bd5478bc639c':
Fix issue 1743700: AudioTrack: setPlaybackRate can not set the playback rate to twice of the ouputSR
573266210fb2b2e7d86fbd46d0dfe16763611d91 07-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1743700: AudioTrack: setPlaybackRate can not set the playback rate to twice of the ouputSR

Store sample rate on 32 bits instead of 16 bits in audio_track_cblk_t.
Removed sampleRate() methods from AudioTrack and AudioRecord: replaced by getSampleRate().
AudioTrack::setSampleRate() no returns a status.
/frameworks/av/include/media/AudioTrack.h
7562408b2261d38415453378b6188f74fda99d88 20-May-2009 Mathias Agopian <mathias@google.com> move libbinder's header files under includes/binder
/frameworks/av/include/media/AudioTrack.h
1dd70b9f04961a06fcb73a97fca10a53b3245d3c 21-Apr-2009 Eric Laurent <elaurent@google.com> Fix issue 1745312: Various cleanups in media framework

AudioTrack, AudioRecord:
- remove useless mAudioFlinger member of AudioTrack and AudioRecord.
- signal cblk.cv condition in stop() method to speed up stop completion.
- extend wait condition timeout in obtainBuffer() when waitCount is -1 to avoid waking up callback thread unnecessarily

AudioFlinger:
- remove some warnings in AudioFlinger.cpp.
- remove function AudioFlinger::MixerThread::removetrack_l() as its content is never executed.
- remove useless call to setMasterVolume in AudioFlinger::handleForcedSpeakerRoute().
- Offset VOICE_CALL stream volume to reflect actual volume that is never 0 in hardware (this fix has been made in the open source): 0.01 + v * 0.99.

AudioSystem.java:
- correct typo in comment

IAudioflinger, IAudioFlingerClient:
- make AudioFlinger binder interfaces used for callbacks ONEWAY.

AudioHardwareInterface:
- correct routeStrings[] table in AudioHardwareInteface.cpp
/frameworks/av/include/media/AudioTrack.h
2c22aeb65e801f663a754d043062f85e49f77739 25-Mar-2009 Jean-Michel Trivi <> Automated import from //branches/donutburger/...@140663,140663
/frameworks/av/include/media/AudioTrack.h
89fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/include/media/AudioTrack.h
15f767b960b38059a74a42a33e16d8df2aec8bc1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/include/media/AudioTrack.h
7a2146d5807030b2629f347736be5301b61e8811 13-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@131421
/frameworks/av/include/media/AudioTrack.h
5e07b5774c8b376776caa4f5b0a193767697e97e 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/av/include/media/AudioTrack.h
e5198b620a9a208ec59ea8457282404725f8ff6e 20-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127101
/frameworks/av/include/media/AudioTrack.h
7b5eb023f8d87cca6d830ae6c11c6aadbe02aca8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/av/include/media/AudioTrack.h
2729ea9262ca60d93047e984739887cfc89e82eb 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/av/include/media/AudioTrack.h