From 37875831a06acb651bfb545b3482281a0bb90caa Mon Sep 17 00:00:00 2001 From: David Hampton Date: Fri, 22 Apr 2022 12:15:14 -0400 Subject: [PATCH] OSX: Handle constants deprecated in 12.0. --- mythtv/libs/libmyth/audio/audiooutputca.cpp | 43 +++++++++++-------- .../libmythbase/platforms/mythpowerosx.cpp | 7 ++- mythtv/libs/libmythui/devices/AppleRemote.cpp | 7 ++- .../libmythui/platforms/mythutilscocoa.mm | 7 ++- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/mythtv/libs/libmyth/audio/audiooutputca.cpp b/mythtv/libs/libmyth/audio/audiooutputca.cpp index 49e3e2b34bc..3d29c6b306b 100644 --- a/mythtv/libs/libmyth/audio/audiooutputca.cpp +++ b/mythtv/libs/libmyth/audio/audiooutputca.cpp @@ -19,11 +19,16 @@ #include #include #include +#include #include "mythcorecontext.h" #include "audiooutputca.h" #include "SoundTouch.h" +#if !defined(MAC_OS_VERSION_12_0) +#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster +#endif + #define LOC QString("CoreAudio: ") #define CHANNELS_MIN 1 @@ -545,7 +550,7 @@ AudioDeviceID CoreAudioData::GetDeviceWithName(const QString &deviceName) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, @@ -599,7 +604,7 @@ AudioDeviceID CoreAudioData::GetDefaultOutputDevice() { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; // Find the ID of the default Device @@ -627,7 +632,7 @@ int CoreAudioData::GetTotalOutputChannels() { kAudioDevicePropertyStreamConfiguration, kAudioDevicePropertyScopeOutput, // Scope needs to be set to output to find output streams - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyDataSize(mDeviceID, &pa, @@ -671,7 +676,7 @@ QString *CoreAudioData::GetName() { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; CFStringRef name; @@ -699,7 +704,7 @@ bool CoreAudioData::GetAutoHogMode() { kAudioHardwarePropertyHogModeIsAllowed, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, &size, &val); @@ -719,7 +724,7 @@ void CoreAudioData::SetAutoHogMode(bool enable) { kAudioHardwarePropertyHogModeIsAllowed, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, @@ -739,7 +744,7 @@ pid_t CoreAudioData::GetHogStatus() { kAudioDevicePropertyHogMode, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, @@ -761,7 +766,7 @@ bool CoreAudioData::SetHogStatus(bool hog) { kAudioDevicePropertyHogMode, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; // According to Jeff Moore (Core Audio, Apple), Setting kAudioDevicePropertyHogMode @@ -825,7 +830,7 @@ bool CoreAudioData::SetMixingSupport(bool mix) { kAudioDevicePropertySupportsMixing, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectSetPropertyData(mDeviceID, &pa, 0, nullptr, sizeof(mixEnable), &mixEnable); @@ -851,7 +856,7 @@ bool CoreAudioData::GetMixingSupport() { kAudioDevicePropertySupportsMixing, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyData(mDeviceID, &pa, 0, nullptr, &size, &val); @@ -873,7 +878,7 @@ AudioStreamIDVec CoreAudioData::StreamsList(AudioDeviceID d) { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; err = AudioObjectGetPropertyDataSize(d, &pa, @@ -919,7 +924,7 @@ AudioStreamRangedVec CoreAudioData::FormatsList(AudioStreamID s) // Bugfix: kAudioStreamPropertyPhysicalFormats, is meant to only give array of AudioStreamBasicDescription kAudioStreamPropertyAvailablePhysicalFormats, // gives array of AudioStreamRangedDescription kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; // Retrieve all the stream formats supported by this output stream @@ -981,7 +986,7 @@ RatesVec CoreAudioData::RatesList(AudioDeviceID d) { kAudioDevicePropertyAvailableNominalSampleRates, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; // retrieve size of rate list @@ -1113,7 +1118,7 @@ int CoreAudioData::OpenAnalog() { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; Debug("OpenAnalog: Entering"); @@ -1505,7 +1510,7 @@ bool CoreAudioData::OpenSPDIF() { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; // Retrieve the original format of this stream first @@ -1622,7 +1627,7 @@ int CoreAudioData::AudioStreamChangeFormat(AudioStreamID s, { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectSetPropertyData(s, &pa, 0, nullptr, sizeof(format), &format); @@ -1676,7 +1681,7 @@ void CoreAudioData::ResetAudioDevices() { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, @@ -1722,7 +1727,7 @@ void CoreAudioData::ResetStream(AudioStreamID s) { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; @@ -1771,7 +1776,7 @@ QMap *AudioOutputCA::GetDevices(const char */*type*/) { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster + kAudioObjectPropertyElementMain }; OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa, diff --git a/mythtv/libs/libmythbase/platforms/mythpowerosx.cpp b/mythtv/libs/libmythbase/platforms/mythpowerosx.cpp index b3e3d083249..60e4903be1e 100644 --- a/mythtv/libs/libmythbase/platforms/mythpowerosx.cpp +++ b/mythtv/libs/libmythbase/platforms/mythpowerosx.cpp @@ -6,6 +6,11 @@ // OSX #include #include +#include + +#if !defined(MAC_OS_VERSION_12_0) +#define kIOMainPortDefault kIOMasterPortDefault +#endif #define LOC QString("PowerOSX: ") @@ -60,7 +65,7 @@ void MythPowerOSX::Init(void) // Is there a battery? CFArrayRef batteryinfo = NULL; - if (IOPMCopyBatteryInfo(kIOMasterPortDefault, &batteryinfo) == kIOReturnSuccess) + if (IOPMCopyBatteryInfo(kIOMainPortDefault, &batteryinfo) == kIOReturnSuccess) { CFRelease(batteryinfo); diff --git a/mythtv/libs/libmythui/devices/AppleRemote.cpp b/mythtv/libs/libmythui/devices/AppleRemote.cpp index f1c7919f0f1..04069d53d41 100644 --- a/mythtv/libs/libmythui/devices/AppleRemote.cpp +++ b/mythtv/libs/libmythui/devices/AppleRemote.cpp @@ -17,11 +17,16 @@ #include #include #include // for Gestalt +#include #include #include "mythlogging.h" +#if !defined(MAC_OS_VERSION_12_0) +#define kIOMainPortDefault kIOMasterPortDefault +#endif + AppleRemote* AppleRemote::_instance = nullptr; @@ -188,7 +193,7 @@ static io_object_t _findAppleRemoteDevice(const char *devName) hidMatchDictionary = IOServiceMatching(devName); // check for matching devices - ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, + ioReturnValue = IOServiceGetMatchingServices(kIOMainPortDefault, hidMatchDictionary, &hidObjectIterator); diff --git a/mythtv/libs/libmythui/platforms/mythutilscocoa.mm b/mythtv/libs/libmythui/platforms/mythutilscocoa.mm index 037f3fc1b1f..98b054f9874 100644 --- a/mythtv/libs/libmythui/platforms/mythutilscocoa.mm +++ b/mythtv/libs/libmythui/platforms/mythutilscocoa.mm @@ -4,6 +4,11 @@ // OSX #import #import +#include + +#if !defined(MAC_OS_VERSION_12_0) +#define kIOMainPortDefault kIOMasterPortDefault +#endif CGDirectDisplayID GetOSXCocoaDisplay(void* View) { @@ -39,7 +44,7 @@ QByteArray GetOSXEDID(CGDirectDisplayID Display) CFMutableDictionaryRef matching = IOServiceMatching("IODisplayConnect"); io_iterator_t iter; - if (IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iter)) + if (IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter)) return result; io_service_t service = 0;