aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMemphiz <memphis@machzwo.de>2015-05-16 16:50:17 +0200
committerMemphiz <memphis@machzwo.de>2015-05-18 21:53:14 +0200
commit1547af2da695f1c4bfbe9722cbeb806d5b486c2d (patch)
tree43284479ac02fa4d6da6764169c94e072a5e66e7
parent483796b9283e55d952b2e4d042c81f8a1f9e362b (diff)
[osx/videosync] - call our UpdateClock with our hostcounter, but calc vblank with the corevideo hostcounter (at the end they might be the same)
-rw-r--r--xbmc/video/videosync/VideoSyncOsx.cpp27
-rw-r--r--xbmc/video/videosync/VideoSyncOsx.h2
2 files changed, 18 insertions, 11 deletions
diff --git a/xbmc/video/videosync/VideoSyncOsx.cpp b/xbmc/video/videosync/VideoSyncOsx.cpp
index c0c63b6290..1302b6f25e 100644
--- a/xbmc/video/videosync/VideoSyncOsx.cpp
+++ b/xbmc/video/videosync/VideoSyncOsx.cpp
@@ -29,6 +29,7 @@
#include "utils/TimeUtils.h"
#include "windowing/WindowingFactory.h"
#include <QuartzCore/CVDisplayLink.h>
+#include <CoreVideo/CVHostTime.h>
#include "osx/CocoaInterface.h"
bool CVideoSyncOsx::Setup(PUPDATECLOCK func)
@@ -36,7 +37,7 @@ bool CVideoSyncOsx::Setup(PUPDATECLOCK func)
CLog::Log(LOGDEBUG, "CVideoSyncOsx::%s setting up OSX", __FUNCTION__);
//init the vblank timestamp
- m_LastVBlankTime = CurrentHostCounter();
+ m_LastVBlankTime = 0;
UpdateClock = func;
m_displayLost = false;
m_displayReset = false;
@@ -101,20 +102,23 @@ void CVideoSyncOsx::OnResetDevice()
m_displayReset = true;
}
-void CVideoSyncOsx::VblankHandler(int64_t nowtime)
+void CVideoSyncOsx::VblankHandler(int64_t nowtime, uint32_t timebase)
{
int NrVBlanks;
double VBlankTime;
+ int64_t Now = CurrentHostCounter();
- //calculate how many vblanks happened
- VBlankTime = (double)(nowtime - m_LastVBlankTime) / (double)g_VideoReferenceClock.GetFrequency();
- NrVBlanks = MathUtils::round_int(VBlankTime * m_fps);
-
+ if (m_LastVBlankTime != 0)
+ {
+ VBlankTime = (double)(nowtime - m_LastVBlankTime) / (double)timebase;
+ NrVBlanks = MathUtils::round_int(VBlankTime * m_fps);
+
+ //update the vblank timestamp, update the clock and send a signal that we got a vblank
+ UpdateClock(NrVBlanks, Now);
+ }
+
//save the timestamp of this vblank so we can calculate how many happened next time
m_LastVBlankTime = nowtime;
-
- //update the vblank timestamp, update the clock and send a signal that we got a vblank
- UpdateClock(NrVBlanks, nowtime);
}
// Called by the Core Video Display Link whenever it's appropriate to render a frame.
@@ -125,7 +129,10 @@ static CVReturn DisplayLinkCallBack(CVDisplayLinkRef displayLink, const CVTimeSt
CVideoSyncOsx *VideoSyncOsx = reinterpret_cast<CVideoSyncOsx*>(displayLinkContext);
- VideoSyncOsx->VblankHandler(inOutputTime->hostTime);
+ if (inOutputTime->flags & kCVTimeStampHostTimeValid)
+ VideoSyncOsx->VblankHandler(inOutputTime->hostTime, CVGetHostClockFrequency());
+ else
+ VideoSyncOsx->VblankHandler(CVGetCurrentHostTime(), CVGetHostClockFrequency());
// Destroy the autorelease pool
Cocoa_Destroy_AutoReleasePool(pool);
diff --git a/xbmc/video/videosync/VideoSyncOsx.h b/xbmc/video/videosync/VideoSyncOsx.h
index 07fc37c794..66b1d06ccd 100644
--- a/xbmc/video/videosync/VideoSyncOsx.h
+++ b/xbmc/video/videosync/VideoSyncOsx.h
@@ -42,7 +42,7 @@ public:
virtual void OnResetDevice();
// used in the displaylink callback
- void VblankHandler(int64_t nowtime);
+ void VblankHandler(int64_t nowtime, uint32_t timebase);
private:
virtual bool InitDisplayLink();