From 037c37519b305bb5d5ea0379122d62ba356cc103 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 25 Jun 2017 15:57:15 +0200 Subject: 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. --- audio/out/ao_lavc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'audio/out/ao_lavc.c') diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index 619f4fe72a..f247cba12e 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -160,6 +160,8 @@ static int init(struct ao *ao) ao->untimed = true; + ao->period_size = ac->aframesize * ac->framecount; + if (ao->channels.num > AV_NUM_DATA_POINTERS) goto fail; @@ -203,7 +205,7 @@ static void uninit(struct ao *ao) ac->shutdown = true; } -// return: how many bytes can be played without blocking +// return: how many samples can be played without blocking static int get_space(struct ao *ao) { struct priv *ac = ao->priv; -- cgit v1.2.3