diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2016-01-06 13:33:42 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2016-01-14 11:11:43 +0100 |
commit | bc1dce5d5b8eabc29813b85ea79dd6d69a9367a3 (patch) | |
tree | 76c0d3b0cfbcf1b0a9ae72866a462fddadfd593a /video/out | |
parent | 0fad73862c69d19b5e24fc7522fb5d17ec612c29 (diff) |
cocoa: get fps only from dislaylink
In my tests, CGDisplayModeGetRefreshRate returns 24.0 even though the nominal
one is set to 24000/1001. This is obviously not good for video.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/cocoa_common.m | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 586a51dbe4..30b832da75 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -374,22 +374,23 @@ static void vo_cocoa_update_screen_fps(struct vo *vo) NSDictionary* sinfo = [screen deviceDescription]; NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"]; CGDirectDisplayID did = [sid longValue]; - CGDisplayModeRef mode = CGDisplayCopyDisplayMode(did); - s->screen_fps = CGDisplayModeGetRefreshRate(mode); - CGDisplayModeRelease(mode); - if (s->screen_fps == 0.0) { + CVDisplayLinkRef link; + CVDisplayLinkCreateWithCGDisplay(did, &link); + s->screen_fps = CVDisplayLinkGetActualOutputVideoRefreshPeriod(link); + + if (s->screen_fps == 0) { // Fallback to using Nominal refresh rate from DisplayLink, // CVDisplayLinkGet *Actual* OutputVideoRefreshPeriod seems to - // return 0 as well if CG returns 0 - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(did, &link); + // return 0 on some Apple devices. Use the nominal refresh period + // instead. const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); if (!(t.flags & kCVTimeIsIndefinite)) s->screen_fps = (t.timeScale / (double) t.timeValue); - CVDisplayLinkRelease(link); } + CVDisplayLinkRelease(link); + flag_events(vo, VO_EVENT_WIN_STATE); } |