summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-30 21:30:54 +0100
committerwm4 <wm4@nowhere>2015-01-30 21:30:54 +0100
commit12d822ce44a6d6bcb981429feb24044cf92b13bc (patch)
tree65e14e9c1bdd18d98fc49bd4ad015632378023d1
parenta7c43babb7c43005e89f2a18bc8688f301def583 (diff)
downloadmpv-12d822ce44a6d6bcb981429feb24044cf92b13bc.tar.bz2
mpv-12d822ce44a6d6bcb981429feb24044cf92b13bc.tar.xz
ao_null: add emulation for certain broken behavior
I'm not sure how common this behavior possibly is; well whatever. This option will allow reproducing such behavior, and help debugging it.
-rw-r--r--DOCS/man/ao.rst3
-rw-r--r--audio/out/ao_null.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/DOCS/man/ao.rst b/DOCS/man/ao.rst
index e16309afb8..fdbefbb167 100644
--- a/DOCS/man/ao.rst
+++ b/DOCS/man/ao.rst
@@ -247,6 +247,9 @@ Available audio output drivers are:
Simulate broken audio drivers, which always add the fixed device
latency to the reported audio playback position.
+ ``broken-delay``
+ Simulate broken audio drivers, which don't report latency correctly.
+
``pcm``
Raw PCM/WAVE file writer audio output
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 8fe783f76d..6fcd06b5c2 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#include "talloc.h"
@@ -50,6 +51,7 @@ struct priv {
float latency_sec; // seconds
float latency; // samples
int broken_eof;
+ int broken_delay;
// 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.
@@ -191,7 +193,15 @@ static double get_delay(struct ao *ao)
if (priv->broken_eof && priv->buffered < priv->latency)
delay = priv->latency;
- return delay / (double)ao->samplerate;
+ delay /= ao->samplerate;
+
+ if (priv->broken_delay) { // Report only multiples of outburst
+ double q = priv->outburst / (double)ao->samplerate;
+ if (delay > 0)
+ delay = (int)(delay / q) * q;
+ }
+
+ return delay;
}
#define OPT_BASE_STRUCT struct priv
@@ -221,6 +231,7 @@ const struct ao_driver audio_out_null = {
OPT_FLOATRANGE("speed", speed, 0, 0, 10000),
OPT_FLOATRANGE("latency", latency_sec, 0, 0, 100),
OPT_FLAG("broken-eof", broken_eof, 0),
+ OPT_FLAG("broken-delay", broken_delay, 0),
{0}
},
};