Permalink
Browse files

Merge pull request #10082 from afedchin/d3d_vsync_fix

[VideoSyncD3D] CVideoSyncD3D should implement IDispResource interface…
  • Loading branch information...
2 parents e318896 + a625d1b commit 06d5304c217953d90f5bf6650e9aedaf6dfbdcdb @afedchin afedchin committed Jul 7, 2016
Showing with 16 additions and 15 deletions.
  1. +6 −5 xbmc/video/videosync/VideoSyncD3D.cpp
  2. +10 −10 xbmc/video/videosync/VideoSyncD3D.h
@@ -31,7 +31,7 @@
#include "win32/dxerr.h"
#include "utils/StringUtils.h"
-void CVideoSyncD3D::OnDestroyDevice()
+void CVideoSyncD3D::OnLostDisplay()
{
if (!m_displayLost)
{
@@ -40,7 +40,7 @@ void CVideoSyncD3D::OnDestroyDevice()
}
}
-void CVideoSyncD3D::OnResetDevice()
+void CVideoSyncD3D::OnResetDisplay()
{
m_displayReset = true;
}
@@ -97,15 +97,16 @@ void CVideoSyncD3D::Run(volatile bool& stop)
if ((Now - m_lastUpdateTime) >= systemFrequency)
{
- if (m_fps != GetFps())
+ float fps = m_fps;
+ if (fps != GetFps())
break;
}
// because we had a vblank, sleep until half the refreshrate period because i think WaitForVBlank block any rendering stuf
// without sleeping we have freeze rendering
int SleepTime = (int)((LastVBlankTime + (systemFrequency / MathUtils::round_int(m_fps) / 2) - Now) * 1000 / systemFrequency);
- if (SleepTime > 100)
- SleepTime = 100; //failsafe
+ if (SleepTime > 50)
+ SleepTime = 50; //failsafe
if (SleepTime > 0)
::Sleep(SleepTime);
}
@@ -22,22 +22,22 @@
#if defined(TARGET_WINDOWS)
#include "video/videosync/VideoSync.h"
-#include "guilib/D3DResource.h"
+#include "guilib/DispResource.h"
#include "threads/Event.h"
-class CVideoSyncD3D : public CVideoSync, ID3DResource
+class CVideoSyncD3D : public CVideoSync, IDispResource
{
public:
CVideoSyncD3D(CVideoReferenceClock *clock) : CVideoSync(clock) {};
- virtual bool Setup(PUPDATECLOCK func);
- virtual void Run(volatile bool& stop);
- virtual void Cleanup();
- virtual float GetFps();
- virtual void RefreshChanged();
+ bool Setup(PUPDATECLOCK func) override;
+ void Run(volatile bool& stop) override;
+ void Cleanup() override;
+ float GetFps() override;
+ void RefreshChanged() override;
+ // IDispResource overrides
+ void OnLostDisplay() override;
+ void OnResetDisplay() override;
- virtual void OnCreateDevice() {}
- virtual void OnDestroyDevice();
- virtual void OnResetDevice();
private:
static std::string GetErrorDescription(HRESULT hr);

0 comments on commit 06d5304

Please sign in to comment.