From e16c91d07ab2acfb83fdeaa6dcfcd25c97666504 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 9 Mar 2014 00:49:39 +0100 Subject: 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. --- audio/out/ao_pulse.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'audio/out/ao_pulse.c') diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 12fca17dd6..d08ffcfc53 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -205,13 +205,18 @@ static bool select_chmap(struct ao *ao, pa_channel_map *dst) chmap_pa_from_mp(dst, &ao->channels); } -static void uninit(struct ao *ao, bool cut_audio) +static void drain(struct ao *ao) { struct priv *priv = ao->priv; - if (priv->stream && !cut_audio) { + if (priv->stream) { pa_threaded_mainloop_lock(priv->mainloop); waitop(priv, pa_stream_drain(priv->stream, success_cb, ao)); } +} + +static void uninit(struct ao *ao) +{ + struct priv *priv = ao->priv; if (priv->mainloop) pa_threaded_mainloop_stop(priv->mainloop); @@ -366,7 +371,7 @@ fail: if (proplist) pa_proplist_free(proplist); - uninit(ao, true); + uninit(ao); return -1; } @@ -620,6 +625,7 @@ const struct ao_driver audio_out_pulse = { .get_delay = get_delay, .pause = pause, .resume = resume, + .drain = drain, .priv_size = sizeof(struct priv), .priv_defaults = &(const struct priv) { .cfg_buffer = 250, -- cgit v1.2.3