summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2016-06-17 04:02:51 +0200
committerwm4 <wm4@nowhere>2016-06-18 19:15:36 +0200
commit47d9fbd13345e50468f0fc2bd574cbc60c89fc87 (patch)
tree62a8e22d83593080f6cf1d674c3c37dde8e49071
parentfb7c5804bbb6046472406f3fa8426784cbda4408 (diff)
downloadmpv-47d9fbd13345e50468f0fc2bd574cbc60c89fc87.tar.bz2
mpv-47d9fbd13345e50468f0fc2bd574cbc60c89fc87.tar.xz
cocoa: fix display refresh rate retrieval on multi monitor setups
1. this basically reverts commit de4c74e5a4a996e8ff431c8f33a32c4b580be203. even with CVDisplayLinkCreateWithActiveCGDisplays and CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext we still have to explicitly set the current display ID, otherwise it will just always choose the display with the lowest refresh rate. another weird thing is, we still have to set the display ID another time with CVDisplayLinkSetCurrentCGDisplay after the link was started. otherwise the display period is 0 and the fallback will be used. if we ever use the callback method for something useful it's probably better to use CVDisplayLinkCreateWithActiveCGDisplays since we will need to keep the display link around instead of releasing it at the end. in that case we have to call CVDisplayLinkSetCurrentCGDisplay two times, once before and once after LinkStart. 2. add windowDidChangeScreen delegate to update the display refresh rate when mpv is moved to a different screen.
-rw-r--r--video/out/cocoa/window.m5
-rw-r--r--video/out/cocoa_common.m16
2 files changed, 17 insertions, 4 deletions
diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m
index 646281df79..d89e296b40 100644
--- a/video/out/cocoa/window.m
+++ b/video/out/cocoa/window.m
@@ -56,6 +56,11 @@
[self.adapter setNeedsResize];
}
+- (void)windowDidChangeScreen:(NSNotification *)notification
+{
+ [self.adapter windowDidChangeScreen:notification];
+}
+
- (void)windowDidChangeScreenProfile:(NSNotification *)notification
{
[self.adapter didChangeWindowedScreenProfile:[self screen]];
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index bd841d3a88..21e1246b1c 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -374,13 +374,16 @@ 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];
+
CVDisplayLinkRef link;
- CVDisplayLinkCreateWithActiveCGDisplays(&link);
+ CVDisplayLinkCreateWithCGDisplay(did, &link);
CVDisplayLinkSetOutputCallback(link, &displayLinkCallback, NULL);
CVDisplayLinkStart(link);
-
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(
- link, s->cgl_ctx, CGLGetPixelFormat(s->cgl_ctx));
+ CVDisplayLinkSetCurrentCGDisplay(link, did);
double display_period = CVDisplayLinkGetActualOutputVideoRefreshPeriod(link);
@@ -947,6 +950,11 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
[[EventsResponder sharedInstance] handleFilesArray:files];
}
+- (void)windowDidChangeScreen:(NSNotification *)notification
+{
+ vo_cocoa_update_screen_info(self.vout, NULL);
+}
+
- (void)didChangeWindowedScreenProfile:(NSScreen *)screen
{
flag_events(self.vout, VO_EVENT_ICC_PROFILE_CHANGED);