void CVideoReferenceClock::Process() { bool SetupSuccess = false; int64_t Now; while(!m_bStop) { m_pVideoSync = g_Windowing.GetVideoSync(this); if (m_pVideoSync) { SetupSuccess = m_pVideoSync->Setup(CBUpdateClock); UpdateRefreshrate(); } CSingleLock SingleLock(m_CritSection); Now = CurrentHostCounter(); m_CurrTime = Now + m_ClockOffset; //add the clock offset from the previous time we stopped m_LastIntTime = m_CurrTime; m_CurrTimeFract = 0.0; m_ClockSpeed = 1.0; m_TotalMissedVblanks = 0; m_MissedVblanks = 0; if (SetupSuccess) { m_UseVblank = true; //tell other threads we're using vblank as clock m_VblankTime = Now; //initialize the timestamp of the last vblank SingleLock.Leave(); //run the clock m_pVideoSync->Run(m_bStop); } else { SingleLock.Leave(); CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setup failed, falling back to CurrentHostCounter()"); } SingleLock.Enter(); m_UseVblank = false; //we're back to using the systemclock Now = CurrentHostCounter(); //set the clockoffset between the vblank clock and systemclock m_ClockOffset = m_CurrTime - Now; SingleLock.Leave(); //clean up the vblank clock if (m_pVideoSync) { m_pVideoSync->Cleanup(); m_pVideoSync.reset(); } if (!SetupSuccess) break; } }
void CVideoReferenceClock::Process() { bool SetupSuccess = false; int64_t Now; while(!m_bStop) { m_pVideoSync = CServiceBroker::GetWinSystem()->GetVideoSync(this); if (m_pVideoSync) { SetupSuccess = m_pVideoSync->Setup(CBUpdateClock); UpdateRefreshrate(); } CSingleLock SingleLock(m_CritSection); Now = CurrentHostCounter(); m_CurrTime = Now; m_LastIntTime = m_CurrTime; m_CurrTimeFract = 0.0; m_ClockSpeed = 1.0; m_TotalMissedVblanks = 0; m_MissedVblanks = 0; if (SetupSuccess) { m_UseVblank = true; //tell other threads we're using vblank as clock m_VblankTime = Now; //initialize the timestamp of the last vblank SingleLock.Leave(); m_vsyncStopEvent.Reset(); //run the clock m_pVideoSync->Run(m_vsyncStopEvent); } else { SingleLock.Leave(); CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setup failed, falling back to CurrentHostCounter()"); } SingleLock.Enter(); m_UseVblank = false; //we're back to using the systemclock SingleLock.Leave(); //clean up the vblank clock if (m_pVideoSync) { m_pVideoSync->Cleanup(); m_pVideoSync.reset(); } if (!SetupSuccess) break; } }
void CVideoReferenceClock::Process() { bool SetupSuccess = false; int64_t Now; while(!m_bStop) { //set up the vblank clock #if defined(HAVE_X11) std::string gpuvendor = g_Windowing.GetRenderVendor(); std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower); if ((gpuvendor.compare(0, 5, "intel") == 0 || gpuvendor.compare(0, 5, "x.org") == 0)) // AMD m_pVideoSync = new CVideoSyncDRM(); #if defined(HAS_GLX) else m_pVideoSync = new CVideoSyncGLX(); #endif #elif defined(TARGET_DARWIN_OSX) m_pVideoSync = new CVideoSyncOsx(); #elif defined(TARGET_DARWIN_IOS) m_pVideoSync = new CVideoSyncIos(); #elif defined(TARGET_RASPBERRY_PI) m_pVideoSync = new CVideoSyncPi(); #elif defined(TARGET_ANDROID) m_pVideoSync = new CVideoSyncAndroid(); #endif if (m_pVideoSync) { SetupSuccess = m_pVideoSync->Setup(CBUpdateClock); UpdateRefreshrate(); } CSingleLock SingleLock(m_CritSection); Now = CurrentHostCounter(); m_CurrTime = Now + m_ClockOffset; //add the clock offset from the previous time we stopped m_LastIntTime = m_CurrTime; m_CurrTimeFract = 0.0; m_ClockSpeed = 1.0; m_TotalMissedVblanks = 0; m_fineadjust = 1.0; m_MissedVblanks = 0; if (SetupSuccess) { m_UseVblank = true; //tell other threads we're using vblank as clock m_VblankTime = Now; //initialize the timestamp of the last vblank SingleLock.Leave(); //run the clock m_pVideoSync->Run(m_bStop); } else { SingleLock.Leave(); CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setup failed, falling back to CurrentHostCounter()"); } SingleLock.Enter(); m_UseVblank = false; //we're back to using the systemclock Now = CurrentHostCounter(); //set the clockoffset between the vblank clock and systemclock m_ClockOffset = m_CurrTime - Now; SingleLock.Leave(); //clean up the vblank clock if (m_pVideoSync) { m_pVideoSync->Cleanup(); delete m_pVideoSync; m_pVideoSync = NULL; } if (!SetupSuccess) break; } }