]> git.alsa-project.org Git - alsa-lib.git/commitdiff
seq: return back old snd_seq_drain_output behaviour for -EAGAIN
authorJaroslav Kysela <perex@perex.cz>
Tue, 13 Jan 2026 07:09:47 +0000 (08:09 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 13 Jan 2026 07:09:47 +0000 (08:09 +0100)
It seems that many applications did not follow the documentation
including pyalsa sequencer module, thus return the previous
behaviour and correct documentation.

Closes: https://github.com/alsa-project/alsa-lib/issues/493
Fixes: b97a11ec ("seq: fix snd_seq_drain_output return value for partial drain")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/seq/seq.c

index 49f013e05c6aa8ca8f48e5011b7bdf94a8e627f5..b9d9c041919e26a3ae57762650e34d8c8a3fed1a 100644 (file)
@@ -4431,8 +4431,7 @@ int snd_seq_event_output_pending(snd_seq_t *seq)
  * \brief drain output buffer to sequencer
  * \param seq sequencer handle
  * \return 0 when all events are drained and sent to sequencer.
- *         When events still remain on the buffer, the byte size of remaining
- *         events are returned.  On error a negative error code is returned.
+ *         On error a negative error code is returned (including -EAGAIN).
  *
  * This function drains all pending events on the output buffer.
  * The function returns immediately after the events are sent to the queues
@@ -4444,19 +4443,15 @@ int snd_seq_event_output_pending(snd_seq_t *seq)
  */
 int snd_seq_drain_output(snd_seq_t *seq)
 {
-       ssize_t result, processed = 0;
+       ssize_t result;
        assert(seq);
        while (seq->obufused > 0) {
                result = seq->ops->write(seq, seq->obuf, seq->obufused);
-               if (result < 0) {
-                       if (result == -EAGAIN && processed > 0)
-                               return seq->obufused;
+               if (result < 0)
                        return result;
-               }
                if ((size_t)result < seq->obufused)
                        memmove(seq->obuf, seq->obuf + result, seq->obufused - result);
                seq->obufused -= result;
-               processed += result;
        }
        return 0;
 }