1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 08:12:17 +00:00

audio/out/pull, ao_sdl: implement new underrun reporting

See previous commits. ao_sdl is worthless, but it might be a good test
for pull-based AOs.

This stops using the old underrun reporting if the new one is enabled.
Also, since the AO's behavior can in theory not be according to
expectations, this needs to be enabled for every single pull AO
separately.

For some reason, in certain cases I get multiple underrun warnings while
cache-pausing is active. It fills the cache, restarts the AO,
immediately underruns again, and then fills the cache again. I'm not
sure why this happens; maybe ao_sdl tries to catch up when it shouldn't.
Who knows.
This commit is contained in:
wm4 2019-10-11 20:01:23 +02:00
parent 89c717559b
commit d908fbd584
2 changed files with 8 additions and 2 deletions

View File

@ -205,6 +205,7 @@ const struct ao_driver audio_out_sdl = {
.uninit = uninit,
.reset = reset,
.resume = resume,
.reports_underruns = true,
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.buflen = 0, // use SDL default

View File

@ -153,8 +153,13 @@ int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_us)
int buffered_bytes = mp_ring_buffered(p->buffers[0]);
bytes = MPMIN(buffered_bytes, full_bytes);
if (full_bytes > bytes && !atomic_load(&p->draining))
atomic_fetch_add(&p->underflow, (full_bytes - bytes) / ao->sstride);
if (full_bytes > bytes && !atomic_load(&p->draining)) {
if (ao->driver->reports_underruns) {
ao_underrun_event(ao);
} else {
atomic_fetch_add(&p->underflow, (full_bytes - bytes) / ao->sstride);
}
}
if (bytes > 0)
atomic_store(&p->end_time_us, out_time_us);