diff options
author | wm4 <wm4@nowhere> | 2014-03-09 00:49:39 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-09 01:27:41 +0100 |
commit | e16c91d07ab2acfb83fdeaa6dcfcd25c97666504 (patch) | |
tree | 5e5e33af457c4d573a32e15aec95205f4987f9bb /audio/out/push.c | |
parent | 2f03dc259960c9cb282e8f371d9f68266afea49c (diff) | |
download | mpv-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/push.c')
-rw-r--r-- | audio/out/push.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/audio/out/push.c b/audio/out/push.c index de093988bd..f0608dd3a4 100644 --- a/audio/out/push.c +++ b/audio/out/push.c @@ -106,6 +106,17 @@ static void resume(struct ao *ao) pthread_mutex_unlock(&p->lock); } +static void drain(struct ao *ao) +{ + if (ao->driver->drain) { + struct ao_push_state *p = ao->api_priv; + pthread_mutex_lock(&p->lock); + ao->driver->drain(ao); + pthread_mutex_unlock(&p->lock); + } else { + ao_wait_drain(ao); + } +} static int get_space(struct ao *ao) { @@ -202,7 +213,7 @@ static void *playthread(void *arg) return NULL; } -static void uninit(struct ao *ao, bool cut_audio) +static void uninit(struct ao *ao) { struct ao_push_state *p = ao->api_priv; @@ -213,7 +224,7 @@ static void uninit(struct ao *ao, bool cut_audio) pthread_join(p->thread, NULL); - ao->driver->uninit(ao, cut_audio); + ao->driver->uninit(ao); pthread_cond_destroy(&p->wakeup); pthread_mutex_destroy(&p->lock); @@ -231,7 +242,7 @@ static int init(struct ao *ao) &ao->channels, ao->samplerate); mp_audio_buffer_preallocate_min(p->buffer, ao->buffer); if (pthread_create(&p->thread, NULL, playthread, ao)) { - ao->driver->uninit(ao, true); + ao->driver->uninit(ao); return -1; } return 0; @@ -247,6 +258,7 @@ const struct ao_driver ao_api_push = { .get_delay = get_delay, .pause = pause, .resume = resume, + .drain = drain, .priv_size = sizeof(struct ao_push_state), }; |