mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-04 04:06:26 -05:00
seq: return back old snd_seq_drain_output behaviour for -EAGAIN
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>
This commit is contained in:
parent
63a981865a
commit
805464c7bd
1 changed files with 3 additions and 8 deletions
|
|
@ -4431,8 +4431,7 @@ int snd_seq_event_output_pending(snd_seq_t *seq)
|
||||||
* \brief drain output buffer to sequencer
|
* \brief drain output buffer to sequencer
|
||||||
* \param seq sequencer handle
|
* \param seq sequencer handle
|
||||||
* \return 0 when all events are drained and sent to sequencer.
|
* \return 0 when all events are drained and sent to sequencer.
|
||||||
* When events still remain on the buffer, the byte size of remaining
|
* On error a negative error code is returned (including -EAGAIN).
|
||||||
* events are returned. On error a negative error code is returned.
|
|
||||||
*
|
*
|
||||||
* This function drains all pending events on the output buffer.
|
* This function drains all pending events on the output buffer.
|
||||||
* The function returns immediately after the events are sent to the queues
|
* 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)
|
int snd_seq_drain_output(snd_seq_t *seq)
|
||||||
{
|
{
|
||||||
ssize_t result, processed = 0;
|
ssize_t result;
|
||||||
assert(seq);
|
assert(seq);
|
||||||
while (seq->obufused > 0) {
|
while (seq->obufused > 0) {
|
||||||
result = seq->ops->write(seq, seq->obuf, seq->obufused);
|
result = seq->ops->write(seq, seq->obuf, seq->obufused);
|
||||||
if (result < 0) {
|
if (result < 0)
|
||||||
if (result == -EAGAIN && processed > 0)
|
|
||||||
return seq->obufused;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
if ((size_t)result < seq->obufused)
|
if ((size_t)result < seq->obufused)
|
||||||
memmove(seq->obuf, seq->obuf + result, seq->obufused - result);
|
memmove(seq->obuf, seq->obuf + result, seq->obufused - result);
|
||||||
seq->obufused -= result;
|
seq->obufused -= result;
|
||||||
processed += result;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue