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_oss.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'audio/out/ao_oss.c') diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index a1bf0feefc..ca7539b590 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -427,24 +427,28 @@ ac3_retry: } // close audio device -static void uninit(struct ao *ao, bool immed) +static void uninit(struct ao *ao) { struct priv *p = ao->priv; if (p->audio_fd == -1) return; -#ifdef SNDCTL_DSP_SYNC - // to get the buffer played - if (!immed) - ioctl(p->audio_fd, SNDCTL_DSP_SYNC, NULL); -#endif #ifdef SNDCTL_DSP_RESET - if (immed) - ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); + ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); #endif close(p->audio_fd); p->audio_fd = -1; } +static void drain(struct ao *ao) +{ +#ifdef SNDCTL_DSP_SYNC + struct priv *p = ao->priv; + // to get the buffer played + if (p->audio_fd != -1) + ioctl(p->audio_fd, SNDCTL_DSP_SYNC, NULL); +#endif +} + #ifndef SNDCTL_DSP_RESET static void close_device(struct ao *ao) { @@ -601,6 +605,7 @@ const struct ao_driver audio_out_oss = { .pause = audio_pause, .resume = audio_resume, .reset = reset, + .drain = drain, .priv_size = sizeof(struct priv), .priv_defaults = &(const struct priv) { .audio_fd = -1, -- cgit v1.2.3