Loading services/surfaceflinger/Scheduler/DispSync.cpp +11 −14 Original line number Original line Diff line number Diff line Loading @@ -210,17 +210,14 @@ public: const nsecs_t baseTime = now - mReferenceTime; const nsecs_t baseTime = now - mReferenceTime; const nsecs_t numPeriodsSinceReference = baseTime / mPeriod; const nsecs_t numPeriodsSinceReference = baseTime / mPeriod; const nsecs_t predictedReference = mReferenceTime + numPeriodsSinceReference * mPeriod; const nsecs_t predictedReference = mReferenceTime + numPeriodsSinceReference * mPeriod; listener.mLastEventTime = predictedReference + mPhase + listener.mPhase; const nsecs_t phaseCorrection = mPhase + listener.mPhase; // If we're very close in time to the predicted last event time, const nsecs_t predictedLastEventTime = predictedReference + phaseCorrection; // and we're not very close to the next predicted last event time if (predictedLastEventTime >= now) { // then we need to back up the last event time so that we can // Make sure that the last event time does not exceed the current time. // attempt to fire an event immediately. // If it would, then back the last event time by a period. // listener.mLastEventTime = predictedLastEventTime - mPeriod; // Otherwise, keep the last event time that we predicted so that } else { // we don't wake up early. listener.mLastEventTime = predictedLastEventTime; if (isShorterThanPeriod(now - listener.mLastEventTime) && !isShorterThanPeriod(listener.mLastEventTime + mPeriod - now)) { listener.mLastEventTime -= mPeriod; } } } else { } else { listener.mLastEventTime = now + mPhase - mWakeupLatency; listener.mLastEventTime = now + mPhase - mWakeupLatency; Loading Loading @@ -316,7 +313,7 @@ private: // Sanity check that the duration is close enough in length to a period without // Sanity check that the duration is close enough in length to a period without // falling into double-rate vsyncs. // falling into double-rate vsyncs. bool isShorterThanPeriod(nsecs_t duration) { bool isCloseToPeriod(nsecs_t duration) { // Ratio of 3/5 is arbitrary, but it must be greater than 1/2. // Ratio of 3/5 is arbitrary, but it must be greater than 1/2. return duration < (3 * mPeriod) / 5; return duration < (3 * mPeriod) / 5; } } Loading @@ -332,7 +329,7 @@ private: nsecs_t t = computeListenerNextEventTimeLocked(eventListener, onePeriodAgo); nsecs_t t = computeListenerNextEventTimeLocked(eventListener, onePeriodAgo); if (t < now) { if (t < now) { if (isShorterThanPeriod(now - eventListener.mLastCallbackTime)) { if (isCloseToPeriod(now - eventListener.mLastCallbackTime)) { eventListener.mLastEventTime = t; eventListener.mLastEventTime = t; ALOGV("[%s] [%s] Skipping event due to model error", mName, ALOGV("[%s] [%s] Skipping event due to model error", mName, eventListener.mName); eventListener.mName); Loading Loading @@ -392,7 +389,7 @@ private: // Check that it's been slightly more than half a period since the last // Check that it's been slightly more than half a period since the last // event so that we don't accidentally fall into double-rate vsyncs // event so that we don't accidentally fall into double-rate vsyncs if (isShorterThanPeriod(t - listener.mLastEventTime)) { if (isCloseToPeriod(t - listener.mLastEventTime)) { t += mPeriod; t += mPeriod; ALOGV("[%s] Modifying t -> %" PRId64, mName, ns2us(t)); ALOGV("[%s] Modifying t -> %" PRId64, mName, ns2us(t)); } } Loading Loading
services/surfaceflinger/Scheduler/DispSync.cpp +11 −14 Original line number Original line Diff line number Diff line Loading @@ -210,17 +210,14 @@ public: const nsecs_t baseTime = now - mReferenceTime; const nsecs_t baseTime = now - mReferenceTime; const nsecs_t numPeriodsSinceReference = baseTime / mPeriod; const nsecs_t numPeriodsSinceReference = baseTime / mPeriod; const nsecs_t predictedReference = mReferenceTime + numPeriodsSinceReference * mPeriod; const nsecs_t predictedReference = mReferenceTime + numPeriodsSinceReference * mPeriod; listener.mLastEventTime = predictedReference + mPhase + listener.mPhase; const nsecs_t phaseCorrection = mPhase + listener.mPhase; // If we're very close in time to the predicted last event time, const nsecs_t predictedLastEventTime = predictedReference + phaseCorrection; // and we're not very close to the next predicted last event time if (predictedLastEventTime >= now) { // then we need to back up the last event time so that we can // Make sure that the last event time does not exceed the current time. // attempt to fire an event immediately. // If it would, then back the last event time by a period. // listener.mLastEventTime = predictedLastEventTime - mPeriod; // Otherwise, keep the last event time that we predicted so that } else { // we don't wake up early. listener.mLastEventTime = predictedLastEventTime; if (isShorterThanPeriod(now - listener.mLastEventTime) && !isShorterThanPeriod(listener.mLastEventTime + mPeriod - now)) { listener.mLastEventTime -= mPeriod; } } } else { } else { listener.mLastEventTime = now + mPhase - mWakeupLatency; listener.mLastEventTime = now + mPhase - mWakeupLatency; Loading Loading @@ -316,7 +313,7 @@ private: // Sanity check that the duration is close enough in length to a period without // Sanity check that the duration is close enough in length to a period without // falling into double-rate vsyncs. // falling into double-rate vsyncs. bool isShorterThanPeriod(nsecs_t duration) { bool isCloseToPeriod(nsecs_t duration) { // Ratio of 3/5 is arbitrary, but it must be greater than 1/2. // Ratio of 3/5 is arbitrary, but it must be greater than 1/2. return duration < (3 * mPeriod) / 5; return duration < (3 * mPeriod) / 5; } } Loading @@ -332,7 +329,7 @@ private: nsecs_t t = computeListenerNextEventTimeLocked(eventListener, onePeriodAgo); nsecs_t t = computeListenerNextEventTimeLocked(eventListener, onePeriodAgo); if (t < now) { if (t < now) { if (isShorterThanPeriod(now - eventListener.mLastCallbackTime)) { if (isCloseToPeriod(now - eventListener.mLastCallbackTime)) { eventListener.mLastEventTime = t; eventListener.mLastEventTime = t; ALOGV("[%s] [%s] Skipping event due to model error", mName, ALOGV("[%s] [%s] Skipping event due to model error", mName, eventListener.mName); eventListener.mName); Loading Loading @@ -392,7 +389,7 @@ private: // Check that it's been slightly more than half a period since the last // Check that it's been slightly more than half a period since the last // event so that we don't accidentally fall into double-rate vsyncs // event so that we don't accidentally fall into double-rate vsyncs if (isShorterThanPeriod(t - listener.mLastEventTime)) { if (isCloseToPeriod(t - listener.mLastEventTime)) { t += mPeriod; t += mPeriod; ALOGV("[%s] Modifying t -> %" PRId64, mName, ns2us(t)); ALOGV("[%s] Modifying t -> %" PRId64, mName, ns2us(t)); } } Loading