Skip to content

Commit

Permalink
ao_coreaudio: signal buffer underruns
Browse files Browse the repository at this point in the history
Change the resulting buffer sizes to match the actual amount of samples
read, and set a flag in case no samples were read at all.
  • Loading branch information
handlerug authored and sfan5 committed Oct 29, 2023
1 parent 1888591 commit 0341a6f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion audio/out/ao_coreaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags,

int64_t end = mp_time_ns();
end += p->hw_latency_ns + ca_get_latency(ts) + ca_frames_to_ns(ao, frames);
ao_read_data(ao, planes, frames, end);
int samples = ao_read_data(ao, planes, frames, end);

if (samples == 0)
*aflags |= kAudioUnitRenderAction_OutputIsSilence;

for (int n = 0; n < buffer_list->mNumberBuffers; n++)
buffer_list->mBuffers[n].mDataByteSize = samples * ao->sstride;

return noErr;
}

Expand Down

0 comments on commit 0341a6f

Please sign in to comment.