OSDN Git Service

resolved conflicts for merge of 7eeaf3f0 to ics-aah
authorJason Simmons <jsimmons@google.com>
Tue, 24 Jan 2012 21:16:19 +0000 (13:16 -0800)
committerJason Simmons <jsimmons@google.com>
Tue, 24 Jan 2012 21:16:19 +0000 (13:16 -0800)
Change-Id: I92b709268e22e3c3e9590c15173ab073b37db726

1  2 
services/audioflinger/AudioFlinger.cpp

@@@ -2086,27 -1971,17 +2086,30 @@@ bool AudioFlinger::MixerThread::threadL
         }
  
          if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
 +            // obtain the presentation timestamp of the next output buffer
 +            int64_t pts;
 +            status_t status = INVALID_OPERATION;
 +
 +            if (NULL != mOutput->stream->get_next_write_timestamp) {
 +                status = mOutput->stream->get_next_write_timestamp(
 +                        mOutput->stream, &pts);
 +            }
 +
 +            if (status != NO_ERROR) {
 +                pts = AudioBufferProvider::kInvalidPTS;
 +            }
 +
              // mix buffers...
 -            mAudioMixer->process();
 +            mAudioMixer->process(pts);
-             sleepTime = 0;
-             // increase sleep time progressively when application underrun condition clears
-             if (sleepTimeShift > 0) {
+             // increase sleep time progressively when application underrun condition clears.
+             // Only increase sleep time if the mixer is ready for two consecutive times to avoid
+             // that a steady state of alternating ready/not ready conditions keeps the sleep time
+             // such that we would underrun the audio HAL.
+             if ((sleepTime == 0) && (sleepTimeShift > 0)) {
                  sleepTimeShift--;
              }
 -            standbyTime = systemTime() + kStandbyTimeInNsecs;
+             sleepTime = 0;
 +            standbyTime = systemTime() + mStandbyTimeInNsecs;
              //TODO: delay standby when effects have a tail
          } else {
              // If no tracks are ready, sleep once for the duration of an output