summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-07 15:24:49 +0100
committerwm4 <wm4@nowhere>2014-03-09 00:19:34 +0100
commit3cd1cfb51cb2e29aa7b1f301b55b723a0c2a44ee (patch)
tree59c52d6cd87410a52e1cd41b8383119e45b8005a /audio/out
parent76eca814556f90cc4ef7ba503a12b2d0a5351bef (diff)
downloadmpv-3cd1cfb51cb2e29aa7b1f301b55b723a0c2a44ee.tar.bz2
mpv-3cd1cfb51cb2e29aa7b1f301b55b723a0c2a44ee.tar.xz
ao_null: add option for simulated device speed
Helps with testing and debugging.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_null.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 7caee039e0..a6b40fdb76 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -45,6 +45,7 @@ struct priv {
int untimed;
float bufferlen; // seconds
+ float speed; // multiplier
// Minimal unit of audio samples that can be written at once. If play() is
// called with sizes not aligned to this, a rounded size will be returned.
@@ -66,7 +67,7 @@ static void drain(struct ao *ao)
double now = mp_time_sec();
if (priv->buffered > 0) {
- priv->buffered -= (now - priv->last_time) * ao->samplerate;
+ priv->buffered -= (now - priv->last_time) * ao->samplerate * priv->speed;
if (priv->buffered < 0) {
if (!priv->playing_final)
MP_ERR(ao, "buffer underrun\n");
@@ -101,7 +102,7 @@ static void uninit(struct ao *ao, bool cut_audio)
{
struct priv *priv = ao->priv;
if (!cut_audio && !priv->paused)
- mp_sleep_us(1000.0 * 1000.0 * priv->buffered / ao->samplerate);
+ mp_sleep_us(1000000.0 * priv->buffered / ao->samplerate / priv->speed);
}
// stop playing and empty buffers (for seeking/pause)
@@ -165,6 +166,9 @@ static float get_delay(struct ao *ao)
struct priv *priv = ao->priv;
drain(ao);
+
+ // Note how get_delay returns the delay in audio device time (instead of
+ // adjusting for speed), since most AOs seem to also do that.
return priv->buffered / (double)ao->samplerate;
}
@@ -185,11 +189,13 @@ const struct ao_driver audio_out_null = {
.priv_defaults = &(const struct priv) {
.bufferlen = 0.2,
.outburst = 256,
+ .speed = 1,
},
.options = (const struct m_option[]) {
OPT_FLAG("untimed", untimed, 0),
OPT_FLOATRANGE("buffer", bufferlen, 0, 0, 100),
OPT_INTRANGE("outburst", outburst, 0, 1, 100000),
+ OPT_FLOATRANGE("speed", speed, 0, 0, 10000),
{0}
},
};