mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +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:
parent
89c717559b
commit
d908fbd584
@ -205,6 +205,7 @@ const struct ao_driver audio_out_sdl = {
|
|||||||
.uninit = uninit,
|
.uninit = uninit,
|
||||||
.reset = reset,
|
.reset = reset,
|
||||||
.resume = resume,
|
.resume = resume,
|
||||||
|
.reports_underruns = true,
|
||||||
.priv_size = sizeof(struct priv),
|
.priv_size = sizeof(struct priv),
|
||||||
.priv_defaults = &(const struct priv) {
|
.priv_defaults = &(const struct priv) {
|
||||||
.buflen = 0, // use SDL default
|
.buflen = 0, // use SDL default
|
||||||
|
@ -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]);
|
int buffered_bytes = mp_ring_buffered(p->buffers[0]);
|
||||||
bytes = MPMIN(buffered_bytes, full_bytes);
|
bytes = MPMIN(buffered_bytes, full_bytes);
|
||||||
|
|
||||||
if (full_bytes > bytes && !atomic_load(&p->draining))
|
if (full_bytes > bytes && !atomic_load(&p->draining)) {
|
||||||
atomic_fetch_add(&p->underflow, (full_bytes - bytes) / ao->sstride);
|
if (ao->driver->reports_underruns) {
|
||||||
|
ao_underrun_event(ao);
|
||||||
|
} else {
|
||||||
|
atomic_fetch_add(&p->underflow, (full_bytes - bytes) / ao->sstride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
atomic_store(&p->end_time_us, out_time_us);
|
atomic_store(&p->end_time_us, out_time_us);
|
||||||
|
Loading…
Reference in New Issue
Block a user