Improvements for issue 2197683: English IME key-press latency is noticeably higher on passion than sholes
This change goes with a kernel driver change that reduces the audio buffer size from 4800 bytes (~27ms) to 3072 bytes (~17ms).
- The AudioFlinger modifcations in change 0bca68cfff161abbc992fec82dc7c88079dd1a36 have been removed: the short sleep period was counter productive when the AudioTrack is using the call back thread as it causes to many preemptions.
- AudioFlinger mixer thread now detects long standby exit time and in this case anticipates start by writing 0s as soon as a track is enabled even if not ready for mixing.
- AudioTrack::start() is modified to start call back thread before starting the IAudioTrack so that thread startup time is masked by IAudioTrack start and mixer thread wakeup time.
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 22d15c9..594d878 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -361,6 +361,12 @@
DUPLICATING
};
+ enum mixer_state {
+ MIXER_IDLE,
+ MIXER_TRACKS_ENABLED,
+ MIXER_TRACKS_READY
+ };
+
// playback track
class Track : public TrackBase {
public:
@@ -530,7 +536,8 @@
virtual int getTrackName_l() = 0;
virtual void deleteTrackName_l(int name) = 0;
- virtual uint32_t getMaxBufferRecoveryInUsecs() = 0;
+ virtual uint32_t activeSleepTimeUs() = 0;
+ virtual uint32_t idleSleepTimeUs() = 0;
private:
@@ -562,7 +569,6 @@
int mNumWrites;
int mNumDelayedWrites;
bool mInWrite;
- int mMinBytesToWrite;
};
class MixerThread : public PlaybackThread {
@@ -582,10 +588,11 @@
virtual status_t dumpInternals(int fd, const Vector<String16>& args);
protected:
- size_t prepareTracks_l(const SortedVector< wp<Track> >& activeTracks, Vector< sp<Track> > *tracksToRemove);
+ uint32_t prepareTracks_l(const SortedVector< wp<Track> >& activeTracks, Vector< sp<Track> > *tracksToRemove);
virtual int getTrackName_l();
virtual void deleteTrackName_l(int name);
- virtual uint32_t getMaxBufferRecoveryInUsecs();
+ virtual uint32_t activeSleepTimeUs();
+ virtual uint32_t idleSleepTimeUs();
AudioMixer* mAudioMixer;
};
@@ -604,7 +611,8 @@
protected:
virtual int getTrackName_l();
virtual void deleteTrackName_l(int name);
- virtual uint32_t getMaxBufferRecoveryInUsecs();
+ virtual uint32_t activeSleepTimeUs();
+ virtual uint32_t idleSleepTimeUs();
private:
float mLeftVolume;