summaryrefslogtreecommitdiffstats
path: root/a52
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-04-06 23:39:31 +0200
committerTakashi Iwai <tiwai@suse.de>2006-04-06 23:39:31 +0200
commit27b17fe7b79fcd1db4041c79b779a636eb506743 (patch)
tree43450c6e1ca79416f0135f4a521725f584ba13d2 /a52
parenta836797cd486d0c372d3503a7241a452959eaafb (diff)
Fix XRUN detection in a52 plugin
Check XRUN in the write function and pointer callback of a52 plugin.
Diffstat (limited to 'a52')
-rw-r--r--a52/pcm_a52.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/a52/pcm_a52.c b/a52/pcm_a52.c
index 3d376e2..94c6411 100644
--- a/a52/pcm_a52.c
+++ b/a52/pcm_a52.c
@@ -70,8 +70,7 @@ static void convert_data(struct a52_ctx *rec)
rec->filled = 0;
}
-static int write_out_pending(snd_pcm_ioplug_t *io ATTRIBUTE_UNUSED,
- struct a52_ctx *rec)
+static int write_out_pending(snd_pcm_ioplug_t *io, struct a52_ctx *rec)
{
int err, ofs = 0;
@@ -80,9 +79,11 @@ static int write_out_pending(snd_pcm_ioplug_t *io ATTRIBUTE_UNUSED,
while (rec->remain) {
err = snd_pcm_writei(rec->slave, rec->outbuf + ofs, rec->remain);
- if (err < 0)
+ if (err < 0) {
+ if (err == -EPIPE)
+ io->state = SND_PCM_STATE_XRUN;
return err;
- else if (! err)
+ } else if (! err)
break;
if (err < rec->remain)
ofs += (rec->remain - err) * 4;
@@ -210,12 +211,17 @@ static snd_pcm_sframes_t a52_pointer(snd_pcm_ioplug_t *io)
int err;
state = snd_pcm_state(rec->slave);
- if (state == SND_PCM_STATE_RUNNING ||
- state == SND_PCM_STATE_DRAINING) {
+ switch (state) {
+ case SND_PCM_STATE_RUNNING:
+ case SND_PCM_STATE_DRAINING:
if ((err = snd_pcm_delay(rec->slave, &delay)) < 0)
return err;
- } else
+ break;
+ case SND_PCM_STATE_XRUN:
+ return -EPIPE;
+ default:
return 0;
+ }
if (delay < 0 || delay >= (snd_pcm_sframes_t)rec->slave_buffer_size)
delay = 0;