Merge "MediaPlayer/MediaRecorder: Do not notify client of audioserver death" into nyc-dev am: c33457231a
am: 5e5364848d
* commit '5e5364848ddf4c210f12d8052a747c86c30e2f04':
MediaPlayer/MediaRecorder: Do not notify client of audioserver death
Change-Id: Ibcf20b8e2907f0d25c788e4c89bd52e1e98fa2d7
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d296ee3..96b7630 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2285,6 +2285,7 @@
kUseFastMixer == FastMixer_Dynamic)) {
size_t minNormalFrameCount = (kMinNormalSinkBufferSizeMs * mSampleRate) / 1000;
size_t maxNormalFrameCount = (kMaxNormalSinkBufferSizeMs * mSampleRate) / 1000;
+
// round up minimum and round down maximum to nearest 16 frames to satisfy AudioMixer
minNormalFrameCount = (minNormalFrameCount + 15) & ~15;
maxNormalFrameCount = maxNormalFrameCount & ~15;
@@ -2301,18 +2302,7 @@
multiplier = (double) maxNormalFrameCount / (double) mFrameCount;
}
} else {
- // prefer an even multiplier, for compatibility with doubling of fast tracks due to HAL
- // SRC (it would be unusual for the normal sink buffer size to not be a multiple of fast
- // track, but we sometimes have to do this to satisfy the maximum frame count
- // constraint)
- // FIXME this rounding up should not be done if no HAL SRC
- uint32_t truncMult = (uint32_t) multiplier;
- if ((truncMult & 1)) {
- if ((truncMult + 1) * mFrameCount <= maxNormalFrameCount) {
- ++truncMult;
- }
- }
- multiplier = (double) truncMult;
+ multiplier = floor(multiplier);
}
}
mNormalFrameCount = multiplier * mFrameCount;
@@ -2835,6 +2825,7 @@
// MIXER
nsecs_t lastWarning = 0;
+ nsecs_t mixStartNs = 0;
// DUPLICATING
// FIXME could this be made local to while loop?
@@ -3017,6 +3008,7 @@
if (mBytesRemaining == 0) {
mCurrentWriteLength = 0;
if (mMixerStatus == MIXER_TRACKS_READY) {
+ mixStartNs = systemTime();
// threadLoop_mix() sets mCurrentWriteLength
threadLoop_mix();
} else if ((mMixerStatus != MIXER_DRAIN_TRACK)
@@ -3144,8 +3136,13 @@
// (1) mixer threads without a fast mixer (which has its own warm-up)
// (2) minimum buffer sized tracks (even if the track is full,
// the app won't fill fast enough to handle the sudden draw).
+ //
+ // Total time spent in last processing cycle equals time spent in
+ // 1. threadLoop_write, as well as time spent in
+ // 2. threadLoop_mix (significant for heavy mixing, especially
+ // on low tier processors)
- const int32_t deltaMs = delta / 1000000;
+ const int32_t deltaMs = (now - mixStartNs)/ 1000000;
const int32_t throttleMs = mHalfBufferMs - deltaMs;
if ((signed)mHalfBufferMs >= throttleMs && throttleMs > 0) {
usleep(throttleMs * 1000);