ao_avfoundation: add EOF handling

This commit is contained in:
Misaki Kasumi 2024-04-22 19:49:22 +08:00 committed by sfan5
parent aebe58203b
commit eb996a13bc
1 changed files with 7 additions and 4 deletions

View File

@ -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(ao, data, request_sample_count, end_time_av - cur_time_av + cur_time_mp + time_delta, NULL, false, false);
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, false);
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(