summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-16 18:47:02 +0200
committerwm4 <wm4@nowhere>2013-06-16 19:32:18 +0200
commitf88193091b3de59b496633682b659cd388e24a59 (patch)
tree2dd817c703d169716c17a45d172e8f36353621ac /audio/out/ao.c
parentc8c70dce5719576648489f9d2bad1cf9b61495a1 (diff)
downloadmpv-f88193091b3de59b496633682b659cd388e24a59.tar.bz2
mpv-f88193091b3de59b496633682b659cd388e24a59.tar.xz
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).
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c17
1 files changed, 8 insertions, 9 deletions
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;
}