summaryrefslogtreecommitdiffstats
path: root/audio/out/internal.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-06-02 20:30:59 +0200
committerwm4 <wm4@nowhere>2020-06-02 20:43:49 +0200
commit08b198aab49f73829bb02a25bc46bd159b6f9c6e (patch)
tree7b59350dd20518867f2a4e3c0a826bd25f96b203 /audio/out/internal.h
parent0d3474c6c0d3bea20bfd50614ffaa3b21d4538cf (diff)
downloadmpv-08b198aab49f73829bb02a25bc46bd159b6f9c6e.tar.bz2
mpv-08b198aab49f73829bb02a25bc46bd159b6f9c6e.tar.xz
audio: further simplify internal audio API somewhat
Instead of the relatively subtle underflow handling, simply signal whether the stream is in a playing state. Should make it more robust. Should affect ao_alsa and ao_pulse only (and ao_openal, but it's broken). For ao_pulse, I'm just guessing. How the hell do you query whether a stream is playing? Who knows. Seems to work, judging from very superficial testing.
Diffstat (limited to 'audio/out/internal.h')
-rw-r--r--audio/out/internal.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/audio/out/internal.h b/audio/out/internal.h
index 15ffd82e57..5cf99a02b7 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -87,9 +87,11 @@ struct mp_pcm_state {
int free_samples; // number of free space in ring buffer
int queued_samples; // number of samples to play in ring buffer
double delay; // total latency in seconds (includes queued_samples)
- bool underrun; // if in underrun state (signals both accidental
- // underruns and normal playback end); cleared by AO
- // driver on reset() calls
+ bool playing; // set if underlying API is actually playing audio;
+ // the AO must unset it on underrun (accidental
+ // underrun and EOF are indistinguishable; the upper
+ // layers decide what it was)
+ // real pausing may assume playing=true
};
/* Note:
@@ -149,13 +151,15 @@ struct ao_driver {
void (*reset)(struct ao *ao);
// push based: set pause state. Only called after start() and before reset().
// returns success (this is intended for paused=true; if it
- // returns false, playback continues; unpausing always works)
+ // returns false, playback continues, and the core emulates via
+ // reset(); unpausing always works)
bool (*set_pause)(struct ao *ao, bool paused);
// pull based: start the audio callback
// push based: start playing queued data
// AO should call ao_wakeup_playthread() if a period boundary
// is crossed, or playback stops due to external reasons
// (including underruns or device removal)
+ // must set mp_pcm_state.playing; unset on error/underrun/end
void (*start)(struct ao *ao);
// push based: queue new data. This won't try to write more data than the
// reported free space (samples <= mp_pcm_state.free_samples).