OSDN Git Service

am 20398fac: Merge "audioflinger: reduce sleep time to avoid underrun" into ics-mr1
authorEric Laurent <elaurent@google.com>
Wed, 23 Nov 2011 20:32:30 +0000 (12:32 -0800)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 23 Nov 2011 20:32:30 +0000 (12:32 -0800)
* commit '20398fac99ff78cb3ec3dd122930e45d409e0524':
  audioflinger: reduce sleep time to avoid underrun

1  2 
services/audioflinger/AudioFlinger.cpp

@@@ -2031,22 -1958,13 +2039,26 @@@ 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) {
+                 sleepTimeShift--;
+             }
              standbyTime = systemTime() + kStandbyTimeInNsecs;
              //TODO: delay standby when effects have a tail
          } else {