Skip to content

Commit

Permalink
Merge pull request xbmc#10082 from afedchin/d3d_vsync_fix
Browse files Browse the repository at this point in the history
[VideoSyncD3D] CVideoSyncD3D should implement IDispResource interface…
  • Loading branch information
afedchin committed Jul 7, 2016
2 parents e318896 + a625d1b commit 06d5304
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
11 changes: 6 additions & 5 deletions xbmc/video/videosync/VideoSyncD3D.cpp
Expand Up @@ -31,7 +31,7 @@
#include "win32/dxerr.h"
#include "utils/StringUtils.h"

void CVideoSyncD3D::OnDestroyDevice()
void CVideoSyncD3D::OnLostDisplay()
{
if (!m_displayLost)
{
Expand All @@ -40,7 +40,7 @@ void CVideoSyncD3D::OnDestroyDevice()
}
}

void CVideoSyncD3D::OnResetDevice()
void CVideoSyncD3D::OnResetDisplay()
{
m_displayReset = true;
}
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 10 additions & 10 deletions xbmc/video/videosync/VideoSyncD3D.h
Expand Up @@ -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);

Expand Down

0 comments on commit 06d5304

Please sign in to comment.