Skip to content

Commit

Permalink
Merge pull request #11389 from Memphiz/vtb_choppy_bp
Browse files Browse the repository at this point in the history
[osx] - fix refclock after refreshrate change and re-add videoscreen.delayrefreshchange
  • Loading branch information
MartijnKaijser committed Jan 11, 2017
2 parents 77d3a00 + 6b0d017 commit 413464b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions xbmc/windowing/osx/WinSystemOSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CWinSystemOSX : public CWinSystemBase, public ITimerCallback

void AnnounceOnLostDevice();
void AnnounceOnResetDevice();
void HandleOnResetDevice();
void StartLostDeviceTimer();
void StopLostDeviceTimer();

Expand Down Expand Up @@ -119,6 +120,8 @@ class CWinSystemOSX : public CWinSystemBase, public ITimerCallback
CCriticalSection m_resourceSection;
std::vector<IDispResource*> m_resources;
CTimer m_lostDeviceTimer;
bool m_delayDispReset;
XbmcThreads::EndTime m_dispResetTimer;
};

#endif
30 changes: 28 additions & 2 deletions xbmc/windowing/osx/WinSystemOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static void DisplayReconfigured(CGDirectDisplayID display,
if (flags & kCGDisplaySetModeFlag || flags == 0)
{
winsys->StopLostDeviceTimer(); // no need to timeout - we've got the callback
winsys->AnnounceOnResetDevice();
winsys->HandleOnResetDevice();
}
}

Expand All @@ -540,6 +540,7 @@ static void DisplayReconfigured(CGDirectDisplayID display,
m_lastDisplayNr = -1;
m_movedToOtherScreen = false;
m_refreshRate = 0.0;
m_delayDispReset = false;
}

CWinSystemOSX::~CWinSystemOSX()
Expand All @@ -561,7 +562,7 @@ static void DisplayReconfigured(CGDirectDisplayID display,

void CWinSystemOSX::OnTimeout()
{
AnnounceOnResetDevice();
HandleOnResetDevice();
}

bool CWinSystemOSX::InitWindowSystem()
Expand Down Expand Up @@ -1741,8 +1742,33 @@ static void DisplayReconfigured(CGDirectDisplayID display,
(*i)->OnLostDisplay();
}

void CWinSystemOSX::HandleOnResetDevice()
{

int delay = CSettings::GetInstance().GetInt("videoscreen.delayrefreshchange");
if (delay > 0)
{
m_delayDispReset = true;
m_dispResetTimer.Set(delay * 100);
}
else
{
AnnounceOnResetDevice();
}
}

void CWinSystemOSX::AnnounceOnResetDevice()
{
double currentFps = m_refreshRate;
int w = 0;
int h = 0;
int currentScreenIdx = GetCurrentScreen();
// ensure that graphics context knows about the current refreshrate before
// doing the callbacks
GetScreenResolution(&w, &h, &currentFps, currentScreenIdx);

g_graphicsContext.SetFPS(currentFps);

CSingleLock lock(m_resourceSection);
// tell any shared resources
CLog::Log(LOGDEBUG, "CWinSystemOSX::AnnounceOnResetDevice");
Expand Down
6 changes: 6 additions & 0 deletions xbmc/windowing/osx/WinSystemOSXGL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
{
if (rendered)
FlushBuffer();

if (m_delayDispReset && m_dispResetTimer.IsTimePast())
{
m_delayDispReset = false;
AnnounceOnResetDevice();
}
}

void CWinSystemOSXGL::SetVSyncImpl(bool enable)
Expand Down

0 comments on commit 413464b

Please sign in to comment.