summaryrefslogtreecommitdiffstats
path: root/audio/out/internal.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-11 19:25:45 +0200
committerwm4 <wm4@nowhere>2019-10-11 19:25:45 +0200
commitc84ec021287d72d122071d5c211f9bfbeb13a3fe (patch)
tree563612b5ecef18b9d26889445cbd53914e184b62 /audio/out/internal.h
parent52f3dee16a81ca4ed4d3a5a12e5f4fbf74cc3ddb (diff)
downloadmpv-c84ec021287d72d122071d5c211f9bfbeb13a3fe.tar.bz2
mpv-c84ec021287d72d122071d5c211f9bfbeb13a3fe.tar.xz
ao: add API for underrun reporting
AOs can now call ao_underrun_event() (in any context) if an underrun has happened. It will print a message. This will be used in the following commits. But for now, audio.c only clears the underrun bit, so that subsequent underruns still print the warning message. Since the underrun flag will be used in fragile ways by the playback state machine, there is the "reports_underruns" field that signals strong support for underrun reporting. (Otherwise, underrun events will not be used by it.)
Diffstat (limited to 'audio/out/internal.h')
-rw-r--r--audio/out/internal.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/audio/out/internal.h b/audio/out/internal.h
index bf769d7e1c..807f124a17 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -68,7 +68,7 @@ struct ao {
char *redirect;
// Internal events (use ao_request_reload(), ao_hotplug_event())
- atomic_int events_;
+ atomic_uint events_;
// Float gain multiplicator
mp_atomic_float gain;
@@ -134,6 +134,11 @@ struct ao_driver {
// first play() call is done. Encode mode uses this, and push mode
// respects it automatically (don't use with pull mode).
bool initially_blocked;
+ // Whether underruns are strictly _always_ reported via ao_underrun_event().
+ // Do not set this to true if underruns may be missed in some way. If the
+ // AO can't guarantee to play silence after underruns, it may be better not
+ // to set this.
+ bool reports_underruns;
// Init the device using ao->format/ao->channels/ao->samplerate. If the
// device doesn't accept these parameters, you can attempt to negotiate
// fallback parameters, and set the ao format fields accordingly.
@@ -206,6 +211,7 @@ struct pollfd;
int ao_wait_poll(struct ao *ao, struct pollfd *fds, int num_fds,
pthread_mutex_t *lock);
void ao_wakeup_poll(struct ao *ao);
+void ao_underrun_event(struct ao *ao);
bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s,
struct mp_chmap *map);