summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | Merge "Document AudioTrack mFrameCount and mReqFrameCount better"Glenn Kasten2014-01-151-1/+1
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | Document AudioTrack mFrameCount and mReqFrameCount betterGlenn Kasten2014-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and remove unnecessary initialization of mFrameCount in set(). Change-Id: I9effeb0a6dd035ca02fe77f6992c55d9515b4df6
* | | | | Document locking rules for mFlags, and fix discrepanciesGlenn Kasten2014-01-141-9/+16
| | | | | | | | | | | | | | | | | | | | Change-Id: Id45ba544cc84133ed5e578fb4fd8a11b62211dc1
* | | | | Merge "Fix race in AudioTrack::getParameters()"Glenn Kasten2014-01-141-2/+3
|\ \ \ \ \
| * | | | | Fix race in AudioTrack::getParameters()Glenn Kasten2014-01-131-2/+3
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | mOutput is protected by mLock. Change-Id: Id02e627062855ca60f28bd8961b1d5f44939c727
* | | | | Improve error logging for getOutputSamplingRateGlenn Kasten2014-01-131-5/+7
|/ / / / | | | | | | | | | | | | Change-Id: I3b52402a663b27efe1d7c6a4f684521f33f3ff8f
* | | | Cleanup AudioTrack::getMinFrameCount error handlingGlenn Kasten2014-01-081-9/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Fix some (but not all) unused parameter warningsGlenn Kasten2013-12-191-4/+4
|/ / / | | | | | | | | | Change-Id: Ia99e23a0b46db3f3e6aa46f9018e63c14f4af369
* | | am 5c474238: am 5893736d: am a67c7653: Merge "Increase kFastTrackMultiplier ↵Glenn Kasten2013-12-171-4/+7
|\ \ \ | |/ / | | | | | | | | | | | | | | | from 1 to 2" * commit '5c474238bc579224ec8f7267d05651b0aa934100': Increase kFastTrackMultiplier from 1 to 2
| * | Merge "Increase kFastTrackMultiplier from 1 to 2"Glenn Kasten2013-12-171-4/+7
| |\ \
| | * | Increase kFastTrackMultiplier from 1 to 2Glenn Kasten2013-12-041-4/+7
| | | | | | | | | | | | | | | | Change-Id: I158f147295eebcea96e4047d7618069bc48bdd7d
| * | | Assign blame for playback wakelocks.Marco Nelissen2013-10-251-5/+15
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | AudioTrack: fix position callback after restoreEric Laurent2013-11-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | update offloaded audio track sampling rateEric Laurent2013-11-221-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Remove default channel mask for AudioTrackGlenn Kasten2013-11-081-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Assign blame for playback wakelocks.Marco Nelissen2013-10-251-5/+15
| | | | | | | | | | | | | | | | | | | | | 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
* | | am b2059ff3: am f8f15b05: Merge "Fix race condition in AudioTrack::pause ↵Glenn Kasten2013-10-161-7/+8
|\ \ \ | |/ / | | | | | | | | | | | | | | | followed by start" into klp-dev * commit 'b2059ff384eee8ffb70a7ec8fc5570405201c734': Fix race condition in AudioTrack::pause followed by start
| * | Merge "Fix race condition in AudioTrack::pause followed by start" into klp-devGlenn Kasten2013-10-171-7/+8
| |\ \
| | * | Fix race condition in AudioTrack::pause followed by startGlenn Kasten2013-10-161-7/+8
| | | | | | | | | | | | | | | | | | | | Bug: 11148722 Change-Id: Iec88f00c8510363d4418e4b8d5b34feb06ecf04d
* | | | am 7f8c3973: am 120a8847: Merge "AudioTrack: fix head position after ↵Eric Laurent2013-10-161-1/+3
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | | | | | restore" into klp-dev * commit '7f8c397378a7ee5abd395413be71388ad36d3ed2': AudioTrack: fix head position after restore
| * | | AudioTrack: fix head position after restoreEric Laurent2013-10-161-1/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Fix AudioTrack pause followed by stop"Glenn Kasten2013-10-071-2/+1
|\ \ \ | |/ / |/| |
| * | Fix AudioTrack pause followed by stopGlenn Kasten2013-09-291-2/+1
| |/ | | | | | | | | | | | | Now the stop is not a nop. Bug: 10993355 Change-Id: Idfbfd6d14897574578b80648a16e0fc73765cb6c
* | fix volume and effect enable delay on offloaded tracksEric Laurent2013-09-301-0/+3
|/ | | | | | | | | | | | | 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
* AudioTrack: fix music resumeEric Laurent2013-09-231-2/+3
| | | | | | | | Fix regression introduced by commit 5a6cd22 in AudioTrack resume: the callback thread was not signaled if paused internaly. Bug: 10895013. Change-Id: Ic356b115132d6fccbcee2d9bb855e92671dc20c5
* Fix slow AudioTrack and AudioRecord destructionGlenn Kasten2013-09-201-24/+29
| | | | | | | | | | | | | | | | | | | | 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
* Fix underruns when fast track denied due to SRCGlenn Kasten2013-09-171-32/+35
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix miscellanous AudioTrack::getTimestamp() bugsGlenn Kasten2013-09-031-1/+12
| | | | | | | | | | | | | | 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
* Merge "Add IAudioTrack::getTimestamp()" into klp-devGlenn Kasten2013-08-301-10/+7
|\
| * Add IAudioTrack::getTimestamp()Glenn Kasten2013-08-291-10/+7
| | | | | | | | | | | | | | | | | | | | 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
* | Merge "New AudioTrack C++ API for audio timestamps" into klp-devGlenn Kasten2013-08-291-0/+5
|\ \ | |/
| * New AudioTrack C++ API for audio timestampsGlenn Kasten2013-08-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | AudioTrack: fix write retries for compressed audioEric Laurent2013-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* | AudioTrack: fix unwanted underrun when restartingEric Laurent2013-08-281-0/+3
|/ | | | | | | | | | | 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
* Move control block mName to createTrack() outputGlenn Kasten2013-07-301-2/+3
| | | | | | | 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
* libmedia: offloaded playback supportRichard Fitzgerald2013-07-251-38/+187
| | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* Merge "Add comments"Glenn Kasten2013-07-171-0/+7
|\
| * Add commentsGlenn Kasten2013-07-101-0/+7
| | | | | | | | Change-Id: Ifbf3a46a4183c8abc0feee1c588953ab10303cc1
* | Fix type error in AudioTrack::processAudioBufferGlenn Kasten2013-07-101-1/+2
|/ | | | | | It returned a bool instead of nsecs_t Change-Id: If0c096dac411afc0a4142ec1e59c1fdd36d4867c
* Include what is neededGlenn Kasten2013-07-021-0/+1
| | | | | | | Remove old includes. Header files only include other header files that they directly need themselves. Change-Id: Ic471386808d9f42ea19ccbd59cb50a5f83a89dd0
* Public API changes for audio offload support.Richard Fitzgerald2013-06-271-6/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* New control block for AudioTrack and AudioRecordGlenn Kasten2013-06-121-571/+648
| | | | | | | | 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
* Fix underruns when sample rate != native sample rateGlenn Kasten2013-06-041-2/+4
| | | | | | | | | | | | | | | | | | 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
* Consistent whitespaceGlenn Kasten2013-05-301-1/+3
| | | | Change-Id: I118cce68d3b777f9ec9b6bfb70367496422a40f2
* am 1641f328: am 4170f515: Merge "Remove timing jitter during startup of ↵Eric Laurent2013-05-031-0/+21
|\ | | | | | | | | | | | | audio" into jb-mr2-dev * commit '1641f328d4de3b2b61481607dc482ccaefe808a9': Remove timing jitter during startup of audio
| * Remove timing jitter during startup of audioGlenn Kasten2013-04-231-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Propose new interpretation for setPosition and setLoopGlenn Kasten2013-01-071-0/+45
|/ | | | | | | Add new API getBufferPosition to return position relative to start of fixed buffer. Change-Id: I7aca8e392d45b988545f07b36b5032691057b03e
* Merge "Start isolating control block accesses in a proxy"Glenn Kasten2012-12-211-38/+71
|\
| * Start isolating control block accesses in a proxyGlenn Kasten2012-12-121-38/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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