From f88193091b3de59b496633682b659cd388e24a59 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 16 Jun 2013 18:47:02 +0200 Subject: audio/out: don't require AOs to set ao->bps Some still do, because they use the value in other places of the init function. ao_portaudio is tricky and reads ao->bps in the stream thread, which might be started on initialization (not sure about that, but better safe than sorry). --- audio/out/ao.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'audio/out/ao.c') diff --git a/audio/out/ao.c b/audio/out/ao.c index 2ad91ab858..9cfa383972 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -25,6 +25,7 @@ #include "config.h" #include "ao.h" +#include "audio/format.h" #include "core/mp_msg.h" @@ -115,7 +116,11 @@ static bool ao_try_init(struct ao *ao, char *params) { if (ao->driver->encode != !!ao->encode_lavc_ctx) return false; - return ao->driver->init(ao, params) >= 0; + if (ao->driver->init(ao, params) < 0) + return false; + ao->bps = ao->channels.num * ao->samplerate * af_fmt2bits(ao->format) / 8; + ao->initialized = true; + return true; } void ao_init(struct ao *ao, char **ao_list) @@ -156,11 +161,8 @@ void ao_init(struct ao *ao, char **ao_list) if (audio_out) { // name matches, try it ao->driver = audio_out; - if (ao_try_init(ao, params)) { - ao->driver = audio_out; - ao->initialized = true; + if (ao_try_init(ao, params)) return; - } mp_tmsg(MSGT_AO, MSGL_WARN, "Failed to initialize audio driver '%s'\n", ao_name); talloc_free_children(ao); @@ -182,11 +184,8 @@ void ao_init(struct ao *ao, char **ao_list) const struct ao_driver *audio_out = audio_out_drivers[i]; ao->driver = audio_out; ao->probing = true; - if (ao_try_init(ao, NULL)) { - ao->initialized = true; - ao->driver = audio_out; + if (ao_try_init(ao, NULL)) return; - } talloc_free_children(ao); *ao = backup; } -- cgit v1.2.3