mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MacOS: Fix API deprecations in macOS 12.0 and iOS 15.0
This commit is contained in:
parent
7d349fd68f
commit
a70488e38e
10 changed files with 73 additions and 32 deletions
|
|
@ -31,6 +31,13 @@ namespace juce
|
|||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wnonnull")
|
||||
|
||||
constexpr auto juceAudioObjectPropertyElementMain =
|
||||
#if defined (MAC_OS_VERSION_12_0)
|
||||
kAudioObjectPropertyElementMain;
|
||||
#else
|
||||
kAudioObjectPropertyElementMaster;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
struct SystemVol
|
||||
{
|
||||
|
|
@ -38,7 +45,7 @@ struct SystemVol
|
|||
: outputDeviceID (kAudioObjectUnknown)
|
||||
{
|
||||
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
||||
addr.mElement = kAudioObjectPropertyElementMaster;
|
||||
addr.mElement = juceAudioObjectPropertyElementMain;
|
||||
addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
||||
|
||||
if (AudioObjectHasProperty (kAudioObjectSystemObject, &addr))
|
||||
|
|
@ -48,7 +55,7 @@ struct SystemVol
|
|||
|
||||
if (status == noErr)
|
||||
{
|
||||
addr.mElement = kAudioObjectPropertyElementMaster;
|
||||
addr.mElement = juceAudioObjectPropertyElementMain;
|
||||
addr.mSelector = selector;
|
||||
addr.mScope = kAudioDevicePropertyScopeOutput;
|
||||
|
||||
|
|
@ -123,9 +130,16 @@ private:
|
|||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
|
||||
constexpr auto juceAudioHardwareServiceDeviceProperty_VirtualMainVolume =
|
||||
#if defined (MAC_OS_VERSION_12_0)
|
||||
kAudioHardwareServiceDeviceProperty_VirtualMainVolume;
|
||||
#else
|
||||
kAudioHardwareServiceDeviceProperty_VirtualMasterVolume;
|
||||
#endif
|
||||
|
||||
#define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1
|
||||
float JUCE_CALLTYPE SystemAudioVolume::getGain() { return SystemVol (kAudioHardwareServiceDeviceProperty_VirtualMasterVolume).getGain(); }
|
||||
bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return SystemVol (kAudioHardwareServiceDeviceProperty_VirtualMasterVolume).setGain (gain); }
|
||||
float JUCE_CALLTYPE SystemAudioVolume::getGain() { return SystemVol (juceAudioHardwareServiceDeviceProperty_VirtualMainVolume).getGain(); }
|
||||
bool JUCE_CALLTYPE SystemAudioVolume::setGain (float gain) { return SystemVol (juceAudioHardwareServiceDeviceProperty_VirtualMainVolume).setGain (gain); }
|
||||
bool JUCE_CALLTYPE SystemAudioVolume::isMuted() { return SystemVol (kAudioDevicePropertyMute).isMuted(); }
|
||||
bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool mute) { return SystemVol (kAudioDevicePropertyMute).setMuted (mute); }
|
||||
|
||||
|
|
@ -204,7 +218,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (OK (AudioObjectGetPropertyDataSize (deviceID, &pa, 0, nullptr, &size)))
|
||||
{
|
||||
|
|
@ -259,7 +273,7 @@ public:
|
|||
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
|
||||
UInt32 size = 0;
|
||||
|
||||
|
|
@ -300,7 +314,7 @@ public:
|
|||
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
|
||||
UInt32 size = 0;
|
||||
|
||||
|
|
@ -341,7 +355,7 @@ public:
|
|||
UInt32 latency = 0;
|
||||
UInt32 size = sizeof (latency);
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioDevicePropertyLatency;
|
||||
pa.mScope = scope;
|
||||
AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, &latency);
|
||||
|
|
@ -357,7 +371,7 @@ public:
|
|||
int getBitDepthFromDevice (AudioObjectPropertyScope scope) const
|
||||
{
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioStreamPropertyPhysicalFormat;
|
||||
pa.mScope = scope;
|
||||
|
||||
|
|
@ -374,7 +388,7 @@ public:
|
|||
{
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioDevicePropertyBufferFrameSize;
|
||||
|
||||
UInt32 framesPerBuf = (UInt32) bufferSize;
|
||||
|
|
@ -387,7 +401,7 @@ public:
|
|||
{
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
pa.mSelector = kAudioDevicePropertyDeviceIsAlive;
|
||||
|
||||
UInt32 isAlive = 0;
|
||||
|
|
@ -503,7 +517,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyDataSourceNameForID;
|
||||
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &transSize, &avt)))
|
||||
s.add (buffer);
|
||||
|
|
@ -521,7 +535,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyDataSource;
|
||||
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (deviceID != 0)
|
||||
{
|
||||
|
|
@ -556,7 +570,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyDataSource;
|
||||
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
OSType typeId = types[index];
|
||||
|
||||
|
|
@ -570,7 +584,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyNominalSampleRate;
|
||||
pa.mScope = kAudioObjectPropertyScopeGlobal;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
Float64 sr = 0;
|
||||
UInt32 size = (UInt32) sizeof (sr);
|
||||
return OK (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, &sr)) ? (double) sr : 0.0;
|
||||
|
|
@ -584,7 +598,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyNominalSampleRate;
|
||||
pa.mScope = kAudioObjectPropertyScopeGlobal;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
Float64 sr = newSampleRate;
|
||||
return OK (AudioObjectSetPropertyData (deviceID, &pa, 0, nullptr, sizeof (sr), &sr));
|
||||
}
|
||||
|
|
@ -626,7 +640,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyBufferFrameSize;
|
||||
pa.mScope = kAudioObjectPropertyScopeGlobal;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
UInt32 framesPerBuf = (UInt32) bufferSizeSamples;
|
||||
|
||||
if (! OK (AudioObjectSetPropertyData (deviceID, &pa, 0, nullptr, sizeof (framesPerBuf), &framesPerBuf)))
|
||||
|
|
@ -715,7 +729,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyDeviceIsRunning;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
OK (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, &running));
|
||||
|
||||
|
|
@ -893,7 +907,7 @@ private:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyDataSources;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
UInt32 size = 0;
|
||||
|
||||
if (deviceID != 0
|
||||
|
|
@ -2040,7 +2054,7 @@ public:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioHardwarePropertyDevices;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (AudioObjectGetPropertyDataSize (kAudioObjectSystemObject, &pa, 0, nullptr, &size) == noErr)
|
||||
{
|
||||
|
|
@ -2105,7 +2119,7 @@ public:
|
|||
pa.mSelector = forInput ? kAudioHardwarePropertyDefaultInputDevice
|
||||
: kAudioHardwarePropertyDefaultOutputDevice;
|
||||
pa.mScope = kAudioObjectPropertyScopeWildcard;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, nullptr, &size, &deviceID) == noErr)
|
||||
{
|
||||
|
|
@ -2213,7 +2227,7 @@ private:
|
|||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
||||
pa.mElement = kAudioObjectPropertyElementMaster;
|
||||
pa.mElement = juceAudioObjectPropertyElementMain;
|
||||
|
||||
if (AudioObjectGetPropertyDataSize (deviceID, &pa, 0, nullptr, &size) == noErr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,14 +119,19 @@ SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
|
|||
const auto major = parts[0].getIntValue();
|
||||
const auto minor = parts[1].getIntValue();
|
||||
|
||||
if (major == 10)
|
||||
switch (major)
|
||||
{
|
||||
jassert (minor > 2);
|
||||
return (OperatingSystemType) (minor + MacOSX_10_7 - 7);
|
||||
case 10:
|
||||
{
|
||||
jassert (minor > 2);
|
||||
return (OperatingSystemType) (minor + MacOSX_10_7 - 7);
|
||||
}
|
||||
|
||||
case 11: return MacOS_11;
|
||||
case 12: return MacOS_12;
|
||||
}
|
||||
|
||||
jassert (major == 11);
|
||||
return MacOS_11;
|
||||
return UnknownOS;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ String SystemStats::getOperatingSystemName()
|
|||
case MacOSX_10_14: JUCE_FALLTHROUGH
|
||||
case MacOSX_10_15: JUCE_FALLTHROUGH
|
||||
case MacOS_11: JUCE_FALLTHROUGH
|
||||
case MacOS_12: JUCE_FALLTHROUGH
|
||||
|
||||
case UnknownOS: JUCE_FALLTHROUGH
|
||||
case WASM: JUCE_FALLTHROUGH
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public:
|
|||
MacOSX_10_14 = MacOSX | 14,
|
||||
MacOSX_10_15 = MacOSX | 15,
|
||||
MacOS_11 = MacOSX | 16,
|
||||
MacOS_12 = MacOSX | 17,
|
||||
|
||||
Win2000 = Windows | 1,
|
||||
WinXP = Windows | 2,
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ String JUCEApplicationBase::getCommandLineParameters()
|
|||
|
||||
for (int i = 1; i < juce_argc; ++i)
|
||||
{
|
||||
String arg (juce_argv[i]);
|
||||
String arg { CharPointer_UTF8 (juce_argv[i]) };
|
||||
|
||||
if (arg.containsChar (' ') && ! arg.isQuotedString())
|
||||
arg = arg.quoted ('"');
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
#if ! (defined (__IPHONE_15_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_15_0)
|
||||
#if ! (defined (__IPHONE_16_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_16_0)
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
#define JUCE_DEPRECATION_IGNORED 1
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ static UIInterfaceOrientation getWindowOrientation()
|
|||
UIApplication* sharedApplication = [UIApplication sharedApplication];
|
||||
|
||||
#if (defined (__IPHONE_13_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_13_0)
|
||||
return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation];
|
||||
for (UIScene* scene in [sharedApplication connectedScenes])
|
||||
if ([scene isKindOfClass: [UIWindowScene class]])
|
||||
return [(UIWindowScene*) scene interfaceOrientation];
|
||||
|
||||
return UIInterfaceOrientationPortrait;
|
||||
#else
|
||||
return [sharedApplication statusBarOrientation];
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -83,7 +83,9 @@ public:
|
|||
filters.removeEmptyStrings();
|
||||
|
||||
[panel setTitle: juceStringToNS (owner.title)];
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
[panel setAllowedFileTypes: createAllowedTypesArray (filters)];
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
|
||||
if (! isSave)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1309,7 +1309,14 @@ public:
|
|||
|
||||
static NSArray* getSupportedDragTypes()
|
||||
{
|
||||
return [NSArray arrayWithObjects: (NSString*) kUTTypeFileURL, (NSString*) kPasteboardTypeFileURLPromise, NSPasteboardTypeString, nil];
|
||||
const auto type =
|
||||
#if defined (MAC_OS_X_VERSION_10_13) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_13
|
||||
NSPasteboardTypeFileURL;
|
||||
#else
|
||||
kUTTypeFileURL;
|
||||
#endif
|
||||
|
||||
return [NSArray arrayWithObjects: (NSString*) type, (NSString*) kPasteboardTypeFileURLPromise, NSPasteboardTypeString, nil];
|
||||
}
|
||||
|
||||
BOOL sendDragCallback (const int type, id <NSDraggingInfo> sender)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,14 @@ namespace
|
|||
io_iterator_t iter = 0;
|
||||
io_object_t iod = 0;
|
||||
|
||||
if (IOServiceGetMatchingServices (kIOMasterPortDefault, dict, &iter) == kIOReturnSuccess
|
||||
const auto defaultPort =
|
||||
#if defined (MAC_OS_VERSION_12_0) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_12_0
|
||||
kIOMainPortDefault;
|
||||
#else
|
||||
kIOMasterPortDefault;
|
||||
#endif
|
||||
|
||||
if (IOServiceGetMatchingServices (defaultPort, dict, &iter) == kIOReturnSuccess
|
||||
&& iter != 0)
|
||||
{
|
||||
iod = IOIteratorNext (iter);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue