From bc5ab97d9a3c2fa28a942e0a09908aced1055e2a Mon Sep 17 00:00:00 2001 From: der richter Date: Sat, 15 Jun 2024 16:51:08 +0200 Subject: [PATCH] ao_avfoundation: guard features only available on macOS 11.3 and 12 build time and runtime checks. --- audio/out/ao_avfoundation.m | 8 +++++++- meson.build | 6 ++++++ meson_options.txt | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/audio/out/ao_avfoundation.m b/audio/out/ao_avfoundation.m index 2e7d194b25..94731a7670 100644 --- a/audio/out/ao_avfoundation.m +++ b/audio/out/ao_avfoundation.m @@ -254,9 +254,11 @@ static int init(struct ao *ao) } [p->synchronizer addRenderer:p->renderer]; +#if HAVE_MACOS_11_3_FEATURES if (@available(tvOS 14.5, iOS 14.5, macOS 11.3, *)) { [p->synchronizer setDelaysRateChangeUntilHasSufficientMediaData:NO]; } +#endif if (af_fmt_is_spdif(ao->format)) { MP_FATAL(ao, "avfoundation does not support SPDIF\n"); @@ -315,7 +317,11 @@ static int init(struct ao *ao) p->observer = [[AVObserver alloc] initWithAO:ao]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserver:p->observer selector:@selector(handleRestartNotification:) name:AVSampleBufferAudioRendererOutputConfigurationDidChangeNotification object:p->renderer]; +#if HAVE_MACOS_12_FEATURES + if (@available(tvOS 15.0, iOS 15.0, macOS 12.0, *)) { + [center addObserver:p->observer selector:@selector(handleRestartNotification:) name:AVSampleBufferAudioRendererOutputConfigurationDidChangeNotification object:p->renderer]; + } +#endif [center addObserver:p->observer selector:@selector(handleRestartNotification:) name:AVSampleBufferAudioRendererWasFlushedAutomaticallyNotification object:p->renderer]; return CONTROL_OK; diff --git a/meson.build b/meson.build index 455e9edde2..6b2bcec546 100644 --- a/meson.build +++ b/meson.build @@ -1587,6 +1587,12 @@ macos_11_features = get_option('macos-11-features').require( ) features += {'macos-11-features': macos_11_features.allowed()} +macos_11_3_features = get_option('macos-11-3-features').require( + macos_sdk_version.version_compare('>= 11.3'), + error_message: 'A macos sdk version >= 11.3 could not be found!', +) +features += {'macos-11-3-features': macos_11_3_features.allowed()} + macos_12_features = get_option('macos-12-features').require( macos_sdk_version.version_compare('>= 12'), error_message: 'A macos sdk version >= 12 could not be found!', diff --git a/meson_options.txt b/meson_options.txt index 53c6ac3c0f..771e66334b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -108,6 +108,7 @@ option('vulkan-interop', type: 'feature', value: 'auto', description: 'Vulkan gr # macOS features option('macos-10-15-4-features', type: 'feature', value: 'auto', description: 'macOS 10.15.4 SDK Features') option('macos-11-features', type: 'feature', value: 'auto', description: 'macOS 11 SDK Features') +option('macos-11-3-features', type: 'feature', value: 'auto', description: 'macOS 11.3 SDK Features') option('macos-12-features', type: 'feature', value: 'auto', description: 'macOS 12 SDK Features') option('macos-cocoa-cb', type: 'feature', value: 'auto', description: 'macOS libmpv backend') option('macos-media-player', type: 'feature', value: 'auto', description: 'macOS Media Player support')