summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-09 00:49:39 +0100
committerwm4 <wm4@nowhere>2014-03-09 01:27:41 +0100
commite16c91d07ab2acfb83fdeaa6dcfcd25c97666504 (patch)
tree5e5e33af457c4d573a32e15aec95205f4987f9bb /audio/out/ao.c
parent2f03dc259960c9cb282e8f371d9f68266afea49c (diff)
downloadmpv-e16c91d07ab2acfb83fdeaa6dcfcd25c97666504.tar.bz2
mpv-e16c91d07ab2acfb83fdeaa6dcfcd25c97666504.tar.xz
audio/out: make draining a separate operation
Until now, this was always conflated with uninit. This was ugly, and also many AOs emulated this manually (or just ignored it). Make draining an explicit operation, so AOs which support it can provide it, and for all others generic code will emulate it. For ao_wasapi, we keep it simple and basically disable the internal draining implementation (maybe it should be restored later). Tested on Linux only.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index f1e88d2a10..ee8bc2a254 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -235,11 +235,10 @@ done:
return ao;
}
-// Uninitialize and destroy the AO.
-// cut_audio: if false, block until all remaining audio was played.
-void ao_uninit(struct ao *ao, bool cut_audio)
+// Uninitialize and destroy the AO. Remaining audio must be dropped.
+void ao_uninit(struct ao *ao)
{
- ao->api->uninit(ao, cut_audio);
+ ao->api->uninit(ao);
talloc_free(ao);
}
@@ -315,13 +314,22 @@ void ao_resume(struct ao *ao)
ao->api->resume(ao);
}
-// Wait until the audio buffer is drained. This can be used to emulate draining
-// if native functionality is not available.
-// Only call this on uninit (otherwise, deadlock trouble ahead).
+// Be careful with locking
void ao_wait_drain(struct ao *ao)
{
// This is probably not entirely accurate, but good enough.
mp_sleep_us(ao_get_delay(ao) * 1000000);
+ ao_reset(ao);
+}
+
+// Block until the current audio buffer has played completely.
+void ao_drain(struct ao *ao)
+{
+ if (ao->api->drain) {
+ ao->api->drain(ao);
+ } else {
+ ao_wait_drain(ao);
+ }
}
bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s,