[LAU] ALSA MIDI buffer size

Brent Busby brent at keycorner.org
Mon Jun 29 18:16:41 CEST 2020


I've been working on a problem with a Perl program sending and receiving
large sysex dumps via the ALSA::MIDI module.  It looks like there is a
4kB buffer in ALSA rawmidi that can be overrun if things go in or out
too quickly.  Keeping it from filling too fast outgoing is easy.  But
since there is no way for MIDI to tell the remote sender to slow down,
preventing buffer overruns from incoming data is turning into a problem.

Is there a way I can either tune the size of the buffer from Perl,
perhaps with some kind of library call to ALSA's raw MIDI API, or
somehow make the access blocking so that it won't try to take more data
than it can handle?  I've been looking at the C source for the amidi
command, but I'm trying to deal with this in Perl if possible.

It seems to depend a lot on how fast the device wants to send, but some
devices break the sysex transfer into chunks and try to slow down, and
other don't bother and just expect you to keep up.


More information about the Linux-audio-user mailing list