From 874c15a90a6aeeb436798994b261a3fddcaa4652 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Wed, 20 Mar 2024 10:06:51 +0800 Subject: [PATCH] ao_avfoundation: handle case when ao_read_data returns zero samples --- audio/out/ao_avfoundation.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio/out/ao_avfoundation.m b/audio/out/ao_avfoundation.m index b8fff08036fea..9b6511afc2686 100644 --- a/audio/out/ao_avfoundation.m +++ b/audio/out/ao_avfoundation.m @@ -98,6 +98,10 @@ static void feed(struct ao *ao) if (real_sample_count == 0) { // in this case, we must satisfy renderer to avoid spining real_sample_count = ao_read_data(ao, data, request_sample_count, p->end_time_mp); + if (real_sample_count == 0) { + // ao_read_data may still return zero? + real_sample_count = request_sample_count; + } } CMSampleTimingInfo sample_timing_into[] = {(CMSampleTimingInfo) {