1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-01 12:22:22 +00:00

cocoa: use displaylink without manually tracking the display id

Maybe it partially helps with #2392 (on dual display setups). Either way, it
makes the code simpler.
This commit is contained in:
Stefano Pigozzi 2016-06-11 11:51:30 +02:00
parent 9cc5507079
commit de4c74e5a4

View File

@ -370,13 +370,14 @@ static void vo_cocoa_update_screens_pointers(struct vo *vo)
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;
CVDisplayLinkCreateWithCGDisplay(did, &link);
CVDisplayLinkCreateWithActiveCGDisplays(&link);
CVDisplayLinkStart(link);
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(
link, s->cgl_ctx, CGLGetPixelFormat(s->cgl_ctx));
s->screen_fps = CVDisplayLinkGetActualOutputVideoRefreshPeriod(link);
if (s->screen_fps == 0) {