Fix build with macOS < 12.0

This commit is contained in:
Jonas Kvinge 2023-08-27 13:54:23 +02:00
parent a333662f56
commit 45ad84a9bc
2 changed files with 13 additions and 1 deletions

View File

@ -21,6 +21,7 @@
#include <libmtp.h>
#include <AvailabilityMacros.h>
#include <CoreFoundation/CFRunLoop.h>
#include <DiskArbitration/DiskArbitration.h>
#include <IOKit/kext/KextManager.h>
@ -155,7 +156,13 @@ bool MacOsDeviceLister::Init() {
DASessionScheduleWithRunLoop(loop_session_, run_loop_, kCFRunLoopDefaultMode);
// Register for USB device connection/disconnection.
IONotificationPortRef notification_port = IONotificationPortCreate(kIOMainPortDefault);
IONotificationPortRef notification_port = IONotificationPortCreate(
#if defined(MAC_OS_VERSION_12_0) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_12_0)
kIOMainPortDefault
#else
kIOMasterPortDefault
#endif
);
CFMutableDictionaryRef matching_dict = IOServiceMatching(kIOUSBDeviceClassName);
// IOServiceAddMatchingNotification decreases reference count.
CFRetain(matching_dict);

View File

@ -22,6 +22,7 @@
#include <memory>
#include <AvailabilityMacros.h>
#include <CoreAudio/AudioHardware.h>
#include <QString>
@ -69,7 +70,11 @@ EngineDeviceList MacOsDeviceFinder::ListDevices() {
AudioObjectPropertyAddress address = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
#if defined(MAC_OS_VERSION_12_0) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_12_0)
kAudioObjectPropertyElementMain
#else
kAudioObjectPropertyElementMaster
#endif
};
UInt32 device_size_bytes = 0;