Skip to contentSkip to conversation

Alsa: seq: correctly detect input buffer overflow

PATCH Applied Adam Goode 2 participants 2 messages Jun 4, 2014 Sound

lore
Share & tools
lore

Adam Goode

author
#0 lore raw

PATCH 1/1 Alsa: seq: correctly detect input buffer overflow

snd_seq_event_dup returns -ENOMEM in some buffer-full conditions, but usually returns -EAGAIN. Make -EAGAIN trigger the overflow condition in snd_seq_fifo_event_in so that the fifo is cleared and -ENOSPC is returned to userspace as stated in the alsa-lib docs.

sound/core/seq/seq_fifo.c +1 -1
index 5599899..53a403e 100644
@@ -124,7 +124,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
 	snd_use_lock_use(&f->use_lock);
 	err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */
 	if (err < 0) {
-		if (err == -ENOMEM)
+		if ((err == -ENOMEM) || (err == -EAGAIN))
 			atomic_inc(&f->overflow);
 		snd_use_lock_free(&f->use_lock);
 		return err;
Signature · 1 line
1.9.1.423.g4596e3a
Applied
#1 lore raw

At Wed, 4 Jun 2014 01:02:51 -0400,

Quoted 7 lines · Adam Goode

snd_seq_event_dup returns -ENOMEM in some buffer-full conditions, but usually returns -EAGAIN. Make -EAGAIN trigger the overflow condition in snd_seq_fifo_event_in so that the fifo is cleared and -ENOSPC is returned to userspace as stated in the alsa-lib docs.

Thanks, applied.

Takashi

Quoted 17 lines
sound/core/seq/seq_fifo.c +1 -1
index 5599899..53a403e 100644
@@ -124,7 +124,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
 	snd_use_lock_use(&f->use_lock);
 	err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */
 	if (err < 0) {
-		if (err == -ENOMEM)
+		if ((err == -ENOMEM) || (err == -EAGAIN))
 			atomic_inc(&f->overflow);
 		snd_use_lock_free(&f->use_lock);
 		return err;
Signature · 1 line
1.9.1.423.g4596e3a