Skip to content

Commit

Permalink
OSX: Handle constants deprecated in 12.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Apr 22, 2022
1 parent 3bc09b4 commit 3787583
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
43 changes: 24 additions & 19 deletions mythtv/libs/libmyth/audio/audiooutputca.cpp
Expand Up @@ -19,11 +19,16 @@
#include <CoreAudio/CoreAudio.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioFormat.h>
#include <AvailabilityMacros.h>

#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
Expand Down Expand Up @@ -545,7 +550,7 @@ AudioDeviceID CoreAudioData::GetDeviceWithName(const QString &deviceName)
{
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa,
Expand Down Expand Up @@ -599,7 +604,7 @@ AudioDeviceID CoreAudioData::GetDefaultOutputDevice()
{
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

// Find the ID of the default Device
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -671,7 +676,7 @@ QString *CoreAudioData::GetName()
{
kAudioObjectPropertyName,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

CFStringRef name;
Expand Down Expand Up @@ -699,7 +704,7 @@ bool CoreAudioData::GetAutoHogMode()
{
kAudioHardwarePropertyHogModeIsAllowed,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr, &size, &val);
Expand All @@ -719,7 +724,7 @@ void CoreAudioData::SetAutoHogMode(bool enable)
{
kAudioHardwarePropertyHogModeIsAllowed,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr,
Expand All @@ -739,7 +744,7 @@ pid_t CoreAudioData::GetHogStatus()
{
kAudioDevicePropertyHogMode,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &pa, 0, nullptr,
Expand All @@ -761,7 +766,7 @@ bool CoreAudioData::SetHogStatus(bool hog)
{
kAudioDevicePropertyHogMode,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

// According to Jeff Moore (Core Audio, Apple), Setting kAudioDevicePropertyHogMode
Expand Down Expand Up @@ -825,7 +830,7 @@ bool CoreAudioData::SetMixingSupport(bool mix)
{
kAudioDevicePropertySupportsMixing,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};
OSStatus err = AudioObjectSetPropertyData(mDeviceID, &pa, 0, nullptr,
sizeof(mixEnable), &mixEnable);
Expand All @@ -851,7 +856,7 @@ bool CoreAudioData::GetMixingSupport()
{
kAudioDevicePropertySupportsMixing,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};
OSStatus err = AudioObjectGetPropertyData(mDeviceID, &pa, 0, nullptr,
&size, &val);
Expand All @@ -873,7 +878,7 @@ AudioStreamIDVec CoreAudioData::StreamsList(AudioDeviceID d)
{
kAudioDevicePropertyStreams,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

err = AudioObjectGetPropertyDataSize(d, &pa,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -981,7 +986,7 @@ RatesVec CoreAudioData::RatesList(AudioDeviceID d)
{
kAudioDevicePropertyAvailableNominalSampleRates,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

// retrieve size of rate list
Expand Down Expand Up @@ -1113,7 +1118,7 @@ int CoreAudioData::OpenAnalog()
{
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

Debug("OpenAnalog: Entering");
Expand Down Expand Up @@ -1505,7 +1510,7 @@ bool CoreAudioData::OpenSPDIF()
{
kAudioStreamPropertyPhysicalFormat,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

// Retrieve the original format of this stream first
Expand Down Expand Up @@ -1622,7 +1627,7 @@ int CoreAudioData::AudioStreamChangeFormat(AudioStreamID s,
{
kAudioStreamPropertyPhysicalFormat,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};
OSStatus err = AudioObjectSetPropertyData(s, &pa, 0, nullptr,
sizeof(format), &format);
Expand Down Expand Up @@ -1676,7 +1681,7 @@ void CoreAudioData::ResetAudioDevices()
{
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa,
Expand Down Expand Up @@ -1722,7 +1727,7 @@ void CoreAudioData::ResetStream(AudioStreamID s)
{
kAudioStreamPropertyPhysicalFormat,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};


Expand Down Expand Up @@ -1771,7 +1776,7 @@ QMap<QString, QString> *AudioOutputCA::GetDevices(const char */*type*/)
{
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
kAudioObjectPropertyElementMain
};

OSStatus err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &pa,
Expand Down
7 changes: 6 additions & 1 deletion mythtv/libs/libmythbase/platforms/mythpowerosx.cpp
Expand Up @@ -6,6 +6,11 @@
// OSX
#include <IOKit/ps/IOPowerSources.h>
#include <IOKit/ps/IOPSKeys.h>
#include <AvailabilityMacros.h>

#if !defined(MAC_OS_VERSION_12_0)
#define kIOMainPortDefault kIOMasterPortDefault
#endif

#define LOC QString("PowerOSX: ")

Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion mythtv/libs/libmythui/devices/AppleRemote.cpp
Expand Up @@ -17,11 +17,16 @@
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h> // for Gestalt
#include <AvailabilityMacros.h>

#include <sstream>

#include "mythlogging.h"

#if !defined(MAC_OS_VERSION_12_0)
#define kIOMainPortDefault kIOMasterPortDefault
#endif

AppleRemote* AppleRemote::_instance = nullptr;


Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion mythtv/libs/libmythui/platforms/mythutilscocoa.mm
Expand Up @@ -4,6 +4,11 @@
// OSX
#import <Cocoa/Cocoa.h>
#import <IOKit/graphics/IOGraphicsLib.h>
#include <AvailabilityMacros.h>

#if !defined(MAC_OS_VERSION_12_0)
#define kIOMainPortDefault kIOMasterPortDefault
#endif

CGDirectDisplayID GetOSXCocoaDisplay(void* View)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3787583

Please sign in to comment.