mirror of https://github.com/mpv-player/mpv
mac/compat: fix compatibility for deployment targets lower than SDK ver
the swift parts can't be nicely encapsulated in the compat file because it lags proper target version compile time checks. Fixes #15292
This commit is contained in:
parent
46574d479d
commit
45c1c58680
|
@ -17,12 +17,17 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef GL_SILENCE_DEPRECATION
|
#ifndef GL_SILENCE_DEPRECATION
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_MACOS_12_FEATURES
|
#ifndef MAC_OS_VERSION_12_0
|
||||||
|
#define MAC_OS_VERSION_12_0 120000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_MACOS_12_FEATURES || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
|
||||||
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
|
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,10 +44,6 @@ extension NSDraggingInfo {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_MACOS_12_FEATURES
|
|
||||||
let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
|
#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
|
||||||
@available(macOS 11.0, *)
|
@available(macOS 11.0, *)
|
||||||
extension CGColorSpace {
|
extension CGColorSpace {
|
||||||
|
|
|
@ -281,13 +281,16 @@ class Common: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initLightSensor() {
|
func initLightSensor() {
|
||||||
let srv = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleLMUController"))
|
let mainPort: mach_port_t
|
||||||
|
if #available(macOS 12.0, *) { mainPort = kIOMainPortDefault } else { mainPort = kIOMasterPortDefault }
|
||||||
|
|
||||||
|
let srv = IOServiceGetMatchingService(mainPort, IOServiceMatching("AppleLMUController"))
|
||||||
if srv == IO_OBJECT_NULL {
|
if srv == IO_OBJECT_NULL {
|
||||||
log.verbose("Can't find an ambient light sensor")
|
log.verbose("Can't find an ambient light sensor")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault)
|
lightSensorIOPort = IONotificationPortCreate(mainPort)
|
||||||
IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)
|
IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)
|
||||||
var n = io_object_t()
|
var n = io_object_t()
|
||||||
IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,
|
IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,
|
||||||
|
|
Loading…
Reference in New Issue