summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrackShared.cpp
Commit message (Collapse)AuthorAgeFilesLines
* libmedia: Preserve futex return status in client obtainBufferLeena Winterrowd2015-12-231-2/+3
| | | | | | | | | | | | clock_gettime() can change errno if something goes wrong (most commonly setting EBADF). This failure should not cause a failure in ClientProxy::obtainBuffer() if the futex returned successfully or with a known status. Preserve errno before calling clock_gettime to prevent propagation of an invalid, unexpected error. Propagated from Ib69201031a81395ece47dd8ad7c4dcddd2b00153 Change-Id: I48320fc287b6a0ef2a1b9e71f9d0e979bd6343a5
* Merge tag 'android-6.0.1_r3' of ↵Steve Kondik2015-12-071-2/+4
|\ | | | | | | | | | | | | | | https://android.googlesource.com/platform/frameworks/av into cm-13.0 Android 6.0.1 release 3 Change-Id: I2f2a1fe1b58c828e8341556996211562d6e195ab
| * For static obtainBuffer(), do not set mUnreleased if acknowledging flush.Andy Hung2015-10-131-2/+4
| | | | | | | | | | | | | | static audio tracks use obtainBuffer() to update position in start(). Bug: 22938515 Change-Id: I8ae32f6cce4d122386d2cf8982e158049b04ba9a
* | Fix benign unsigned overflow in AuidoTrackSharedChad Brubaker2015-11-051-2/+2
|/ | | | | | | fsanitize=integer adds unsigned checks to int32_t - uint32_t, force both operands to int32_t to avoid such checks being added. Change-Id: I76fce38f9636f5322ad95fdb81abb690503f4d08
* Fix buildGlenn Kasten2015-07-171-1/+1
| | | | Change-Id: I18b63d68d452c4ee7544ff1614f4e3f57f5a9e73
* Fix AudioTrack flush pointer wrapAndy Hung2015-07-161-1/+13
| | | | | | | | Occurs when read offset / write offset span the power of 2 mask boundary. Bug: 22513776 Change-Id: If863577dac6666e8b2083d78f78fe9b9490fcf76
* Use AudioPlaybackRate to hold TimestretchBufferProvider parametersRicardo Garcia2015-04-221-7/+3
| | | | | | | | Use this struct to handle the parameters for TimestretchBufferProvider all across the system. Add stretch mode and fallback mode to TimestretchBuffer Provider. Change-Id: I19099924a7003c62e48bb6ead56c785cb129fba2
* libmedia: fix all warning, make warnings errors, use clangLajos Molnar2015-04-171-2/+3
| | | | Change-Id: Ic00d2c5d0bbb1605e96666e25c9ccc22bea6d3ff
* Add playback rate to AudioTrackAndy Hung2015-04-091-0/+10
| | | | | Bug: 19196501 Change-Id: I6411e1d3ce652b711a71a6d9df020cb5f60d4714
* Update commentsGlenn Kasten2015-03-131-1/+0
| | | | Change-Id: I37d3c4ce22b74fe8581a886fe5a7f9fef8266dad
* Fix loop and position restoration in static AudioTracksAndy Hung2015-01-061-19/+48
| | | | | | | | Allow restoration of loop and position. Make position and loop synchronously readable. Bug: 17964637 Change-Id: I8cfb5036e665f55fdff5c67d27e1363ce9a8665d
* Fix loop and position setting in static AudioTracksAndy Hung2015-01-051-45/+119
| | | | | | | Allow independent setting of position and loop. Bug: 17964637 Change-Id: I8b3bd97a244b932728b68da7684044f2636984a5
* Line length 100Glenn Kasten2014-12-301-2/+4
| | | | Change-Id: I6c8fe626a3825fa9e139319656d682a57b887c97
* Fix 64 bit compiler warnings in AudioTrackSharedAndy Hung2014-12-221-3/+3
| | | | | | | Comparisons between size_t and int64_t variables show warnings for 64 bit compilation, fix with casting. Change-Id: I3c1b12ea6eca01e49696c724a1cf1cc6b88df7aa
* Prevent ANR when AudioTrack is paused or re-routedzunkyu.lee2014-12-081-0/+2
| | | | | | | | | | | | | | If ClientProxy was interrupted by AudioTrack::pause() just before futex syscall() in obtainBuffer() was called, It will not call releaseBuffer to wake up AudioTrackThread. It puts the AudioTrackThread to sleep and then a deadlock occurs. In this case, CBLK_INTERRUPT flags can't prevent a deadlock, so this patch set mFutex to FUTEX_WAKE during interrupt() to avoid deadlock. A similar problem could occur due to re-route or recovery after mediaserver death. Bug: 18641665 Change-Id: I66fcae43af9a91eb55f6cdb52c644ee6c0999772
* Fix AudioTrack loop mode to play audio from buffer startAndy Hung2014-11-241-2/+8
| | | | | Bug: 18217633 Change-Id: Ica77acf0a32832d9b04eb657ef2f4f5329f8fbda
* Fix missing loop count for static tracks.Andy Hung2014-11-181-22/+38
| | | | | | | | | | | | | | | | | StaticAudioTrackServerProxy::framesReady() previously returned only the contiguous frames, update to return the total available frames. This resolves short-count looping in SoundPool for FastTracks. Also (1) Removes the racy condition of reading two variables and (2) Fixes buffer->mNonContig to return the correct value and (3) Restores behavior that loop count of 1 goes back to loopStart once during playback. Bug: 11830751 Bug: 12070295 Bug: 17456842 Change-Id: I64906e6036bb00a1d7375b03efe6deb69d6478ca
* AudioTrack::flush() will no longer flush later dataGlenn Kasten2014-10-301-5/+22
| | | | | Bug: 17832076 Change-Id: I4915d782acb8077923e419406b0dcea5b6aab961
* libmedia: 64-bit compile warningsMark Salyzyn2014-06-201-6/+6
| | | | Change-Id: I600f062fa7148c01851023c1240c39939e648002
* Use of fast capture by normal captureGlenn Kasten2014-06-021-4/+11
| | | | | | | Will only configure fast capture path if the input buffer size is less than 10 ms and the input sample rate is same as the primary output sample rate. Change-Id: I4a7cdc6069d750845412c626d27e83f72a1ab397
* resolved conflicts for merge of c0bf836f to masterElliott Hughes2014-05-211-31/+31
|\ | | | | | | Change-Id: I5cf238fa56d6fff443b212870cf9dd7f1110e7da
| * Move frameworks/av off private API.Elliott Hughes2014-05-211-31/+31
| | | | | | | | | | Bug: 11156955 Change-Id: Ib3bb9d66a2bf92977c2445b62aa074a2d7a45aea
* | resolved conflicts for merge of b1080917 to masterElliott Hughes2014-05-211-10/+10
|\ \ | |/ | | | | Change-Id: Iabbe3e95e29f28461ff722b550e8a9f35bd2528f
| * Move frameworks/av off __futex_syscall3.Elliott Hughes2014-05-211-10/+10
| | | | | | | | | | Bug: 11156955 Change-Id: I943080bc51b6efa781059b48b5b5ecc4fa287512
| * Replace size_t in shared memory by uint32_tGlenn Kasten2014-02-131-6/+13
| | | | | | | | | | | | | | Eventually we may want to use uint64_t, but will need to confirm atomicity. Bug: 12381724 Change-Id: Ia2c591d262d22b47b6f7dab4b9d9faa14b86d865
* | Pass stereo gains as packed minifloatGlenn Kasten2014-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | 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
* | Cache mCblk in local variable cblkGlenn Kasten2014-05-091-5/+7
| | | | | | | | | | | | This is the style used throughout the rest of AudioTrackShared. Change-Id: I959a6be3064e087bb19eba41173fd130dfcb4a9a
* | Use LOG_ALWAYS_FATAL instead of LOG_FATALGlenn Kasten2014-03-261-3/+3
| | | | | | | | | | | | | | LOG_FATAL is compiled out in most builds, so the assertion checks were not being performed. Change-Id: I774f0985ab9c5ccecd8989a0f1c940386b73fc35
* | Replace size_t in shared memory by uint32_tGlenn Kasten2014-01-281-6/+13
| | | | | | | | | | | | | | Eventually we may want to use uint64_t, but will need to confirm atomicity. Bug: 12381724 Change-Id: Ia2c591d262d22b47b6f7dab4b9d9faa14b86d865
* | Merge "Replace control block frameCount_ by explicit in/out parameter"Glenn Kasten2014-01-241-1/+1
|\ \
| * | Replace control block frameCount_ by explicit in/out parameterGlenn Kasten2013-12-201-1/+1
| |/ | | | | | | | | | | in IAudioFlinger::createTrack and IAudioFlinger::openRecord Change-Id: I09c644c80e92c8e744b1b99055988a2588b2a83d
* | Fix some (but not all) unused parameter warningsGlenn Kasten2013-12-191-2/+2
|/ | | | Change-Id: Ia99e23a0b46db3f3e6aa46f9018e63c14f4af369
* Allow releaseBuffer after flushGlenn Kasten2013-10-181-3/+7
| | | | | | | | | | | After AudioTrack start checks for pending flush, allow releaseBuffer on any previously obtained buffer. For example, this can happen if the resampler has obtained a buffer but not released the whole buffer yet. Note that the resampler will be reading obsolete data. Bug: 11285590 Change-Id: I0614fbb62e43604aac3089cce4b7797c87a306b5
* AudioTrack: fix head position after restoreEric Laurent2013-10-161-0/+21
| | | | | | | | | | 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
* Fix underruns when fast track denied due to SRCGlenn Kasten2013-09-171-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Report underruns for fast tracks alsoGlenn Kasten2013-07-311-0/+19
| | | | | | | | | | | | | | | | | | | | | | | This fixes a regression that was introduced earlier by commit 9f80dd223d83d9bb9077fb6baee056cee4eaf7e5 called "New control block for AudioTrack and AudioRecord". That commit broke underrun reporting for fast tracks. Also remove Track::mUnderrunCount, which counted the number of underrun events, and was only used by dumpsys media.audio_flinger. Now dumpsys media.audio_flinger reports the number of underrun frames, Isolated underrun-related control block accesses via the proxy, so that the server is not directly poking around in the control block. The new proxy APIs are AudioTrackServerProxy::getUnderrunFrames() and AudioTrackServerProxy::tallyUnderrunFrames(). getUnderrunFrames() returns a rolling counter for streaming tracks, or zero for static buffer tracks which never underrun, but do a kind of 'pause' at end of buffer. tallyUnderrunFrames() increments the counter by a specified number of frames. Change-Id: Ib31fd73eb17cbb23888ce3af8ff29f471f5bd5a2
* Move control block mName to createTrack() outputGlenn Kasten2013-07-301-1/+1
| | | | | | | 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
* Rename control block flags to mFlagsGlenn Kasten2013-07-301-9/+9
| | | | Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89
* Rename control block server to mServer and add commentsGlenn Kasten2013-07-301-3/+3
| | | | Change-Id: Ieabd91acee92d0e84e66fbd358df5282b856306e
* libmedia: offloaded playback supportRichard Fitzgerald2013-07-251-7/+126
| | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* AudioFlinger: offload playback, non-blocking writeEric Laurent2013-07-251-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | - Added specialized playback thread class for offload playback, derived from directoutput thread. This thread type handles specific state transitions for offloaded tracks and offloading commands (pause/resume/drain/flush..) to audio HAL. As opposed to other threads, does not go to standby if the track is paused. - Added support for asynchronous write and drain operations at audio HAL. Use a thread to handle async callback events from HAL: this avoids locking playback thread mutex when executing the callback and cause deadlocks when calling audio HAL functions with the playback thread mutex locked. - Better accouting for track activity: call start/stop and release Output methods in audio policy manager when tracks are actually added and removed from the active tracks list. Added a command thread in audio policy service to handle stop/release commands asynchronously and avoid deadlocks with playback thread. - Track terminated status is not a state anymore. This condition is othogonal to state to permitted state transitions while terminated. Change-Id: Id157f4b3277620568d8eace7535d9186602564de
* Merge "AudioTrackShared cleanup"Glenn Kasten2013-07-111-31/+32
|\
| * AudioTrackShared cleanupGlenn Kasten2013-07-021-31/+32
| | | | | | | | | | | | | | | | Maintain unreleased frame count on client side also (was already there on server side). Assertion failure instead of BAD_VALUE status for incorrect usage of APIs. Clean up error handling code. Change-Id: I23ca2f6f8a7c18645309ee5d64fbc844429bcba8
* | Fix AudioTrack::flush()Glenn Kasten2013-07-111-0/+2
|/ | | | | | | | | It was only flushing at a surface level, and even then only the first time the server observed the client's flush request. Now it flushes at a deeper level, but there may be even deeper device-specific flushing. Bug: 9770947 Change-Id: I687cc3410ff9e5e5d4a5dcb9e3b129501e53d247
* Workaround AudioRecord bug for large buffer sizesGlenn Kasten2013-06-241-1/+2
| | | | | Bug: 9556436 Change-Id: I92d1238b623d2cfd648e0a684d0e710fb0bd8b43
* Use mFutex as an event flag rather than semaphoreGlenn Kasten2013-06-241-6/+5
| | | | | | | | An event flag can be more fault-tolerant in case of loss of synchronization, as it cannot overflow. It also allows more bits to be used in the future. See http://en.wikipedia.org/wiki/Event_flag Change-Id: I01ca25d951eb263124da54bb4738f0d94ec4a48b
* New control block for AudioTrack and AudioRecordGlenn Kasten2013-06-121-115/+601
| | | | | | | | 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
* Start isolating control block accesses in a proxyGlenn Kasten2012-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Split off the current control block to separate fileGlenn Kasten2012-12-031-0/+196
Prepare for a new implementation of step() etc. Change-Id: I268421976ba577aa1fb5d7015de5441c05861190