summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao.c17
-rw-r--r--audio/out/ao_alsa.c1
-rw-r--r--audio/out/ao_jack.c1
-rw-r--r--audio/out/ao_lavc.c1
-rw-r--r--audio/out/ao_null.c1
-rw-r--r--audio/out/ao_openal.c1
-rw-r--r--audio/out/ao_pulse.c2
-rw-r--r--audio/out/ao_rsound.c2
-rw-r--r--audio/out/ao_sdl.c42
9 files changed, 28 insertions, 40 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;
}
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index a8952e4547..6dd04d2967 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -560,7 +560,6 @@ static int init(struct ao *ao, char *params)
p->bytes_per_sample = af_fmt2bits(ao->format) / 8;
p->bytes_per_sample *= ao->channels.num;
- ao->bps = ao->samplerate * p->bytes_per_sample;
err = snd_pcm_hw_params_set_buffer_time_near
(p->alsa, alsa_hwparams, &(unsigned int){BUFFER_TIME}, NULL);
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index e66f01cca6..ff5c37a818 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -279,7 +279,6 @@ static int init(struct ao *ao, char *params)
goto err_out;
ao->format = AF_FORMAT_FLOAT_NE;
- ao->bps = ao->channels.num * ao->samplerate * sizeof(float);
int unitsize = ao->channels.num * sizeof(float);
ao->outburst = CHUNK_SIZE / unitsize * unitsize;
ao->buffersize = NUM_CHUNKS * ao->outburst;
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index e30b3182d2..d2ae5e1e53 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -285,7 +285,6 @@ out_takefirst:
ao->outburst =
ac->aframesize * ac->sample_size * ao->channels.num * ac->framecount;
ao->buffersize = ao->outburst * 2;
- ao->bps = ao->channels.num * ao->samplerate * ac->sample_size;
ao->untimed = true;
ao->priv = ac;
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 32d02bea31..f3c60913b5 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -58,7 +58,6 @@ static int init(struct ao *ao, char *params)
ao->outburst = 256 * ao->channels.num * samplesize;
// A "buffer" for about 0.2 seconds of audio
ao->buffersize = (int)(ao->samplerate * 0.2 / 256 + 1) * ao->outburst;
- ao->bps = ao->channels.num * ao->samplerate * samplesize;
priv->last_time = mp_time_sec();
return 0;
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index 5dc95a4dd9..60f4dd7c99 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -188,7 +188,6 @@ static int init(struct ao *ao, char *params)
if (alcGetError(dev) == ALC_NO_ERROR && freq)
ao->samplerate = freq;
ao->format = AF_FORMAT_S16_NE;
- ao->bps = ao->channels.num * ao->samplerate * 2;
ao->buffersize = CHUNK_SIZE * NUM_BUF;
ao->outburst = ao->channels.num * CHUNK_SIZE;
tmpbuf = malloc(CHUNK_SIZE);
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 15a2b8b0a1..2c9f3734c6 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -313,8 +313,6 @@ static int init(struct ao *ao, char *params)
if (!select_chmap(ao, &map))
goto fail;
- ao->bps = pa_bytes_per_second(&ss);
-
if (!(priv->stream = pa_stream_new(priv->context, "audio stream", &ss,
&map)))
goto unlock_and_fail;
diff --git a/audio/out/ao_rsound.c b/audio/out/ao_rsound.c
index 1c0b534ab4..3fdf2b8cac 100644
--- a/audio/out/ao_rsound.c
+++ b/audio/out/ao_rsound.c
@@ -140,8 +140,6 @@ static int init(struct ao *ao, char *params)
return -1;
}
- ao->bps = ao->channels.num * ao->samplerate * af_fmt2bits(ao->format) / 8;
-
return 0;
}
diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c
index 63b1f3963d..572266c4a8 100644
--- a/audio/out/ao_sdl.c
+++ b/audio/out/ao_sdl.c
@@ -169,26 +169,25 @@ static int init(struct ao *ao, char *params)
SDL_AudioSpec desired, obtained;
- int bytes = 0;
switch (ao->format) {
- case AF_FORMAT_U8: desired.format = AUDIO_U8; bytes = 1; break;
- case AF_FORMAT_S8: desired.format = AUDIO_S8; bytes = 1; break;
- case AF_FORMAT_U16_LE: desired.format = AUDIO_U16LSB; bytes = 2; break;
- case AF_FORMAT_U16_BE: desired.format = AUDIO_U16MSB; bytes = 2; break;
+ case AF_FORMAT_U8: desired.format = AUDIO_U8; break;
+ case AF_FORMAT_S8: desired.format = AUDIO_S8; break;
+ case AF_FORMAT_U16_LE: desired.format = AUDIO_U16LSB; break;
+ case AF_FORMAT_U16_BE: desired.format = AUDIO_U16MSB; break;
default:
- case AF_FORMAT_S16_LE: desired.format = AUDIO_S16LSB; bytes = 2; break;
- case AF_FORMAT_S16_BE: desired.format = AUDIO_S16MSB; bytes = 2; break;
+ case AF_FORMAT_S16_LE: desired.format = AUDIO_S16LSB; break;
+ case AF_FORMAT_S16_BE: desired.format = AUDIO_S16MSB; break;
#ifdef AUDIO_S32LSB
- case AF_FORMAT_S32_LE: desired.format = AUDIO_S32LSB; bytes = 4; break;
+ case AF_FORMAT_S32_LE: desired.format = AUDIO_S32LSB; break;
#endif
#ifdef AUDIO_S32MSB
- case AF_FORMAT_S32_BE: desired.format = AUDIO_S32MSB; bytes = 4; break;
+ case AF_FORMAT_S32_BE: desired.format = AUDIO_S32MSB; break;
#endif
#ifdef AUDIO_F32LSB
- case AF_FORMAT_FLOAT_LE: desired.format = AUDIO_F32LSB; bytes = 4; break;
+ case AF_FORMAT_FLOAT_LE: desired.format = AUDIO_F32LSB; break;
#endif
#ifdef AUDIO_F32MSB
- case AF_FORMAT_FLOAT_BE: desired.format = AUDIO_F32MSB; bytes = 4; break;
+ case AF_FORMAT_FLOAT_BE: desired.format = AUDIO_F32MSB; break;
#endif
}
desired.freq = ao->samplerate;
@@ -217,23 +216,23 @@ static int init(struct ao *ao, char *params)
(int) obtained.format, (int) obtained.samples);
switch (obtained.format) {
- case AUDIO_U8: ao->format = AF_FORMAT_U8; bytes = 1; break;
- case AUDIO_S8: ao->format = AF_FORMAT_S8; bytes = 1; break;
- case AUDIO_S16LSB: ao->format = AF_FORMAT_S16_LE; bytes = 2; break;
- case AUDIO_S16MSB: ao->format = AF_FORMAT_S16_BE; bytes = 2; break;
- case AUDIO_U16LSB: ao->format = AF_FORMAT_U16_LE; bytes = 2; break;
- case AUDIO_U16MSB: ao->format = AF_FORMAT_U16_BE; bytes = 2; break;
+ case AUDIO_U8: ao->format = AF_FORMAT_U8; break;
+ case AUDIO_S8: ao->format = AF_FORMAT_S8; break;
+ case AUDIO_S16LSB: ao->format = AF_FORMAT_S16_LE; break;
+ case AUDIO_S16MSB: ao->format = AF_FORMAT_S16_BE; break;
+ case AUDIO_U16LSB: ao->format = AF_FORMAT_U16_LE; break;
+ case AUDIO_U16MSB: ao->format = AF_FORMAT_U16_BE; break;
#ifdef AUDIO_S32LSB
- case AUDIO_S32LSB: ao->format = AF_FORMAT_S32_LE; bytes = 4; break;
+ case AUDIO_S32LSB: ao->format = AF_FORMAT_S32_LE; break;
#endif
#ifdef AUDIO_S32MSB
- case AUDIO_S32MSB: ao->format = AF_FORMAT_S32_BE; bytes = 4; break;
+ case AUDIO_S32MSB: ao->format = AF_FORMAT_S32_BE; break;
#endif
#ifdef AUDIO_F32LSB
- case AUDIO_F32LSB: ao->format = AF_FORMAT_FLOAT_LE; bytes = 4; break;
+ case AUDIO_F32LSB: ao->format = AF_FORMAT_FLOAT_LE; break;
#endif
#ifdef AUDIO_F32MSB
- case AUDIO_F32MSB: ao->format = AF_FORMAT_FLOAT_BE; bytes = 4; break;
+ case AUDIO_F32MSB: ao->format = AF_FORMAT_FLOAT_BE; break;
#endif
default:
if (!ao->probing)
@@ -249,7 +248,6 @@ static int init(struct ao *ao, char *params)
}
ao->samplerate = obtained.freq;
- ao->bps = ao->channels.num * ao->samplerate * bytes;
ao->buffersize = obtained.size * bufcnt;
ao->outburst = obtained.size;
priv->buffer = av_fifo_alloc(ao->buffersize);