summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_null.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out/ao_null.c')
-rw-r--r--audio/out/ao_null.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 102f0a7013..dde2102daa 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -29,16 +29,18 @@
#include "ao.h"
struct priv {
- unsigned last_time;
+ double last_time;
float buffered_bytes;
+ int buffersize;
+ int outburst;
};
static void drain(struct ao *ao)
{
struct priv *priv = ao->priv;
- unsigned now = GetTimer();
- priv->buffered_bytes -= (now - priv->last_time) / 1e6 * ao->bps;
+ double now = mp_time_sec();
+ priv->buffered_bytes -= (now - priv->last_time) * ao->bps;
if (priv->buffered_bytes < 0)
priv->buffered_bytes = 0;
priv->last_time = now;
@@ -48,12 +50,17 @@ static int init(struct ao *ao, char *params)
{
struct priv *priv = talloc_zero(ao, struct priv);
ao->priv = priv;
+
+ struct mp_chmap_sel sel = {0};
+ mp_chmap_sel_add_any(&sel);
+ if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
+ return -1;
+
int samplesize = af_fmt2bits(ao->format) / 8;
- ao->outburst = 256 * ao->channels * samplesize;
+ priv->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 * ao->samplerate * samplesize;
- priv->last_time = GetTimer();
+ priv->buffersize = (int)(ao->samplerate * 0.2 / 256 + 1) * priv->outburst;
+ priv->last_time = mp_time_sec();
return 0;
}
@@ -87,18 +94,18 @@ static int get_space(struct ao *ao)
struct priv *priv = ao->priv;
drain(ao);
- return ao->buffersize - priv->buffered_bytes;
+ return priv->buffersize - priv->buffered_bytes;
}
static int play(struct ao *ao, void *data, int len, int flags)
{
struct priv *priv = ao->priv;
- int maxbursts = (ao->buffersize - priv->buffered_bytes) / ao->outburst;
- int playbursts = len / ao->outburst;
+ int maxbursts = (priv->buffersize - priv->buffered_bytes) / priv->outburst;
+ int playbursts = len / priv->outburst;
int bursts = playbursts > maxbursts ? maxbursts : playbursts;
- priv->buffered_bytes += bursts * ao->outburst;
- return bursts * ao->outburst;
+ priv->buffered_bytes += bursts * priv->outburst;
+ return bursts * priv->outburst;
}
static float get_delay(struct ao *ao)
@@ -110,7 +117,6 @@ static float get_delay(struct ao *ao)
}
const struct ao_driver audio_out_null = {
- .is_new = true,
.info = &(const struct ao_info) {
"Null audio output",
"null",