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_openal.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'audio/out/ao_openal.c') diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c index 8cc29db689..f2cbe78e94 100644 --- a/audio/out/ao_openal.c +++ b/audio/out/ao_openal.c @@ -178,18 +178,10 @@ err_out: } // close audio device -static void uninit(struct ao *ao, bool immed) +static void uninit(struct ao *ao) { ALCcontext *ctx = alcGetCurrentContext(); ALCdevice *dev = alcGetContextsDevice(ctx); - if (!immed) { - ALint state; - alGetSourcei(sources[0], AL_SOURCE_STATE, &state); - while (state == AL_PLAYING) { - mp_sleep_us(10000); - alGetSourcei(sources[0], AL_SOURCE_STATE, &state); - } - } reset(ao); alcMakeContextCurrent(NULL); alcDestroyContext(ctx); @@ -197,6 +189,16 @@ static void uninit(struct ao *ao, bool immed) ao_data = NULL; } +static void drain(struct ao *ao) +{ + ALint state; + alGetSourcei(sources[0], AL_SOURCE_STATE, &state); + while (state == AL_PLAYING) { + mp_sleep_us(10000); + alGetSourcei(sources[0], AL_SOURCE_STATE, &state); + } +} + static void unqueue_buffers(void) { ALint p; @@ -298,6 +300,7 @@ const struct ao_driver audio_out_openal = { .pause = audio_pause, .resume = audio_resume, .reset = reset, + .drain = drain, .priv_size = sizeof(struct priv), .options = (const struct m_option[]) { OPT_STRING_VALIDATE("device", cfg_device, 0, validate_device_opt), -- cgit v1.2.3