summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-06-25 15:57:15 +0200
committerwm4 <wm4@nowhere>2017-06-25 15:57:43 +0200
commit037c37519b305bb5d5ea0379122d62ba356cc103 (patch)
tree5f93237279937290a3cd882e60a2bc040907a490 /audio/out/ao.c
parent72ef74dab5244753c9bc6f33687aa60a2886c53b (diff)
downloadmpv-037c37519b305bb5d5ea0379122d62ba356cc103.tar.bz2
mpv-037c37519b305bb5d5ea0379122d62ba356cc103.tar.xz
audio/out: require AO drivers to report period size and correct buffer
Before this change, AOs could have internal alignment, and play() would not consume the trailing data if the size passed to it is not aligned. Change this to require AOs to report their alignment (via period_size), and make sure to always send aligned data. The buffer reported by get_space() now always has to be correct and reliable. If play() does not consume all data provided (which is bounded by get_space()), an error is printed. This is preparation for potential further AO changes. I casually checked alsa/lavc/null/pcm, the other AOs might or might not work.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index a2a001c50c..b699b64c5a 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -194,6 +194,8 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
ao->stream_silence = flags & AO_INIT_STREAM_SILENCE;
+ ao->period_size = 1;
+
int r = ao->driver->init(ao);
if (r < 0) {
// Silly exception for coreaudio spdif redirection
@@ -209,6 +211,11 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
goto fail;
}
+ if (ao->period_size < 1) {
+ MP_ERR(ao, "Invalid period size set.\n");
+ goto fail;
+ }
+
ao->sstride = af_fmt_to_bytes(ao->format);
ao->num_planes = 1;
if (af_fmt_is_planar(ao->format)) {