mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 04:58:06 +00:00
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.
This commit is contained in:
parent
0fad73862c
commit
bc1dce5d5b
@ -374,22 +374,23 @@ static void vo_cocoa_update_screen_fps(struct vo *vo)
|
|||||||
NSDictionary* sinfo = [screen deviceDescription];
|
NSDictionary* sinfo = [screen deviceDescription];
|
||||||
NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"];
|
NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"];
|
||||||
CGDirectDisplayID did = [sid longValue];
|
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,
|
// Fallback to using Nominal refresh rate from DisplayLink,
|
||||||
// CVDisplayLinkGet *Actual* OutputVideoRefreshPeriod seems to
|
// CVDisplayLinkGet *Actual* OutputVideoRefreshPeriod seems to
|
||||||
// return 0 as well if CG returns 0
|
// return 0 on some Apple devices. Use the nominal refresh period
|
||||||
CVDisplayLinkRef link;
|
// instead.
|
||||||
CVDisplayLinkCreateWithCGDisplay(did, &link);
|
|
||||||
const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
||||||
if (!(t.flags & kCVTimeIsIndefinite))
|
if (!(t.flags & kCVTimeIsIndefinite))
|
||||||
s->screen_fps = (t.timeScale / (double) t.timeValue);
|
s->screen_fps = (t.timeScale / (double) t.timeValue);
|
||||||
CVDisplayLinkRelease(link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CVDisplayLinkRelease(link);
|
||||||
|
|
||||||
flag_events(vo, VO_EVENT_WIN_STATE);
|
flag_events(vo, VO_EVENT_WIN_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user