History log of /frameworks/av/media/libmedia/AudioTrack.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
c2813e568aa476e03d159529c0af28c99536db8d 17-Oct-2014 Andy Hung <hunga@google.com> Fix AudioTrack retrograde getPosition when restoring tracks

mReleased represents the number of frames written to the
track, but was cleared on start() causing a mismatch if the
client wrote to the track before starting. Moved the clearing
to entering the STATE_STOPPED or STATE_FLUSHED state.

Bug: 18017947
Bug: 18022276
Change-Id: I3788c98c4c3c4d9cc004378432797b3f3138e22e
/frameworks/av/media/libmedia/AudioTrack.cpp
7985dcb06e0c29d5cc12d0c0e17e03d5d863cf53 08-Oct-2014 Eric Laurent <elaurent@google.com> AudioTrack: fix AudioTrackThread crash upon exit

In case of error during createTrack_l(), there is a possibility
that a newly created AudioTrackThread is resumed by requestExit()
just after entering the Thread class _threadLoop() but before
entering the class threadLoop(). In this case, processAudioBuffer()
is executed once with mCblk == 0 and we assert.

Bug: 17894033.
Change-Id: I93d0d0d4dbf14bcb88dad23e6ad49d2ecd47badd
/frameworks/av/media/libmedia/AudioTrack.cpp
bb6c9a05840d924b502ce0f1868fca4881ada1ed 25-Sep-2014 Eric Laurent <elaurent@google.com> audio: fix stream type for accessibility usage

Make sure that accessibility prompts are heard when
a ringtone is active by forcing stream type
to AUDIO_STREAM_RING when phone state is AUDIO_MODE_RINGTONE.

Bug: 17558149.
Change-Id: Ia3bead8052fca5cbf282c267f7b9b06014fef628
/frameworks/av/media/libmedia/AudioTrack.cpp
dfc34daba6d6cb923683d96689a0cb7c7006eee5 19-Sep-2014 Glenn Kasten <gkasten@google.com> Reduce log spam from getTimestamp errors

Bug: 17576481
Change-Id: I07d99e7c42b7d4f0994b5a6d9c9fe8eb29fbbe40
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
34fb29696b0f3abf61b10f8d053b1f33d501de0a 19-Jun-2014 Mark Salyzyn <salyzyn@google.com> libmedia: 64-bit compile warnings

Change-Id: I600f062fa7148c01851023c1240c39939e648002
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
5bd3f38638acab633d181359cc9ec27b80f84d43 14-Jun-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioPolicyManager: return output for audio attributes

In AudioPolicyManager, support querying an output
or playback strategy for audio attributes,
instead of a stream type,
In AudioTrack creation, use the output returned
for the track's attributes.

Change-Id: I0fef05845ba676404775e2e338c10e6a96237268
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
9c68ac03f16cc32625f6965e869432eae4fded2d 13-Jun-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "AudioSystem: remove unused stream type"
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
/frameworks/av/media/libmedia/AudioTrack.cpp
b7f24b101d43139b4c747129bfbc4ecf5c468b86 11-Jun-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioSystem: remove unused stream type

The audio stream type is not used in the getSampleRate() and
getFrameCount() methods.

Change-Id: I3d065ae272bd039204cd323cdab9b60460034f2d
/frameworks/av/media/libmedia/AudioTrack.cpp
b4db73d022f3de3530bc2b3c9c831ccfdd1a2ead 20-May-2014 Andy Hung <hunga@google.com> Merge "Use new channel count functions for audio masks"
c56f3426099a3cf2d07ccff8886050c7fbce140f 22-Mar-2014 Glenn Kasten <gkasten@google.com> Pass stereo gains as packed minifloat

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

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

Change-Id: I63bce9e82e0a61546d8ff475fb94bcb700d99c96
/frameworks/av/media/libmedia/AudioTrack.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>
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
877a0ac7e8677fa1cbd0e8565ad9d38ba0db5fc0 01-May-2014 Glenn Kasten <gkasten@google.com> Use AUDIO_INTERLEAVE_* constants

Change-Id: I6609fa75c9a57fc4ca3887d626a2f4fb8b6593a1
/frameworks/av/media/libmedia/AudioTrack.cpp
142f519aa1acd5804d111e60d100f170fed28405 26-Mar-2014 Glenn Kasten <gkasten@google.com> Use symbol AUDIO_IO_HANDLE_NONE from <system/audio.h>

Change-Id: Id6b1aa17558eb73e17f22b8eab6cd02e00a96dff
/frameworks/av/media/libmedia/AudioTrack.cpp
ecdca392ed40e89a6ef14b86446e952c35497ac4 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Use symbolic constants from <system/audio.h>"
8c7b9fb41585fccb06573252823b929c82a40999 26-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Remove streamType parameter from AudioSystem::getLatency()"
ebb80e4f9873cc1a5ee3f766323f622bb0c07ae5 26-Mar-2014 Glenn Kasten <gkasten@google.com> Remove dead code

Change-Id: I0878d11451c7bbbf96b59f5fe0cd97ba1f033aa9
/frameworks/av/media/libmedia/AudioTrack.cpp
241618f1b286f9e7e02fe61e96d9194e2e1e8a7a 26-Mar-2014 Glenn Kasten <gkasten@google.com> Remove streamType parameter from AudioSystem::getLatency()

Change-Id: Ie7346e93436ddc215cad7d16be555dcb6c277d54
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
c644345b0b8f5292a049c4cee2bb7a2a6159b884 11-Mar-2014 Jean-Michel Trivi <jmtrivi@google.com> Merge "AudioTrack non-blocking write"
3a90f2849d49bf65f2d6257fd6da30ae46d745fa 10-Mar-2014 Marco Nelissen <marcone@google.com> Fix freeze on pause

isOffloaded() tries to lock mLock again. We should be calling isOffloaded_l()
b/13394633

Change-Id: I155be6fee937f894d8e6c974e593223ab6014ade
/frameworks/av/media/libmedia/AudioTrack.cpp
1c32a00b8750998562a8d76351ba5c6d2ed788c8 07-Mar-2014 Glenn Kasten <gkasten@google.com> Merge "Simplify AudioTrack stream end and fix race"
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/media/libmedia/AudioTrack.cpp
720ad9ddb2ac6b55b0dfbfcd2d8360151d8ac427 04-Feb-2014 Jean-Michel Trivi <jmtrivi@google.com> AudioTrack non-blocking write

Bug 7531968

Change-Id: I6d0e79fa8cab5b6eb36bcc34977f4cf0d7eec8ea
/frameworks/av/media/libmedia/AudioTrack.cpp
33ca5cf8826f5fcd9c011e8d336138b62d982f2a 28-Feb-2014 Glenn Kasten <gkasten@google.com> Merge "Make openRecord_l more like createTrack_l for fast tracks: part 1"
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
c6ba823a397abf865b02f4f48fe18231f94d8e87 27-Feb-2014 Glenn Kasten <gkasten@google.com> Make openRecord_l more like createTrack_l for fast tracks: part 1

Use the transfer mode to distinguish use cases, as the presence of
a callback handler is not sufficient. For example, the track could be
configured for synchronous transfer with write() or read(), and also
have a callback handler for position updates. But that does not mean
the track can operate in fast track mode.

Change-Id: I2a7f1f0ca98e68efe180b524496985109d8ce291
/frameworks/av/media/libmedia/AudioTrack.cpp
c08d20b6a37122ebf116262c9372509ed060d4c1 25-Feb-2014 Glenn Kasten <gkasten@google.com> Simplify error handling after track creation

IAudioFlinger::createTrack and IAudioFlinger::openRecord
both guarantee that (status == OK) == (sp<> != 0).

Change-Id: I91cb4f7e843019efb65cace7ba146f7da7aa5b59
/frameworks/av/media/libmedia/AudioTrack.cpp
5f631515d098c29603cda88f7a7e7580a2d55b57 25-Feb-2014 Glenn Kasten <gkasten@google.com> Unify comments and whitespace between AudioTrack and AudioRecord

Change-Id: I5320a6b2d7f7077cb12d7da4f2ca30a940100bf2
/frameworks/av/media/libmedia/AudioTrack.cpp
e3247bf8dd4f8fa8dfa3a108260241ae4a967569 25-Feb-2014 Glenn Kasten <gkasten@google.com> Update channel fields at same place in AudioTrack and AudioRecord

Change-Id: I4b649feeef47e7968a9fa3a460217017ca9b05fe
/frameworks/av/media/libmedia/AudioTrack.cpp
86f04663032ddaa25110149d709bbf896ad83b02 25-Feb-2014 Glenn Kasten <gkasten@google.com> Add log at entry to set() in AudioTrack and AudioRecord

Change-Id: Ife23b88474c1d62c0cf682c1a310d951f2c0f54a
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
1d6fa7af1288b550faabe4ec2cf98684236723db 11-Feb-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of 566be7c3 to master

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

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

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

Change-Id: I725feaae50ed8eee25ca2c947cf15aee1f395c43
/frameworks/av/media/libmedia/AudioTrack.cpp
43bdc1de363a3c72c7dcf9c9a898bac109dc7cb5 10-Feb-2014 Glenn Kasten <gkasten@google.com> Fix build after merge from AOSP

Change-Id: I1cd3432c02db1600e49ade67e6a89e39e7a8d3ed
/frameworks/av/media/libmedia/AudioTrack.cpp
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
cac3daa6332bf6d1f7d26adc4a9915f3d7992dd9 07-Feb-2014 Glenn Kasten <gkasten@google.com> Use printf format %#x for audio_format_t in logs

Change-Id: I1c611d1037685d52ccc84efe0fccd6413ec938e9
/frameworks/av/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
df576995a5aad3428aeeef765387d650945c161d 28-Jan-2014 Eric Laurent <elaurent@google.com> AudioTrack: fix obtainBuffer timeout calculation

AudioTrack::obtainBuffer() passes a pointer to a timeout
variable that has gone out of scope when calling
ClientProxy::obtainBuffer().

Same fix for AudioRecord.

Bug: 11968591.
Change-Id: I22af8f94fa2f8cc54ab5c25c89167c805e754317
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
f0002d142e6d24c5438600b2c259679de710f8ac 24-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Replace control block frameCount_ by explicit in/out parameter"
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"
0ce5ca5e113d58cbcb7cb48615d6dbbf3fbe7c66 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Cleanup createTrack error handling"
d0b33f63a9364364a827e77da26b112edf3c4d6e 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Remove dead code in AudioTrack::processAudioBuffer"
a1ebc3b03d4dca534374c19e3c4f32ee687942e3 17-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Improve logs in AudioTrack::getMinFrameCount"
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
70c0bfbe5ec88dcc3efa2bd8df26f36cff1cf03a 15-Jan-2014 Glenn Kasten <gkasten@google.com> Improve logs in AudioTrack::getMinFrameCount

Change-Id: I8b478e6abdded26a43f32c131931939e9ae36fd7
/frameworks/av/media/libmedia/AudioTrack.cpp
7103d9671ded507fd3f6938297019a32f71ea5a0 15-Jan-2014 Glenn Kasten <gkasten@google.com> Remove dead code in AudioTrack::processAudioBuffer

Change-Id: I0baefe9dc08bb5ec45d34698fc764caa160789d2
/frameworks/av/media/libmedia/AudioTrack.cpp
ac1954cb9a480a409e8cee4193fc534a6a29fbb6 15-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Document AudioTrack mFrameCount and mReqFrameCount better"
2b2165c75790050810460c8de3f414876bce4c0e 13-Jan-2014 Glenn Kasten <gkasten@google.com> Unify comments between AudioTrack and AudioRecord

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

Change-Id: Id45ba544cc84133ed5e578fb4fd8a11b62211dc1
/frameworks/av/media/libmedia/AudioTrack.cpp
84fba38b60c2ddb02b9a787f56be88fc084b4a16 14-Jan-2014 Glenn Kasten <gkasten@google.com> Merge "Fix race in AudioTrack::getParameters()"
b1bef51fec06e8bceec914d1b48b411d3ff2adff 13-Jan-2014 Glenn Kasten <gkasten@google.com> Improve error logging for getOutputSamplingRate

Change-Id: I3b52402a663b27efe1d7c6a4f684521f33f3ff8f
/frameworks/av/media/libmedia/AudioTrack.cpp
2c6c5294388e251ebc1e00d6c8785190561c27fc 13-Jan-2014 Glenn Kasten <gkasten@google.com> Fix race in AudioTrack::getParameters()

mOutput is protected by mLock.

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

Change-Id: Ia99e23a0b46db3f3e6aa46f9018e63c14f4af369
/frameworks/av/media/libmedia/AudioTrack.cpp
dfeed91152cb54772b1411d7e82833ca4a48efcc 27-Nov-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix position callback after restore

When restoring an AudioTrack, the next position callback point
should not be modified and set ahead of current buffer head.
Otherwise, as frames are dropped, the new position is never reached
and an application relying on position callbacks to reload the buffer
would be stalled.

Bug: 11868603.
Change-Id: I93b2a311642a0c89944b78bcc0482d4ceed98ae4
/frameworks/av/media/libmedia/AudioTrack.cpp
5e49afd05566820517747b9a8071c99ec0918328 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/media/libmedia/AudioTrack.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"
b5fed68bcdd6f44424c9e4d12bfe9a3ff51bd62e 03-Dec-2013 Glenn Kasten <gkasten@google.com> Increase kFastTrackMultiplier from 1 to 2

Change-Id: I158f147295eebcea96e4047d7618069bc48bdd7d
/frameworks/av/media/libmedia/AudioTrack.cpp
b31788687736666e58b852e744a93f772d3f7148 27-Nov-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix position callback after restore

When restoring an AudioTrack, the next position callback point
should not be modified and set ahead of current buffer head.
Otherwise, as frames are dropped, the new position is never reached
and an application relying on position callbacks to reload the buffer
would be stalled.

Bug: 11868603.
Change-Id: I93b2a311642a0c89944b78bcc0482d4ceed98ae4
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
8ba90326d683b035d99e24db669093e4602a7149 30-Oct-2013 Glenn Kasten <gkasten@google.com> Remove default channel mask for AudioTrack

It doesn't make sense to have a default channel mask, since the caller
needs to know what format it will use when supplying data, and there
is currently no API to return the channel mask of an AudioTrack.
audio_is_output_channel() does not allow 0, so it will catch any
stragglers (I'm not aware of any).

Also move channel mask validation earlier.

Change-Id: Ia018ded8711455581a2a935f37432b049422d492
/frameworks/av/media/libmedia/AudioTrack.cpp
9cae217050aa1347d4ac5053c305754879e3f97f 14-Jan-2013 Marco Nelissen <marcone@google.com> Assign blame for playback wakelocks.

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

Cherrypicked from master.

b/9464621

Change-Id: I7329f88a288a95a582a78005a1c3d16a5a611e31
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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
f8f15b05fe051009945c9042a1a9260280e0feb2 17-Oct-2013 Glenn Kasten <gkasten@google.com> Merge "Fix race condition in AudioTrack::pause followed by start" into klp-dev
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/media/libmedia/AudioTrack.cpp
771f1b6d196b7924707fc44177ac3a88fc31fa9e 17-Oct-2013 Eric Laurent <elaurent@google.com> am 7f8c3973: am 120a8847: Merge "AudioTrack: fix head position after restore" into klp-dev

* commit '7f8c397378a7ee5abd395413be71388ad36d3ed2':
AudioTrack: fix head position after restore
cc21e4f1e41dfa17e7e2bef995fcd22c45f6bcd0 17-Oct-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix head position after restore

The head position transfered to the new track
by restoreTrack_l() must take into account the frames that
are dropped from the old track to avoid a non recoverable
offset in the playback head position returned to applications.

Bug: 11230062.
Change-Id: I51143a08b95e8f264ed709ae2054360315f2b8b1
/frameworks/av/media/libmedia/AudioTrack.cpp
7a72e2aca9a6c46a08bc605166f90915aaeb81cb 07-Oct-2013 Glenn Kasten <gkasten@google.com> Merge "Fix AudioTrack pause followed by stop"
59fe010bcc072597852454a2ec53d7b0a2002a3b 28-Sep-2013 Eric Laurent <elaurent@google.com> fix volume and effect enable delay on offloaded tracks

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

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

Bug: 10796540.

Change-Id: Id2747ae88783575d1d7ffd6fc86fbd054ab2c739
/frameworks/av/media/libmedia/AudioTrack.cpp
96f04886d1c1bfbc422e2be033ea66be83e42441 20-Sep-2013 Glenn Kasten <gkasten@google.com> Simplify AudioTrack stream end and fix race

Bug: 10994052
Change-Id: Ib2e38e7a600bcffef8cbc68c1722e40fbbc7ea67
/frameworks/av/media/libmedia/AudioTrack.cpp
397edb3377e5775f4df60afb8bf6d4711e5adc0e 31-Aug-2013 Glenn Kasten <gkasten@google.com> Fix AudioTrack pause followed by stop

Now the stop is not a nop.

Bug: 10993355
Change-Id: Idfbfd6d14897574578b80648a16e0fc73765cb6c
/frameworks/av/media/libmedia/AudioTrack.cpp
9d2c78c4798ffd8c276c1bf0eaa0b34bc255a2da 23-Sep-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix music resume

Fix regression introduced by commit 5a6cd22 in AudioTrack resume:
the callback thread was not signaled if paused internaly.

Bug: 10895013.
Change-Id: Ic356b115132d6fccbcee2d9bb855e92671dc20c5
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
ce8828a016b082f730152af2204b8ea3610dc1ec 17-Sep-2013 Glenn Kasten <gkasten@google.com> Fix underruns when fast track denied due to SRC

OpenSL ES requests a fast track. If sample rate conversion is needed,
the request is denied by server, and a larger client buffer is used
to handle the higher latency of a normal track. However the client
notification period was calculated based on buffer being divided into
2 sub-buffers. That resulted in the notification period being too long.
The server pulls chunks that are smaller than half the total buffer.
So now the client uses 3 sub-buffers when there is SRC.

Also removed the 'defer wake' optimization because it was incorrect.
This optimization attempted to reduce the number of wakeups of client,
when server releaseBuffer knows that another releaseBuffer will be
following. But there is no way for the first releaseBuffer to predict
how soon the second releaseBuffer will occur. In some cases it was
a long time, and the client underran. So now the client is woken up
immediately if the total number of available frames to client is >=
the minimum number the client wants to see (the notification period).

Also fix bug where minimum frame count was not being used in the
calculation of notification period.

Bug: 10342804
Change-Id: I3c246f4e7bc3684a344f2cf08268dc082e338e2a
/frameworks/av/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
56b592240073b1ab116c6e23a9c4c34ef5ad80d8 30-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "Add IAudioTrack::getTimestamp()" into klp-dev
865f6f248bf10189272020ebfdbf4827433caf0f 30-Aug-2013 Glenn Kasten <gkasten@google.com> Merge "New AudioTrack C++ API for audio timestamps" into klp-dev
42a6f422c09ca6a960673e0e805ddf71a9b51bef 29-Aug-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix write retries for compressed audio

When the amount of frames that can be written to the buffer
is less than requested, AudioTrack::processAudioBuffer() estimates
the time needed to free the missing amount of frames and asks the
callback thread to sleep.
This behavior is not possible for compressed audio and should not
be enabled for offloaded tracks.

Change-Id: I5b657283cfba06254c9ac0ea9b447467cce7eb61
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
ec9a032c2e104ab1e3b5bf73e69dab1408ced0ad 28-Aug-2013 Eric Laurent <elaurent@google.com> AudioTrack: fix unwanted underrun when restarting

When restarting an AudioTrack from stopped state, it is necessary
to force refresh of mRemainingFrames by processAudioBuffer() as
the last write before stop() could be partial. No doing so will lead
into unnecessary sleep before filling the non contiguous part
of the buffer returned by obtainBuffer() when processAudioBuffer()
is executed for the first time after start().

Change-Id: Id703f8dc092a6f07c905eee194054b4a978f979d
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
96f60d8f04432a1ed503b3e24d5736d28c63c9a2 12-Jul-2013 Glenn Kasten <gkasten@google.com> Rename control block flags to mFlags

Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
cff1b2359b8a302f19539c0bc5d25c98a52733fd 17-Jul-2013 Glenn Kasten <gkasten@google.com> Merge "Add comments"
fb1fdc9d6603aa228362e7349451f6455c9849c2 11-Jul-2013 Glenn Kasten <gkasten@google.com> Add comments

Change-Id: Ifbf3a46a4183c8abc0feee1c588953ab10303cc1
/frameworks/av/media/libmedia/AudioTrack.cpp
b0dfd4613225a3b2a17bdf8d85e89a4b04d65ef3 11-Jul-2013 Glenn Kasten <gkasten@google.com> Fix type error in AudioTrack::processAudioBuffer

It returned a bool instead of nsecs_t

Change-Id: If0c096dac411afc0a4142ec1e59c1fdd36d4867c
/frameworks/av/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.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>
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
bb6f0a0bb413817d707cfb4c4a30847fda520787 04-Jun-2013 Glenn Kasten <gkasten@google.com> Fix underruns when sample rate != native sample rate

This forces a minimum of 3 application buffers when the sample rates
don't match, using the normal mixer and low latency HAL.

There is still an issue that the latency() varies depending on whether
screen was off or on at the time of creating the AudioTrack.

With screen on:
I/AudioTrack( 2028): afFrameCount=960, minBufCount=2, afSampleRate=48000, afLatency=50
I/AudioTrack( 2028): minFrameCount: 2646, afFrameCount=960, minBufCount=3, sampleRate=44100, afSampleRate=48000, afLatency=50

With screen off:
I/AudioTrack( 2817): afFrameCount=960, minBufCount=4, afSampleRate=48000, afLatency=84
I/AudioTrack( 2817): minFrameCount: 3528, afFrameCount=960, minBufCount=4, sampleRate=44100, afSampleRate=48000, afLatency=84

Change-Id: Ib45515edff2afcd672dda34881b658c800ffc25a
/frameworks/av/media/libmedia/AudioTrack.cpp
7c027248e1a4ccd5b22bc4deafb03e2d87ac8f38 26-Dec-2012 Glenn Kasten <gkasten@google.com> Consistent whitespace

Change-Id: I118cce68d3b777f9ec9b6bfb70367496422a40f2
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
d5681bc9a38fe4cd1d591e6ae62b9c68fb851041 22-Dec-2012 Glenn Kasten <gkasten@google.com> Merge "Start isolating control block accesses in a proxy"
8d6cc842e8d525405c68e57fdf3bc5da0b4d7e87 03-Feb-2012 Glenn Kasten <gkasten@google.com> Remove unnecessary parameter

Just get the parameter on server side

Change-Id: I433a63104dbb257e0d862be2ab61847cb36d1c15
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
a8190fc518b6769257896605f3aee091aeb60b50 04-Dec-2012 Glenn Kasten <gkasten@google.com> Split off the current control block to separate file

Prepare for a new implementation of step() etc.

Change-Id: I268421976ba577aa1fb5d7015de5441c05861190
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
01437b7cdaecf53acb46b50ff8b5d86b9d36eb20 29-Nov-2012 Glenn Kasten <gkasten@google.com> AudioTrack inline short const methods

Change-Id: I142917edb454d510bbe545e94e6eaea30b650fae
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
aa25c0321bd4b9eb46a4d1cb4ac5fa47af30eeb4 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge ""if" statements use curly braces per media style"
67ba2b6b8018ce7556cdd880dbf28d06a92ebb78 17-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Don't use control block frame count after create"
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/media/libmedia/AudioTrack.cpp
d65d73c4ae74d084751b417615a78cbe7a51372a 23-Jun-2012 Glenn Kasten <gkasten@google.com> "if" statements use curly braces per media style

Change-Id: I130e7849fd1da7a0b7fe56c3c53919d26e3843b8
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
3b16c766d1ae2cfd8487e8ffb2b23936fc0a8e17 14-Nov-2012 Glenn Kasten <gkasten@google.com> Use uint32_t for sample rate

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

Change-Id: I85d7d2f6381b251db5695202fec75128883a8662
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
bc0f6b92bba33ca9c2e76f2a520d290f055da6b2 12-Nov-2012 Glenn Kasten <gkasten@google.com> Fix regression for AudioTrack::write() 8-bit PCM

Bug: 7526532
Change-Id: I8ddd1f0e9d035b54401788dcc422591281dcd97a
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
659004c2949620d8adb29e1d950a2dd1c75ba9a9 08-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Add all-channel AudioTrack::setVolume() API"
755e8e1dcf36f282b727ff22d87d3c2fac70d30a 08-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Fix call to restoreTrack_l() without lock held"
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/media/libmedia/AudioTrack.cpp
864585df53eb97c31e77b3ad7c0d89e4f9b42588 07-Nov-2012 Glenn Kasten <gkasten@google.com> Remove CBLK_DIRECTION from control block flags

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

Change-Id: I0265fece3247356b585d4d48fbda6f37aea8a851
/frameworks/av/media/libmedia/AudioTrack.cpp
8fa3ad0e4c77f7868348ad2a4cacc34c34e7c39e 07-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Remove CBLK_FAST from control block flags"
e0b07179a48ee50fda931d2aa1b3c751d167e4d7 07-Nov-2012 Glenn Kasten <gkasten@google.com> Remove CBLK_FAST from control block flags

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

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

Change-Id: Iab75f6e2348d8b6d1f3cec95aeb3fcd5135dfb50
/frameworks/av/media/libmedia/AudioTrack.cpp
d2c38fc4d5dc742d7441444316849510dd2b7363 01-Nov-2012 Glenn Kasten <gkasten@google.com> Cache mCblk in local variable cblk

Use "iMem" for sp<IMemory>

Change-Id: I2f1fbbc517fbd77cfc92f6c3b1f253c26bae93b0
/frameworks/av/media/libmedia/AudioTrack.cpp
8e825a57202ce6cb2ddac67683ee5885334ce75d 06-Nov-2012 Glenn Kasten <gkasten@google.com> Merge "Simplify control block flag names"
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/media/libmedia/AudioTrack.cpp
847d05dc8fa144dcf8f4f435d6a6ac1727f00937 28-Feb-2012 Glenn Kasten <gkasten@google.com> Remove deprecated AudioTrack APIs

Change-Id: I88be6525f3e33df529c0c3cb701d12a484809477
/frameworks/av/media/libmedia/AudioTrack.cpp
9c5fdd83f9b9f49be35107971feb33528d60b945 05-Nov-2012 Glenn Kasten <gkasten@google.com> Simplify control block flag names

Use only one symbol per flag

Change-Id: Ia3582e2134abd60c896d11337face65383e79c7c
/frameworks/av/media/libmedia/AudioTrack.cpp
9a08ebc8de71e260efb86cd1a04559b075b38ebc 02-Nov-2012 Glenn Kasten <gkasten@google.com> Fix spurious wakeup waiting for new IAudioTrack

If there was a spurious wakeup while waiting for another thread to create
a new IAudioTrack, we assumed that the track has been created when it
might not have been.

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

Change-Id: Ib28fd7b9ce951a6933f006e7f8812ba617625530
/frameworks/av/media/libmedia/AudioTrack.cpp
896adcd3ae6a1c7010e526327eff54e16179987b 13-Sep-2012 Eric Laurent <elaurent@google.com> audioflinger: send priority request from a thread

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

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

This also reverts the workaround in commit 73431968

Bug 7126707.

Change-Id: I3347adf71ffbb56ed8436506d4357eab693078a3
/frameworks/av/media/libmedia/AudioTrack.cpp
73431968e3c5cf420b5d63c54cf72d10ff7ee7bc 13-Sep-2012 Jean-Michel Trivi <jmtrivi@google.com> Workaround for track recreation bug

Ignore thread can call Java parameter to work around bug where
AudioTrack instance gets recreated when key clicks are enabled
and WFD gets turned on, with the wrong parameters.

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

Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
28b76b334f92a15a2be3cc9e2f7d229a3275d1ac 04-Jul-2012 Glenn Kasten <gkasten@google.com> Use audio_channel_mask_t for channel mask

Change-Id: I1c1896da48983aa9f1462a4b471f910498816f60
/frameworks/av/media/libmedia/AudioTrack.cpp
04cd0186305e2b59d23c9147787046c6662029cc 25-Jun-2012 Glenn Kasten <gkasten@google.com> getMinFrameCount error handling

Convention is for "get" APIs that directly return status_t and indirectly
return a value via a pointer, to return BAD_VALUE if the pointer is NULL.
Also indirectly return 0 for other errors.

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

Change-Id: I7d8201590cda29c9fa99662a4fdba222091febfe
/frameworks/av/media/libmedia/AudioTrack.cpp
d3a9ff4b725de612bf0354c035ba8f8564dbc6e8 21-Jun-2012 Glenn Kasten <gkasten@google.com> Move declarations of local variables to first use

Change-Id: I48b193a742b32b6746aa938b84dc405124a6a5c3
/frameworks/av/media/libmedia/AudioTrack.cpp
192cbbad773979a6fe3b5a0c223356de4fc3309c 13-Jun-2012 Eric Laurent <elaurent@google.com> Fix audio track pause.

AudioTrack::pause() should signal the control block condition
to release threads waiting for available buffers in obtainBuffer().
Otherwise the behavior relies on the timout on the condition
or the fact that audioflinger will mix a new audio buffer while executing
the pause.

Bug 6653769.

Change-Id: I5f8f73c471fe306070f30b814f32fd4b4dc1d575
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
df839841d2db4cb8e2acb10205b3942622b3e7a2 31-May-2012 Eric Laurent <elaurent@google.com> Do not keep audio wake lock when apps underrun.

Do not automatically restart an AudioTrack after an underrun
if the callback is executed but no data is written by the app.

Bug 6541286.

Change-Id: I11e7ab8dc968d7ff087058fec68f44490d3a7731
/frameworks/av/media/libmedia/AudioTrack.cpp
2986460984580833161bdaabc7f17da1005a8961 09-May-2012 Eric Laurent <elaurent@google.com> Fix issues with synchronous record start.

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

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

Bug 6449468.

Change-Id: Ib36e11111fb88f73caa31dcb0622792737d57a4b
/frameworks/av/media/libmedia/AudioTrack.cpp
093000f7d11839b920e8dfaa42ed1d09f48e24b8 03-May-2012 Glenn Kasten <gkasten@google.com> Don't allow AudioTrack frameCount to decrease

This is a workaround for bug that client can cache return value of
frameCount(), and is not notified when this value changes due to automatic
re-recreation of the underlying IAudioTrack.

A better long-term fix would be to notify clients when these kinds of
parameters change, and to fix assumptions in client code that they are
constant (e.g. in SoundPool and maybe obtainBuffer).

Also, once a fast track request is denied, don't request it again.

Bug: 6431187
Change-Id: I55b4ff30bbd9ed3a402e39452a38de52cdea53a9
/frameworks/av/media/libmedia/AudioTrack.cpp
f4022f90db5acb680870db8c1150b673cdd211d9 02-May-2012 Glenn Kasten <gkasten@google.com> Fix race in AudioTrack destruction

Bug: 6427369
Change-Id: Id3b4487406235b881f6f0b4b95c5a02a9b797e75
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
ca8b28013c0558a4a3323a1a0f58520277200086 23-Apr-2012 Glenn Kasten <gkasten@google.com> Fix regression in AudioTrack::pause()

Bug: 6379646
Change-Id: I12b53bc4118499ddc73a53a981f3f56328140868
/frameworks/av/media/libmedia/AudioTrack.cpp
3acbd053c842e76e1a40fc8a0bf62de87eebf00f 28-Feb-2012 Glenn Kasten <gkasten@google.com> Configure policy of mediaserver threads

Change-Id: Ifd825590ba36996064a458f64453a94b84722cb0
/frameworks/av/media/libmedia/AudioTrack.cpp
1948eb3ea6eee336e8cdab9b0c693f93f5f19993 14-Apr-2012 Eric Laurent <elaurent@google.com> Add support for deep audio buffers

Allow AudioSink to use deep audio buffering when the
source is audio only and its duration is more than
a certain threshold.
This helps improve battery life but implies higher
audio latency.

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

Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
4a4a0959bca78e03e3c3f486ba17829c28314d8c 19-Mar-2012 Glenn Kasten <gkasten@google.com> AudioTrack client fast policy

Change-Id: I42ce691df3f586ac061b62237f35a263a0116f1f
/frameworks/av/media/libmedia/AudioTrack.cpp
a1472d9883e35edd280201c8be3191695007dfd4 30-Mar-2012 Marco Nelissen <marcone@google.com> Make AudioTrack/AudioRecord handle more than 2^32 frames

b/6160363
Change-Id: I471815012c6a113ec2c4dd7676e8fa288a70bc76
/frameworks/av/media/libmedia/AudioTrack.cpp
b83d38feeeb88a8a2a6219e1fca2480b5a14fb0d 26-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "IAudioFlinger::createTrack and openRecord flags"
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/media/libmedia/AudioTrack.cpp
63c1faa8dea7feb90255d31ef2a133d8f2818844 21-Mar-2012 Glenn Kasten <gkasten@google.com> Merge "Update comments"
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/media/libmedia/AudioTrack.cpp
17a736c3e1d062d7fc916329eb32aef8935614af 14-Feb-2012 Glenn Kasten <gkasten@google.com> Update comments

Change-Id: I327663a020670d0a72ff57bd0b682e2ce0528650
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
480b46802bef1371d5caa16ad5454fce04769c57 28-Feb-2012 Glenn Kasten <gkasten@google.com> Shorten thread names

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

Change-Id: I1f99c2730ba0787ed9b59c15914356cddf698e2f
/frameworks/av/media/libmedia/AudioTrack.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>
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
ed15977476a3d53103866e6d527fa3fb65d4166c 14-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Remove dead code AudioTrack::getLoop"
6dbc1359f778575d09d6da722b060a6d72c2e7c5 02-Feb-2012 Glenn Kasten <gkasten@google.com> AudioRecord and AudioTrack client tid

Inform AudioFlinger of the tid of the callback thread.

Change-Id: I670df92dd06749b057238b48ed1094b13aab720b
/frameworks/av/media/libmedia/AudioTrack.cpp
38f5d71e72f3b76c5b519614d27f051d53cd2712 08-Feb-2012 Glenn Kasten <gkasten@google.com> Remove dead code AudioTrack::getLoop

Change-Id: I868329c52f31bc20125f068500d8f892b4ec9796
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
05bfe50e13793404a78c20c850d467d17734d496 20-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Move memcpy_to_i16_from_u8 to audio_utils"
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/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
511754b5839fd9b09fc56b89ae007fbc39084a33 11-Jan-2012 Glenn Kasten <gkasten@google.com> Move memcpy_to_i16_from_u8 to audio_utils

This will make it easier for this kind of code to be optimized
for each target architecture.

Change-Id: I9efd27d6c0175b00b9a784353244805cec63c0b8
/frameworks/av/media/libmedia/AudioTrack.cpp
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"
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
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
4cc55d53d542c4f4ed645738cebb65b9e7eb6c44 12-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Use audio_format_t consistently"
83bc7f3cf78b28a818417f40a4f0c00593993366 04-Jan-2012 Glenn Kasten <gkasten@google.com> libmedia new can't fail on Android

Change-Id: Ie79dd5abb8078b35474bf0f1b3a6ff994a3a3360
/frameworks/av/media/libmedia/AudioTrack.cpp
5c7b3bcc88e2b472f1f7b416d89222714b96a567 09-Jan-2012 Glenn Kasten <gkasten@google.com> Merge "Clean up AudioTrack::mActive and stopped()"
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
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
f6b1678f8f508b447155a81b44e214475ab634a8 15-Dec-2011 Glenn Kasten <gkasten@google.com> Use the standard CC_LIKELY and CC_UNLIKELY macros

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

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

Change-Id: I2494e087a0c0cac0ac998335f5e9c8ad02955873
/frameworks/av/media/libmedia/AudioTrack.cpp
42968939dfce0954d6540011199045ec4ed7de80 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Fix indentation and whitespace"
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
/frameworks/av/media/libmedia/AudioTrack.cpp
1d334101f1289cf4c8967af6e78ac22619175982 15-Dec-2011 Glenn Kasten <gkasten@google.com> Merge "Remove unnecessary this->"
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
/frameworks/av/media/libmedia/AudioTrack.cpp
91eb8bfbe253a6b6fe1aa23fb884a601c28991c4 13-Dec-2011 Glenn Kasten <gkasten@google.com> Remove redundant clear()

Change-Id: Ie5e4e63cbc8fa85ef50451dddf8f149fa864b132
/frameworks/av/media/libmedia/AudioTrack.cpp
9054897ab9ffb307fadae81b774a1fc61cb542e7 13-Dec-2011 Glenn Kasten <gkasten@google.com> Remove unnecessary this->

Change-Id: I72038f5d4568f0633d3e4ab90f4b67e2dd22c332
/frameworks/av/media/libmedia/AudioTrack.cpp
f0c495012bad92230604a9a12a907812ec49ee8f 30-Nov-2011 Glenn Kasten <gkasten@google.com> AudioTrack::setVolume check range

Change-Id: Ie182bf0f741f1f49f68c02a1e7437a2a34d34fc5
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
2267ba18d0d2b2d4bd7f5411821ad89ac2659a88 07-Sep-2011 Eric Laurent <elaurent@google.com> AudioTrack: extend callback thread sleep time

Do not force wake up the AudioTrack thread every 10ms if no timed
events (loop, markers..) have to be processed.
This will help reduce power consumption.

Change-Id: Icb425b13800690008dd07c27ffac84739e3dbba3
/frameworks/av/media/libmedia/AudioTrack.cpp
408b8dc3c0a364c6f6b4991d15da9e6bcc2b8008 06-Sep-2011 Eric Laurent <elaurent@google.com> Issue 5247986: Battery drain due to audio wakelock

The problem occurs when activating or deactivating A2DP connection
while SoudPool has a channel active. This can happen quite frequently now
that the UI sound effects are enabled by default.
If PCM data is remaining in the AudioTrack buffer when it is restroyed and
re-created on the new AudioFlinger output thread, this data is flushed.
As a consequence, no underrun or request for new data callback is sent to
SoundPool and the sound channel remains active for ever as the end of the
sample is never detected.

Change-Id: I13e0c11e4ce3f83bff7f58d347ca814b6a86712b
/frameworks/av/media/libmedia/AudioTrack.cpp
9f6530f53ae9eda43f4e7c1cb30d2379db00aa00 30-Aug-2011 Eric Laurent <elaurent@google.com> 226483: A2DP connected, but music out to speaker

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

Change-Id: Ib2ce1eb5320eaff83287b93779061bf4e7a330df
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
3a34befc6fb04a4945a849e8bda8b84e4bf973fe 02-Aug-2011 Marco Nelissen <marcone@google.com> Keep effects sessions active when the caller dies.

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

Change-Id: I4496e5df080230ca1af149dec95c1309ab8ea888
/frameworks/av/media/libmedia/AudioTrack.cpp
68cbeba4e21aa53f52fb99b74dfa1910af31a3eb 23-Jun-2011 Glenn Kasten <gkasten@google.com> Merge "Fix warnings for uninitialized local variables"
d0965dde97f2815ae0a15fe6b40946f8a741a81e 23-Jun-2011 Glenn Kasten <gkasten@google.com> Fix warnings for uninitialized local variables

Change-Id: Ic9b03b0fd215444e76c7b7bebb385f7831c557e0
/frameworks/av/media/libmedia/AudioTrack.cpp
671a636931295d9c33ffca74551a804479d01241 17-Jun-2011 Eric Laurent <elaurent@google.com> Added audio_bytes_per_sample() helper function

Change-Id: Ibfcd75c4c241a53d5f052c25ada091904991048a
/frameworks/av/media/libmedia/AudioTrack.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>
/frameworks/av/media/libmedia/AudioTrack.cpp
c6854100cea4fcd0f20cb2ac8235c02d1849b3a1 02-Jun-2011 Glenn Kasten <gkasten@google.com> Remove unnecessary level of priority indirection

Change-Id: I942d43973c20a7ace8b0d3f78b4da97e45e996c6
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
64760240f931714858a59c1579f07264d7182ba2 11-May-2011 Dima Zavin <dima@android.com> update for new audio.h header location

Change-Id: Ic4c62c4037800802427eb7d3c7f5eb8b25d18876
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
9b7d950f1f3b0c526712b713dbceb0e22762c015 21-Mar-2011 Eric Laurent <elaurent@google.com> Fix issue 3483718: audio streaming and A2DP.

The problem is that when switching from A2DP to device speakers or headset,
The AudioTrack binder interface to AudioFlinger must be destroyed and restored
to accomodate new buffer size requirements. Current AudioTrack implementation
did not restore properly the PCM buffer write index which caused a mismatch between
the written frame count in the mediaplayer renderer and the AudioTrack. The renderer
could then believe the AudioTrack buffer was full and stop writing data preventing the
AudioTrack to reach a bufffer full condition and resume playback.

The rendered was also modified to refresh the AudioTrack frame count (buffer size)
inside the write loop in NuPlayer::Renderer::onDrainAudioQueue() as this count can change
from one write to the next.

Also modified AudioTrack::obtainBuffer() to check for track invalidated status before
querying for available space in the buffer. This avoids writing to the old track's
buffer until full before detecting the invalidated condition and create a new track.

Change-Id: I16a857e464e466880847f52f640820aa271539ad
/frameworks/av/media/libmedia/AudioTrack.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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
a514bdb58b5de4986679f72b7204b4764f7a2778 21-Jun-2010 Eric Laurent <elaurent@google.com> Added support for audio sessions in MediaPlayer and AudioTrack.

Audio sessions are used to associate audio effects to particular instances (or groups) of MediaPlayers or AudioTracks.

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

Change-Id: If15162583d1d16d89f59be0793106afe77417f35
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
54b1a0550411c2fd2084d82d28934d505c37349a 20-Mar-2010 Mathias Agopian <mathias@google.com> libutils Condition are now PRIVATE by default

Condition must be initialized with SHARED for the old behavior, where
they can be used accross processes.

Updated the two places android that require SHARED conditions.

PRIVATE conditions (and mutexes) use more efficient syscalls.

Change-Id: I9a281a4b88206e92ac559c66554e886b9c62db3a
/frameworks/av/media/libmedia/AudioTrack.cpp
867d2f6ce668968e463eb86b856d21525f12fd67 26-Jan-2010 Mathias Agopian <mathias@google.com> Simplify the MemoryDealer implementation

At some point the implementation became complicated because of
SurfaceFlinger's special needs, since we are now relying on gralloc
we can go back to much simpler MemoryDealer.

Removed HeapInterface and AllocatorInterface, since those don't need
to be paramterized anymore. Merged SimpleMemory and Allocation.
Made SimplisticAllocator non virtual.

Removed MemoryDealer flags (READ_ONLY, PAGE_ALIGNED)

Removed a lot of unneeded code.
/frameworks/av/media/libmedia/AudioTrack.cpp
6100d2d60517ff33ed8eb35d0b7ea63cde0831c9 19-Nov-2009 Eric Laurent <elaurent@google.com> Issue 2265163: Audio still reported routed through earpiece on sholes

This is a second attempt to fix the audio routed to earpiece syndrom.
The root cause identified this time is the crash of an application having an active AudioTrack playing on the VOICE_CALL stream type.
When this happens, the AudioTrack destructor is not called and the audio policy manager is not notified of the track stop.
Results a situation where the VOICE_CALL stream is considered as always in use by audio policy manager which makes that audio is routed to earpiece.

The fix consists in moving the track start/stop/close notification to audio policiy manager from AudioTrack to AudioFlinger Track objet.
The net result is that in the case of a client application crash, the AudioFlinger TrackHandle object (which implements the remote side of the IAudioTrack binder interface) destructor is called which in turn destroys the Track object and we can notify the audio policy manager of the track stop and removal.

The same modification is made for AudioRecord although no bug related to record has been reported yet.
Also fixed a potential problem if record stop is called while the record thread is exiting.
/frameworks/av/media/libmedia/AudioTrack.cpp
2b584244930c9de0e3bc46898a801e9ccb731900 10-Nov-2009 Eric Laurent <elaurent@google.com> Improvements for issue 2197683: English IME key-press latency is noticeably higher on passion than sholes

This change goes with a kernel driver change that reduces the audio buffer size from 4800 bytes (~27ms) to 3072 bytes (~17ms).
- The AudioFlinger modifcations in change 0bca68cfff161abbc992fec82dc7c88079dd1a36 have been removed: the short sleep period was counter productive when the AudioTrack is using the call back thread as it causes to many preemptions.
- AudioFlinger mixer thread now detects long standby exit time and in this case anticipates start by writing 0s as soon as a track is enabled even if not ready for mixing.
- AudioTrack::start() is modified to start call back thread before starting the IAudioTrack so that thread startup time is masked by IAudioTrack start and mixer thread wakeup time.
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
3302526f6276911b2dc40c731ea7fa0e7972d908 04-Aug-2009 Eric Laurent <elaurent@google.com> Fix problem in AudioTrack with 8 bit PCM and direct output.

Do not perform 8 to 16 bit conversion in AudioTrack write() and processAudioBuffer() if direct output flag is set.
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
b07c28b90b2d2793be2b8878d813b607f3eebbb7 14-Jul-2009 Mathias Agopian <mathias@google.com> add a ctor to Mutex to specify the type, which can be shared. This is used by sf and af an soon will allow some optimization in the kernel for non shared mutexes
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
7562408b2261d38415453378b6188f74fda99d88 20-May-2009 Mathias Agopian <mathias@google.com> move libbinder's header files under includes/binder
/frameworks/av/media/libmedia/AudioTrack.cpp
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/media/libmedia/AudioTrack.cpp
2c22aeb65e801f663a754d043062f85e49f77739 25-Mar-2009 Jean-Michel Trivi <> Automated import from //branches/donutburger/...@140663,140663
/frameworks/av/media/libmedia/AudioTrack.cpp
1179bc9b0e3d17c984e8f4ad38561c049dd102fa 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake_rel/...@140373
/frameworks/av/media/libmedia/AudioTrack.cpp
8555d0867c3e8fe6cc5c7ad40af557fe6b92fa72 05-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@136594
/frameworks/av/media/libmedia/AudioTrack.cpp
89fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/media/libmedia/AudioTrack.cpp
15f767b960b38059a74a42a33e16d8df2aec8bc1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/media/libmedia/AudioTrack.cpp
ad04d9201452001dbaac4349f084cc9316190b89 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
/frameworks/av/media/libmedia/AudioTrack.cpp
99ffda877980468a9ae31e013cd10fb3645df1b0 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
/frameworks/av/media/libmedia/AudioTrack.cpp
25658fd43d150a45fb37734a9f9f27f48bb5c133 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
/frameworks/av/media/libmedia/AudioTrack.cpp
7a2146d5807030b2629f347736be5301b61e8811 13-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@131421
/frameworks/av/media/libmedia/AudioTrack.cpp
5e07b5774c8b376776caa4f5b0a193767697e97e 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/av/media/libmedia/AudioTrack.cpp
e5198b620a9a208ec59ea8457282404725f8ff6e 20-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127101
/frameworks/av/media/libmedia/AudioTrack.cpp
cce8bd12da6d8419a8770e4552a51ec297c250c2 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/frameworks/av/media/libmedia/AudioTrack.cpp
7b5eb023f8d87cca6d830ae6c11c6aadbe02aca8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/av/media/libmedia/AudioTrack.cpp
2729ea9262ca60d93047e984739887cfc89e82eb 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/av/media/libmedia/AudioTrack.cpp