We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2696

Summary: [Patch] Mac: fix display mode refresh rate calculation
Product: SDL Reporter: Alex Szpakowski <amaranth72>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: HG 2.0   
Hardware: x86_64   
OS: Mac OS X (All)   
Attachments: Patch to fix refresh rate calculation in OS X.

Description Alex Szpakowski 2014-08-20 22:09:49 UTC
Created attachment 1835 [details]
Patch to fix refresh rate calculation in OS X.

SDL's Cocoa backend uses the CGDisplayMode API to get refresh rate information about a display mode, but CGDisplayModeGetRefreshRate will return 0 on most non-CRT monitors.

The only way I know of to get correct refresh rate information in OS X is via the CoreVideo DisplayLink API.
I have attached a patch which tries to use the CVDisplayLinkGetNominalOutputVideoRefreshPeriod function if CGDisplayModeGetRefreshRate fails, which fixes display mode refresh rate information on the monitors I tested.

The CVDisplayLink API requires linking with the CoreVideo framework, and the patch updates the various build files to do so.
Comment 1 Sam Lantinga 2014-08-23 17:49:32 UTC
Great job being thorough in adding CoreVideo to the dependencies! :)
https://hg.libsdl.org/SDL/rev/345a7d41dda9