diff options
-rw-r--r-- | DOCS/man/vo.rst | 4 | ||||
-rw-r--r-- | video/out/cocoa_common.m | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst index 32bc600ec4..2f23bf7ca9 100644 --- a/DOCS/man/vo.rst +++ b/DOCS/man/vo.rst @@ -600,8 +600,8 @@ Available video output drivers are: can lead to bad results. If the framerate is close to or over the display refresh rate, results can be bad as well. - .. note:: On systems other than Linux, you currently must set the - ``--display-fps`` option, or the results will be bad. + .. note:: On systems other than Linux or OS X, you currently must set + the ``--display-fps`` option, or the results will be bad. ``smoothmotion-threshold=<0.0-0.5>`` Mix threshold at which interpolation is skipped (default: 0.0 – never diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index e89504c472..306b5aedd2 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -62,6 +62,7 @@ struct vo_cocoa_state { NSScreen *current_screen; NSScreen *fs_screen; + double screen_fps; NSInteger window_level; @@ -256,6 +257,27 @@ static void vo_cocoa_update_screens_pointers(struct vo *vo) get_screen_handle(vo, opts->fsscreen_id, s->window, &s->fs_screen); } +static void vo_cocoa_update_screen_fps(struct vo *vo) +{ + struct vo_cocoa_state *s = vo->cocoa; + NSScreen *screen = vo->opts->fullscreen ? s->fs_screen : s->current_screen; + 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) { + // Most internal Apple monitors and laptop monitors report 0 instead + // of 60fps. Assume them to be 60hz. This is technically incorrect but + // works most of the time, and seems to be used in most open source + // software for lack of a better Apple API. + MP_VERBOSE(vo, "CoreGraphics reports a 0fps display. Assuming internal " + "Apple monitor @ 60fps instead.\n"); + s->screen_fps = 60.0; + } +} + static void vo_cocoa_update_screen_info(struct vo *vo, struct mp_rect *out_rc) { struct vo_cocoa_state *s = vo->cocoa; @@ -264,6 +286,7 @@ static void vo_cocoa_update_screen_info(struct vo *vo, struct mp_rect *out_rc) return; vo_cocoa_update_screens_pointers(vo); + vo_cocoa_update_screen_fps(vo); if (out_rc) { NSRect r = [s->current_screen frame]; @@ -649,6 +672,9 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) case VOCTRL_GET_ICC_PROFILE: vo_cocoa_control_get_icc_profile(vo, arg); return VO_TRUE; + case VOCTRL_GET_DISPLAY_FPS: + *(double *)arg = vo->cocoa->screen_fps; + return VO_TRUE; } return VO_NOTIMPL; } |