summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Tracks.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Report underruns for fast tracks alsoGlenn Kasten2013-07-311-7/+3
| | | | | | | | | | | | | | | | | | | | | | | 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-2/+0
| | | | | | | 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-8/+8
| | | | Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89
* Rename control block server to mServer and add commentsGlenn Kasten2013-07-301-2/+2
| | | | Change-Id: Ieabd91acee92d0e84e66fbd358df5282b856306e
* Merge "Fix theoretical race using TrackBase::sampleRate()"Glenn Kasten2013-07-301-2/+4
|\
| * Fix theoretical race using TrackBase::sampleRate()Glenn Kasten2013-06-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In two places we assumed that TrackBase::sampleRate() would return the same value when it is called twice in the same function. This is not guaranteed; sampleRate() reads from the control block so the return value could change. To fix this, only call sampleRate() once and cache the return value to get a consistent value. This was only a theoretical race. In MixerThread::prepareTracks_l() it would have no bad effect. In TimedTrack::getNextBuffer() it could cause a real problem, but we don't currently support dynamic sample rate ratios for timed tracks. Change-Id: I8e5c33f0121fc058d1e70c2ab5e9135397d3e0b7
* | Remove CC_LIKELY and CC_UNLIKELY where not neededGlenn Kasten2013-07-291-1/+0
| | | | | | | | | | | | Only keep them in performance-sensitive code Change-Id: Ib257ddd7bc39ce9896997ffae008c524ac743d01
* | Merge "Declare methods in binder opcode order"Glenn Kasten2013-07-291-4/+4
|\ \
| * | Declare methods in binder opcode orderGlenn Kasten2013-07-291-4/+4
| | | | | | | | | | | | Change-Id: I5f624b7a51ffe1a17a67c056cf984f74e4c56eac
* | | Remove obsolete mBufferEndGlenn Kasten2013-07-291-5/+3
|/ / | | | | | | Change-Id: I507c6109d66000bb30933ca23b912a1316f55e5e
* | Remove obsolete TrackBase::step(), mStepCount, mStepServerFailedGlenn Kasten2013-07-291-10/+6
| | | | | | | | Change-Id: I6347096f066b8b19451c6472db7b0671f0cf7702
* | Merge "Simplify RecordTrack::stop()"Glenn Kasten2013-07-291-6/+1
|\ \
| * | Simplify RecordTrack::stop()Glenn Kasten2013-07-251-6/+1
| | | | | | | | | | | | Change-Id: Ib959c1e9dc9544d12277ce11bea445118b2e0521
* | | Merge "CBLK_OVERRUN, not CBLK_UNDERRUN, is for record threads"Glenn Kasten2013-07-271-3/+0
|\ \ \ | |/ /
| * | CBLK_OVERRUN, not CBLK_UNDERRUN, is for record threadsGlenn Kasten2013-07-251-3/+0
| | | | | | | | | | | | Change-Id: I8948f76ef4717a423c37cd6ea7db4381636af612
* | | Merge "Remove obsolete TrackBase::reset()"Glenn Kasten2013-07-261-7/+0
|\ \ \ | |/ /
| * | Remove obsolete TrackBase::reset()Glenn Kasten2013-07-251-7/+0
| | | | | | | | | | | | Change-Id: I38100b7e28a12d7af8cb40ae3f4d9cb4a0ebe701
* | | AudioFlinger: offload playback, non-blocking writeEric Laurent2013-07-251-106/+155
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* | Make AudioFlinger::instantiate() more resilient when called from separate moduleGlenn Kasten2013-07-191-0/+1
| | | | | | | | | | Bug: 8834855 Change-Id: I4cd842cdfb09d2aaaaab9df9ac3bec6179709bd3
* | Public API changes for audio offload support.Richard Fitzgerald2013-06-271-0/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-186/+88
| | | | | | | | 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
* Consistent whitespaceGlenn Kasten2013-05-301-2/+2
| | | | Change-Id: I118cce68d3b777f9ec9b6bfb70367496422a40f2
* audioflinger: fix duplicating track sampling rateEric Laurent2013-04-251-0/+3
| | | | | | | | Add missing initialization of client proxy sampling rate and volumes in OutputTrack constructor. Bug: 8687522 Change-Id: I813e700315bb97083a63dd32279f1998ac775483
* Miscellaneous cleanupGlenn Kasten2013-03-041-1/+1
| | | | | | | | | | Abbreviation framesReady to fRdy for new systrace. Put inline const on one line. Use local copy of mState in state. Improve logging. Line length 100. Change-Id: I8201c3ce0e53fd464fd33d02544e52c342d40b68
* Merge "media.log cleanup" into jb-mr2-devGlenn Kasten2013-03-021-4/+0
|\
| * media.log cleanupGlenn Kasten2013-03-011-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove almost all of the specific logs, but leave the media.log logging infrastructure in place for the next time we need it. Re-apply a few good changes that were reverted earlier: - check logf format vs. argument list compatibility - distinguish potentially modified and actually modified tracks in FastMixer - fix benign bug where sq->end() was called more than once - fix a build warning Bug: 6490974 Change-Id: I02d3e83646c738acaebb415bd0d6b548638b4ef5
* | Remove tee sink debugging at compile timeGlenn Kasten2013-02-261-14/+20
|/ | | | | Bug: 8223560 Change-Id: Iddbfb06c45d43d9f20bb428215dd4094931e19a7
* Update tee sinkGlenn Kasten2013-02-221-1/+30
| | | | | | | | | | Implement rotation to reduce long-term storage use. Implement optional per-track tee. Dynamically enable at runtime based on property, instead of at compile-time. Dynamic frame count not yet implemented. Bug: 8223560 Change-Id: I3706443c6ec0cb0c6656dc288715a02ad5fea63a
* Revert "Temporary additional logging to investigate bug"Glenn Kasten2013-02-151-10/+4
| | | | | | This reverts commit 32584a7d672864b20ab8b83a3cb23c1858e908b7 Change-Id: I9dc680578b955b1af462eeb7a49d61a0d45eb81b
* Temporary additional logging to investigate bugGlenn Kasten2013-02-151-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug appears related to continuing to use an invalid buffer provider in fast mixer after track destruction, so focus the added logs in that area. Also includes a bug fix: was calling log in an unsafe place near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250. Details: - include caller pid or client pid where appropriate - increase log buffer size - log mFastIndex when AudioMixer sees an invalid bufferProvider. - log both potentially modified and actually modified tracks in FastMixer. - fix benign bug where sq->end() was called more than once. - log StateQueue push() call and return. - increase StateQueue size from 4 to 8 entries - log mixer->enable(), bufferProvider, and currentTrackMask - log buffer provider addresses - increase fast mixer log buffer again - check logf format vs. argument list compatibility - add logging to AudioMixer - add checking of magic field in AudioMixer to detect overwrites - add bool AudioMixer::enabled() - increase log buffer sizes yet again - enable assertion checking without ALOGV - improve a few log messages - check for corruption in more places - log in all the process hooks - add new mixer APIs so we can check for corruption of mixer state - fix a build warning Bug: 6490974 Change-Id: Ib0c4a73dcf606ef9bd898313b3b40ef61ab42f51
* Revert "Temporary additional logging to investigate bug"Glenn Kasten2013-02-141-10/+4
| | | | | | This reverts commit 639482c24c911b125398b31883ba6d55faebe28b Change-Id: I11f2829072ab11e18b0663024f27bf31192f1d39
* Temporary additional logging to investigate bugGlenn Kasten2013-02-141-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | The bug appears related to continuing to use an invalid buffer provider in fast mixer after track destruction, so focus the added logs in that area. Also includes a bug fix: was calling log in an unsafe place near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250. Details: - include caller pid or client pid where appropriate - increase log buffer size - log mFastIndex when AudioMixer sees an invalid bufferProvider. - log both potentially modified and actually modified tracks in FastMixer. - fix benign bug where sq->end() was called more than once. - log StateQueue push() call and return. - increase StateQueue size from 4 to 8 entries - log mixer->enable(), bufferProvider, and currentTrackMask - log buffer provider addresses - increase fast mixer log buffer again - check logf format vs. argument list compatibility - add logging to AudioMixer - add checking of magic field in AudioMixer to detect overwrites - add bool AudioMixer::enabled() Bug: 6490974 Change-Id: I1f3f18aa62d9fbd35bc32285b669f5ba40efe28e
* Revert "Temporary additional logging to investigate bug"Glenn Kasten2013-02-141-10/+4
| | | | | | This reverts commit 0ddd56316262ac74a95e9edb595697c163136d6d Change-Id: I180a928af6f5a38d15a5efe44cd1fe927b5d961c
* Temporary additional logging to investigate bugGlenn Kasten2013-02-131-4/+10
| | | | | | | | | | | | | | | | | | | The bug appears related to continuing to use an invalid buffer provider in fast mixer after track destruction, so focus the added logs in that area. Also includes a bug fix: was calling log in an unsafe place near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250. Details: - include caller pid or client pid where appropriate - increase log buffer size - log mFastIndex when AudioMixer sees an invalid bufferProvider. - log both potentially modified and actually modified tracks in FastMixer. - fix benign bug where sq->end() was called more than once. - log StateQueue push() call and return. Bug: 6490974 Change-Id: Iee7c8f40e20b6000cd8286c0ec6a14fff4a37af1
* Revert "Temporary additional logging to investigate bug"Glenn Kasten2013-02-121-10/+4
| | | | | | This reverts commit 3051df27261e9952c0e642dec548515250e85f6a Change-Id: I8bf5c3e91b65bd20de26f480c367c2854b62373c
* Temporary additional logging to investigate bugGlenn Kasten2013-02-121-4/+10
| | | | | | | | | | | | | | | The bug appears related to continuing to use an invalid buffer provider in fast mixer after track destruction, so focus the added logs in that area. Also includes a bug fix: was calling log in an unsafe place near Threads.cpp AudioFlinger::PlaybackThread::createTrack_l line 1250. Details: - include caller pid or client pid where appropriate - increase log buffer size Bug: 6490974 Change-Id: I4c030f171343fe4b483eae0ddea4427118d8d4b1
* AudioFlinger uses media.log service for loggingGlenn Kasten2013-01-311-0/+4
| | | | Change-Id: Ia0f8204334f6b233f644d897762a18c95d936b4b
* Start isolating control block accesses in a proxyGlenn Kasten2012-12-121-56/+41
| | | | | | | | | | | | | | | | | | | | | 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
* Prepare for track invalidation to be done by proxyGlenn Kasten2012-12-121-1/+10
| | | | | | | Don't rely on control block to determine whether track has been marked invalid. Instead, use a local flag that can't be corrupted by client. Change-Id: I783dafe828f93c1c3d2d0e5a08105ea536436efb
* AudioTrack::mute() is unused so remove itGlenn Kasten2012-12-031-13/+2
| | | | | | | If ever needed again, it could be implemented on client side by forcing a track volume of 0. Change-Id: I88a9b4f675b6dca2948549414f9ec2c192d29269
* AudioFlinger files reorganizationEric Laurent2012-11-191-0/+1789
Audioflinger.cpp and Audioflinger.h files must be split to improve readability and maintainability. This CL splits the files as follows: AudioFlinger.cpp split into: - AudioFlinger.cpp: implementation of IAudioflinger interface and global methods - AFThreads.cpp: implementation of ThreadBase, PlaybackThread, MixerThread, DuplicatingThread, DirectOutputThread and RecordThread. - AFTracks.cpp: implementation of TrackBase, Track, TimedTrack, OutputTrack, RecordTrack, TrackHandle and RecordHandle. - AFEffects.cpp: implementation of EffectModule, EffectChain and EffectHandle. AudioFlinger.h is modified by inline inclusion of header files containing the declaration of complex inner classes: - AFThreads.h: ThreadBase, PlaybackThread, MixerThread, DuplicatingThread, DirectOutputThread and RecordThread - AFEffects.h: EffectModule, EffectChain and EffectHandle AFThreads.h includes the follownig headers inline: - AFTrackBase.h: TrackBase - AFPlaybackTracks: Track, TimedTrack, OutputTrack - AFRecordTracks: RecordTrack Change-Id: I512ebc3a51813ab7a4afccc9a538b18125165c4c