Skip to content

Commit 26590dd

Browse files
committed
cocoa_gl_ctx: gate CGDisplayModeRef refresh-rate read on 10.6 SDK
GCC 4.0 (Xcode 3.1, PowerPC) reports: cocoa_gl_ctx.m:251: error: 'CGDisplayModeRef' undeclared (first use in this function) CGDisplayModeRef, CGDisplayCopyDisplayMode, and CGDisplayModeGet- RefreshRate all arrived in 10.6 Snow Leopard. The 10.5 Leopard SDK only exposes the older CFDictionaryRef-based CGDisplayCurrent- Mode API, which is a different enough shape that it's not worth wiring up for a single refresh-rate readout. Gate the existing OSX block on MAC_OS_X_VERSION_10_6 (defined only on 10.6+ SDKs). On older SDKs, return 60.0f — same pattern the iOS #else branch already uses for targets older than iOS 10.3 / tvOS 10.2 that don't have maximumFramesPerSecond. Related: 667256a gated the same CGDisplayModeRef family in dispserv_apple.m behind a RARCH_HAS_CGDISPLAYMODE_API macro. This change uses the raw SDK gate (MAC_OS_X_VERSION_10_6) to stay consistent with the other MAC_OS_X_VERSION_* gates already in this file at lines 206, 298, 375, 396, 402, 610. Modern macOS builds are unaffected.
1 parent 345a2ef commit 26590dd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

gfx/drivers_context/cocoa_gl_ctx.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,19 @@ static void cocoa_gl_gfx_ctx_get_video_size(void *data,
247247
static float cocoa_gl_gfx_ctx_get_refresh_rate(void *data)
248248
{
249249
#ifdef OSX
250+
#ifdef MAC_OS_X_VERSION_10_6
251+
/* CGDisplayModeRef and CGDisplayCopyDisplayMode are 10.6+.
252+
* On the 10.5 Leopard SDK only the older CFDictionaryRef-based
253+
* CGDisplayCurrentMode API exists; not worth wiring up for a
254+
* refresh-rate readout, so fall back to 60. */
250255
CGDirectDisplayID mainDisplayID = CGMainDisplayID();
251256
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(mainDisplayID);
252257
float currentRate = CGDisplayModeGetRefreshRate(currentMode);
253258
CFRelease(currentMode);
254259
return currentRate;
260+
#else
261+
return 60.0f;
262+
#endif
255263
#else
256264
if (@available(iOS 10.3, tvOS 10.2, *))
257265
return [UIScreen mainScreen].maximumFramesPerSecond;

0 commit comments

Comments
 (0)