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/internal.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'audio/out/internal.h') diff --git a/audio/out/internal.h b/audio/out/internal.h index a4be59982a..0c59ce973e 100644 --- a/audio/out/internal.h +++ b/audio/out/internal.h @@ -48,6 +48,14 @@ struct ao { int init_flags; // AO_INIT_* flags bool stream_silence; // if audio inactive, just play silence + // Set by the driver on init. This is typically the period size, and the + // smallest unit the driver will accept in one piece (although if + // AOPLAY_FINAL_CHUNK is set, the driver must accept everything). + // This value is in complete samples (i.e. 1 for stereo means 1 sample + // for both channels each). + // Used for push based API only. + int period_size; + // The device as selected by the user, usually using ao_device_desc.name // from an entry from the list returned by driver->list_devices. If the // default device should be used, this is set to NULL. -- cgit v1.2.3