summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrackShared.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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