aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/alsa_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-29 15:59:40 +0100
committerMax Kellermann <max@duempel.org>2009-10-29 15:59:40 +0100
commit1403172ef397c3dfc58a64c999a362cca977241b (patch)
tree5fcd866c62528295dfa697cc06dfba862ed3ff61 /src/output/alsa_plugin.c
parentf74ee1a352a0fb39fd0a0b42ab740f2f6e6957a3 (diff)
downloadmpd-1403172ef397c3dfc58a64c999a362cca977241b.tar.gz
mpd-1403172ef397c3dfc58a64c999a362cca977241b.tar.xz
mpd-1403172ef397c3dfc58a64c999a362cca977241b.zip
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.
Diffstat (limited to '')
-rw-r--r--src/output/alsa_plugin.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c
index 89ed6058e..870115998 100644
--- a/src/output/alsa_plugin.c
+++ b/src/output/alsa_plugin.c
@@ -496,6 +496,14 @@ alsa_recover(struct alsa_data *ad, int err)
}
static void
+alsa_drain(void *data)
+{
+ struct alsa_data *ad = data;
+
+ snd_pcm_drain(ad->pcm);
+}
+
+static void
alsa_cancel(void *data)
{
struct alsa_data *ad = data;
@@ -508,9 +516,6 @@ alsa_close(void *data)
{
struct alsa_data *ad = data;
- if (snd_pcm_state(ad->pcm) == SND_PCM_STATE_RUNNING)
- snd_pcm_drain(ad->pcm);
-
snd_pcm_close(ad->pcm);
}
@@ -542,6 +547,7 @@ const struct audio_output_plugin alsaPlugin = {
.finish = alsa_finish,
.open = alsa_open,
.play = alsa_play,
+ .drain = alsa_drain,
.cancel = alsa_cancel,
.close = alsa_close,