Merge dup code at thread entry and param change
This CL is mostly just cleanup, but there are a couple of fixes marked
"FIX" below.
Merge the duplicate code that was at the beginning of threadLoop() and
after a parameter change. cacheParameters_l() is now called at entry to
threadLoop() and after any parameter change. It re-calculates all values
that are derived from parameters, and caches them in instance variables.
updateWaitTime_l():
- FIX activeSleepTime depends on mWaitTimeMs, which was initially set
to infinity. updateWaitTime_l() was not called at entry to
threadLoop(), so activeSleepTime was not set correctly before the
first parameter change.
- FIX reversed the order of calls after parameter change
for the same reason so that updateWaitTime_l() is called before
calculating values that are derived from wait time.
- marked it private since now it's only called from DuplicatingThread
Change-Id: If2607d2ed66c6893d910433e48208a93c41fb7e9
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 38fff8c..194b826 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -222,6 +222,8 @@
audio_hw_device_t* findSuitableHwDev_l(uint32_t devices);
void purgeStaleEffects_l();
+ // standby delay for MIXER and DUPLICATING playback threads is read from property
+ // ro.audio.flinger_standbytime_ms or defaults to kDefaultStandbyTimeInNsecs
static nsecs_t mStandbyTimeInNsecs;
// Internal dump utilites.
@@ -840,9 +842,6 @@
virtual void threadLoop_write();
virtual void threadLoop_standby();
- // Non-trivial for DUPLICATING only
- virtual void updateWaitTime_l() { }
-
// Non-trivial for DIRECT only
virtual void applyVolume() { }
@@ -929,6 +928,9 @@
virtual void saveOutputTracks() { }
virtual void clearOutputTracks() { }
+ // Cache various calculated values, at threadLoop() entry and after a parameter change
+ virtual void cacheParameters_l();
+
private:
friend class AudioFlinger;
@@ -964,8 +966,11 @@
// FIXME rename these former local variables of threadLoop to standard "m" names
nsecs_t standbyTime;
size_t mixBufferSize;
+
+ // cached copies of activeSleepTimeUs() and idleSleepTimeUs() made by cacheParameters_l()
uint32_t activeSleepTime;
uint32_t idleSleepTime;
+
uint32_t sleepTime;
// mixer status returned by prepareTracks_l()
@@ -976,8 +981,13 @@
// MIXER only
bool longStandbyExit;
uint32_t sleepTimeShift;
- // DIRECT only
+
+ // same as AudioFlinger::mStandbyTimeInNsecs except for DIRECT which uses a shorter value
nsecs_t standbyDelay;
+
+ // MIXER only
+ nsecs_t maxPeriod;
+
// DUPLICATING only
uint32_t writeFrames;
};
@@ -1003,6 +1013,7 @@
virtual void deleteTrackName_l(int name);
virtual uint32_t idleSleepTimeUs();
virtual uint32_t suspendSleepTimeUs();
+ virtual void cacheParameters_l();
// threadLoop snippets
virtual void threadLoop_mix();
@@ -1028,6 +1039,7 @@
virtual uint32_t activeSleepTimeUs();
virtual uint32_t idleSleepTimeUs();
virtual uint32_t suspendSleepTimeUs();
+ virtual void cacheParameters_l();
// threadLoop snippets
virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
@@ -1075,9 +1087,12 @@
virtual void threadLoop_sleepTime();
virtual void threadLoop_write();
virtual void threadLoop_standby();
+ virtual void cacheParameters_l();
+ private:
// called from threadLoop, addOutputTrack, removeOutputTrack
virtual void updateWaitTime_l();
+ protected:
virtual void saveOutputTracks();
virtual void clearOutputTracks();
private: