summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_avfoundation.m
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out/ao_avfoundation.m')
-rw-r--r--audio/out/ao_avfoundation.m19
1 files changed, 14 insertions, 5 deletions
diff --git a/audio/out/ao_avfoundation.m b/audio/out/ao_avfoundation.m
index 7654916519..94731a7670 100644
--- a/audio/out/ao_avfoundation.m
+++ b/audio/out/ao_avfoundation.m
@@ -76,11 +76,14 @@ static void feed(struct ao *ao)
int64_t cur_time_mp = mp_time_ns();
int64_t end_time_av = MPMAX(p->end_time_av, cur_time_av);
int64_t time_delta = CMTimeGetNanoseconds(CMTimeMake(request_sample_count, samplerate));
- int real_sample_count = ao_read_data_nonblocking(ao, data, request_sample_count, end_time_av - cur_time_av + cur_time_mp + time_delta);
+ bool eof;
+ int real_sample_count = ao_read_data(ao, data, request_sample_count, end_time_av - cur_time_av + cur_time_mp + time_delta, &eof, false, true);
+ if (eof) {
+ [p->renderer stopRequestingMediaData];
+ ao_stop_streaming(ao);
+ }
if (real_sample_count == 0) {
- // avoid spinning by blocking the thread
- mp_sleep_ns(10000000);
- goto finish;
+ return;
}
if ((err = CMBlockBufferCreateWithMemoryBlock(
@@ -251,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");
@@ -312,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;