1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

cocoa: fix display refresh rate retrieval on multi monitor setups

1. this basically reverts commit de4c74e5a4.
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.
This commit is contained in:
Akemi 2016-06-17 04:02:51 +02:00 committed by wm4
parent fb7c5804bb
commit 47d9fbd133
2 changed files with 17 additions and 4 deletions

View File

@ -56,6 +56,11 @@
[self.adapter setNeedsResize];
}
- (void)windowDidChangeScreen:(NSNotification *)notification
{
[self.adapter windowDidChangeScreen:notification];
}
- (void)windowDidChangeScreenProfile:(NSNotification *)notification
{
[self.adapter didChangeWindowedScreenProfile:[self screen]];

View File

@ -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);