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_alsa.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index d50757bdfd..291c6d7c1c 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -79,7 +79,7 @@ struct priv { } while (0) static float get_delay(struct ao *ao); -static void uninit(struct ao *ao, bool immed); +static void uninit(struct ao *ao); /* to set/get/query special features/parameters */ static int control(struct ao *ao, enum aocontrol cmd, void *arg) @@ -530,22 +530,19 @@ static int init(struct ao *ao) return 0; alsa_error: - uninit(ao, true); + uninit(ao); return -1; } // end init /* close audio device */ -static void uninit(struct ao *ao, bool immed) +static void uninit(struct ao *ao) { struct priv *p = ao->priv; if (p->alsa) { int err; - if (!immed) - snd_pcm_drain(p->alsa); - err = snd_pcm_close(p->alsa); CHECK_ALSA_ERROR("pcm close error"); @@ -556,6 +553,12 @@ alsa_error: p->alsa = NULL; } +static void drain(struct ao *ao) +{ + struct priv *p = ao->priv; + snd_pcm_drain(p->alsa); +} + static void audio_pause(struct ao *ao) { struct priv *p = ao->priv; @@ -712,6 +715,7 @@ const struct ao_driver audio_out_alsa = { .pause = audio_pause, .resume = audio_resume, .reset = reset, + .drain = drain, .priv_size = sizeof(struct priv), .priv_defaults = &(const struct priv) { .cfg_block = 1, -- cgit v1.2.3