summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2016-01-06 13:33:42 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2016-01-13 08:58:15 +0100
commit6ea1f5b13b0661bc62f080b4c942d68be29da562 (patch)
tree8b361d43aba85916fef9dc73db479243e63ebf2e
parentc16a0c99c85ffadf230c4fcc8173d8f3f1688a4a (diff)
downloadmpv-timing.tar.bz2
mpv-timing.tar.xz
cocoa: get fps only from dislaylinktiming
In my tests, CGDisplayModeGetRefreshRate returns 24.0 even though the nominal one is set to 24000/1001. This is obviously not good for video.
-rw-r--r--video/out/cocoa_common.m17
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);
}