From 1403172ef397c3dfc58a64c999a362cca977241b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 29 Oct 2009 15:59:40 +0100 Subject: output_plugin: added method "drain" drain() is the opposite of cancel(): it waits until all data in the buffer has finished playing. Instead of implicitly draining in the close() method like the ALSA plugin has been doing it forever, let the output thread decide whether to drain or to cancel. --- src/output_plugin.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/output_plugin.h') diff --git a/src/output_plugin.h b/src/output_plugin.h index 3a9748d4..ee7f7c73 100644 --- a/src/output_plugin.h +++ b/src/output_plugin.h @@ -116,6 +116,11 @@ struct audio_output_plugin { size_t (*play)(void *data, const void *chunk, size_t size, GError **error); + /** + * Wait until the device has finished playing. + */ + void (*drain)(void *data); + /** * Try to cancel data which may still be in the device's * buffers. @@ -213,6 +218,13 @@ ao_plugin_play(const struct audio_output_plugin *plugin, return plugin->play(data, chunk, size, error); } +static inline void +ao_plugin_drain(const struct audio_output_plugin *plugin, void *data) +{ + if (plugin->drain != NULL) + plugin->drain(data); +} + static inline void ao_plugin_cancel(const struct audio_output_plugin *plugin, void *data) { -- cgit v1.2.3