summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastMixer.h
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-04-25 17:52:27 -0700
committerGlenn Kasten <gkasten@google.com>2012-04-30 13:00:31 -0700
commit288ed2103d96f3aabd7e6bea3c080ab6db164049 (patch)
treedec8e7b3a993e86baa8916ba70dcd6b3c053d062 /services/audioflinger/FastMixer.h
parent0c0abd4ad26971b5fba94734137fe0bb1a590ab6 (diff)
downloadframeworks_av-288ed2103d96f3aabd7e6bea3c080ab6db164049.zip
frameworks_av-288ed2103d96f3aabd7e6bea3c080ab6db164049.tar.gz
frameworks_av-288ed2103d96f3aabd7e6bea3c080ab6db164049.tar.bz2
Fix race condition for non-started fast tracks
This required re-implementing how fast tracks are considered active. Now, they use the same logic as normal tracks, except underrun is ignored. Other changes: - add framesReady() to AudioBufferProvider interface - rebased - add track underrun counter state to fast mixer dump state - move dumpsys header to Track::appendDumpHeader() so it closer to where tracks are dumped - display track state in dumpsys as a character code - measure and display warmup time and cycles in dumpsys - copy in the presentation complete code - add ExtendedAudioBufferProvider for framesReady() which returns size_t - simplify underrun tracking - deferred reset track after stop() - add comments Change-Id: I7db8821bc565230ec76da1f9380fe3fb09735e5b
Diffstat (limited to 'services/audioflinger/FastMixer.h')
-rw-r--r--services/audioflinger/FastMixer.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/services/audioflinger/FastMixer.h b/services/audioflinger/FastMixer.h
index 8a8fcb8..a6dd310 100644
--- a/services/audioflinger/FastMixer.h
+++ b/services/audioflinger/FastMixer.h
@@ -42,8 +42,23 @@ private:
}; // class FastMixer
+// Represents the dump state of a fast track
+struct FastTrackDump {
+ FastTrackDump() : mUnderruns(0) { }
+ /*virtual*/ ~FastTrackDump() { }
+ uint32_t mUnderruns; // Underrun status, represented as follows:
+ // bit 0 == 0 means not currently in underrun
+ // bit 0 == 1 means currently in underrun
+ // bits 1 to 31 == total number of underruns
+ // Not reset to zero for new tracks or if track generation changes.
+ // This representation is used to keep the information atomic.
+};
+
// The FastMixerDumpState keeps a cache of FastMixer statistics that can be logged by dumpsys.
-// Since used non-atomically, only POD types are permitted, and the contents can't be trusted.
+// Each individual native word-sized field is accessed atomically. But the
+// overall structure is non-atomic, that is there may be an inconsistency between fields.
+// No barriers or locks are used for either writing or reading.
+// Only POD types are permitted, and the contents shouldn't be trusted (i.e. do range checks).
// It has a different lifetime than the FastMixer, and so it can't be a member of FastMixer.
struct FastMixerDumpState {
FastMixerDumpState();
@@ -60,6 +75,9 @@ struct FastMixerDumpState {
uint32_t mOverruns; // total number of overruns
uint32_t mSampleRate;
size_t mFrameCount;
+ struct timespec mMeasuredWarmupTs; // measured warmup time
+ uint32_t mWarmupCycles; // number of loop cycles required to warmup
+ FastTrackDump mTracks[FastMixerState::kMaxFastTracks];
#ifdef FAST_MIXER_STATISTICS
// cycle times in seconds
float mMean;