Following on (kind of) from this thread, my midi setup has two interfaces, one with 16 ports and the other with 9. When SPi starts up it creates an ALSA client mapped to each port on those devices, including two more for ALSA’s own loopback client. That’s 52 clients. Add to this, ALSA’s own three clients for the loopback and my two midi interfaces, and we’re at 55 clients for the system as a whole.
Now, I’ve been writing my own little midi router app to run alongside SPi to switch between the various keyboards and modules that I have. It creates just one ALSA client and sets up a full duplex port for each input device that I want to route. That’s only four or five ports but, for every port that I add to my app, SPi will create two more additional clients and when we get beyond 64 clients in total, we hit problems. Specifically, SPi will attempt to open up all its clients but will fail, reporting “ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: Cannot allocate memory” in erlang.log, after which it will close down all its midi devices (and maybe the server shuts down, too, but I haven’t confirmed this).
I’ve searched Google with that error messages and I’ve found comments that there is indeed a limit in ALSA of 64 clients, but I haven’t found it explicitly documented anywhere.
To solve this for myself, I can hack sp_midi.cpp to avoid opening ports my own app, or only open specific ports on my interfaces, or just only open outputs and not inputs, but this is not a solution for everyone.
I think I put in a feature request a while back - either or here or on Github - for a way to selectively enable or disable specific midi ports and not open everything that’s available. At the time I was having problems on Windows with its non-sharable MME driver for class compliant midi devices, which meant that I couldn’t run SPi with anything else that wanted to use midi. This problem was also the primary reason for me now trying to run all midi kit from an RPi . So, apart from anything else, I’d like to put in another vote for that request.
Of course, in the mean time, if anyone knows a way to increase ALSA’s own resource limits - short of reconfiguring and rebuilding ALSA or the kernel - I’d be very happy
Thanks for reading this,