We can sometimes get an invalid-sync from the hardware. We should ensure we do not wake the
update-thread if this is the case.
However, we could be shutting down while getting several invalid vsyncs so we still check that.
Change-Id: Ib6424cce5ee1bbf106764b27883968b64793a4f3
+ // Ensure we do not process an invalid v-sync
+ if( validSync )
- ConditionalWait::ScopedLock vSyncLock( mVSyncThreadWaitCondition );
- if( numberOfVSyncsPerRender != mNumberOfVSyncsPerRender )
- numberOfVSyncsPerRender = mNumberOfVSyncsPerRender; // save it back
- mFrameTime.SetMinimumFrameTimeInterval( mNumberOfVSyncsPerRender * TIME_PER_FRAME_IN_MICROSECONDS );
- }
+ ConditionalWait::ScopedLock vSyncLock( mVSyncThreadWaitCondition );
+ if( numberOfVSyncsPerRender != mNumberOfVSyncsPerRender )
+ {
+ numberOfVSyncsPerRender = mNumberOfVSyncsPerRender; // save it back
+ mFrameTime.SetMinimumFrameTimeInterval( mNumberOfVSyncsPerRender * TIME_PER_FRAME_IN_MICROSECONDS );
+ }
mFrameTime.SetSyncTime( frameNumber );
}
mFrameTime.SetSyncTime( frameNumber );
}
- if( ! mVSyncThreadInitialised )
- {
- LOG_VSYNC( "Initialised" );
+ if( ! mVSyncThreadInitialised )
+ {
+ LOG_VSYNC( "Initialised" );
- mVSyncThreadInitialised = TRUE;
+ mVSyncThreadInitialised = TRUE;
- // Notify event thread that this thread is up and running, this locks so we should have a scoped-lock
- NotifyThreadInitialised();
- }
- else
- {
- // Increment v-sync-ahead-of-update count and inform update-thread
+ // Notify event thread that this thread is up and running, this locks so we should have a scoped-lock
+ NotifyThreadInitialised();
+ }
+ else
- ConditionalWait::ScopedLock lock( mUpdateThreadWaitCondition );
- ++mVSyncAheadOfUpdate;
- LOG_VSYNC_COUNTER_VSYNC( " vSyncAheadOfUpdate(%d)", mVSyncAheadOfUpdate );
+ // Increment v-sync-ahead-of-update count and inform update-thread
+ {
+ ConditionalWait::ScopedLock lock( mUpdateThreadWaitCondition );
+ ++mVSyncAheadOfUpdate;
+ LOG_VSYNC_COUNTER_VSYNC( " vSyncAheadOfUpdate(%d)", mVSyncAheadOfUpdate );
+ }
+ mUpdateThreadWaitCondition.Notify();
- mUpdateThreadWaitCondition.Notify();
- }
- // Ensure update-thread has set us to run before continuing
- // Ensure we do not wait if we're supposed to stop
- {
- ConditionalWait::ScopedLock vSyncLock( mVSyncThreadWaitCondition );
- while( ! mVSyncThreadRunning && ! mVSyncThreadStop )
+ // Ensure update-thread has set us to run before continuing
+ // Ensure we do not wait if we're supposed to stop
- LOG_VSYNC( "WAIT" );
- mVSyncThreadWaitCondition.Wait( vSyncLock );
+ ConditionalWait::ScopedLock vSyncLock( mVSyncThreadWaitCondition );
+ while( ! mVSyncThreadRunning && ! mVSyncThreadStop )
+ {
+ LOG_VSYNC( "WAIT" );
+ mVSyncThreadWaitCondition.Wait( vSyncLock );
+ }
+ else
+ {
+ LOG_VSYNC( "INVALID SYNC" );
+
+ // Later we still check if the v-sync thread is supposed to keep running so we can still stop the thread if we are supposed to
+ }
return IsVSyncThreadRunning(); // Call to this function locks so should not be called if we have a scoped-lock
}
return IsVSyncThreadRunning(); // Call to this function locks so should not be called if we have a scoped-lock
}