Browse Source

macOS: Fix deprecations in macOS 14.0

v7.0.9
reuk 2 years ago
parent
commit
f0aacca62c
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
2 changed files with 27 additions and 2 deletions
  1. +14
    -0
      modules/juce_gui_basics/native/juce_Windowing_mac.mm
  2. +13
    -2
      modules/juce_video/native/juce_CameraDevice_mac.h

+ 14
- 0
modules/juce_gui_basics/native/juce_Windowing_mac.mm View File

@@ -510,11 +510,25 @@ static Image createNSWindowSnapshot (NSWindow* nsWindow)
{
JUCE_AUTORELEASEPOOL
{
// CGWindowListCreateImage is replaced by functions in the ScreenCaptureKit framework, but
// that framework is only available from macOS 12.3 onwards.
// A suitable @available check should be added once the minimum build OS is 12.3 or greater,
// so that ScreenCaptureKit can be weak-linked.
#if defined (MAC_OS_VERSION_14_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
#define JUCE_DEPRECATION_IGNORED 1
#endif
CGImageRef screenShot = CGWindowListCreateImage (CGRectNull,
kCGWindowListOptionIncludingWindow,
(CGWindowID) [nsWindow windowNumber],
kCGWindowImageBoundsIgnoreFraming);
#if JUCE_DEPRECATION_IGNORED
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
#undef JUCE_DEPRECATION_IGNORED
#endif
NSBitmapImageRep* bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: screenShot];
Image result (Image::ARGB, (int) [bitmapRep size].width, (int) [bitmapRep size].height, true);


+ 13
- 2
modules/juce_video/native/juce_CameraDevice_mac.h View File

@@ -146,8 +146,19 @@ struct CameraDevice::Pimpl
#if JUCE_USE_NEW_CAMERA_API
if (@available (macOS 10.15, *))
{
auto* discovery = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes: @[AVCaptureDeviceTypeBuiltInWideAngleCamera,
AVCaptureDeviceTypeExternalUnknown]
const auto deviceType = [&]
{
#if defined (MAC_OS_VERSION_14_0) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0
if (@available (macOS 14.0, *))
return AVCaptureDeviceTypeExternal;
#endif
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations", "-Wunguarded-availability-new")
return AVCaptureDeviceTypeExternalUnknown;
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
}();
auto* discovery = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes: @[AVCaptureDeviceTypeBuiltInWideAngleCamera, deviceType]
mediaType: AVMediaTypeVideo
position: AVCaptureDevicePositionUnspecified];


Loading…
Cancel
Save