From 08b198aab49f73829bb02a25bc46bd159b6f9c6e Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 2 Jun 2020 20:30:59 +0200 Subject: 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. --- audio/out/internal.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'audio/out/internal.h') 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). -- cgit v1.2.3