alsa-seq: improve midi encode some more

snd_midi_event_encode() will reset the encoder when it returns an
encoded event. It is possible that the function returns with an encoded
event when the internal buffer is full, in that case we need to push the
event and continue encoding without reseting the encoder.

0 is not a snd_midi_event_encode() error, so don't handle it like
one.
This commit is contained in:
Wim Taymans 2024-05-09 18:32:14 +02:00
parent 1c056661b6
commit 7dcfe81690

View file

@ -649,16 +649,16 @@ static int process_write(struct seq_state *state)
if (c->type != SPA_CONTROL_Midi)
continue;
if (size == 0) {
if (size == 0)
/* only reset when we start decoding a new message */
snd_seq_ev_clear(&ev);
snd_midi_event_reset_encode(stream->codec);
}
if ((s = snd_midi_event_encode(stream->codec,
SPA_POD_BODY(&c->value),
SPA_POD_BODY_SIZE(&c->value), &ev)) <= 0) {
SPA_POD_BODY_SIZE(&c->value), &ev)) < 0) {
spa_log_warn(state->log, "failed to encode event: %s",
snd_strerror(s));
snd_midi_event_reset_encode(stream->codec);
size = 0;
continue;
}