ALSA raw MIDI API - client hangup and amidi exits midiC3D0 failed: Device or resource busy

happy musicmaker happy.musicmaker at gmail.com
Wed Feb 19 06:20:53 CET 2020


While developing a client using the raw MIDI interface, bumped into an
issue that
went away after rebooting Ubuntu 19.10 - 64 bit. Using a MIDISPORT 4x4 one
of the 4 ports could not be opened. The client (written in C) call hang and
the client thus went unresponsive. No timeout, no error, no nothing.
CTRL-BREAK the client and retrying many times gave the exact same result,
no other apps were using the port. The other 3 ports on the interface and
any other MIDI USB device connected could be opened and used without any
problem.

When opening the port with amidi, an error was reported, it seems amidi did
not gracefully exit as well.

amidi -receive -p hw:3,0,1
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC3D0
failed: Device or resource busy
cannot open port "hw:3,0,1": Device or resource busy

Looking at the rawmidi_hw.c code there is a GOTO and SYSERR statement. Not
sure if those caused this .

   if (fd < 0) {
            snd_ctl_close(ctl);
            SYSERR("open %s failed", filename);
            return -errno;
.
After reboot the problem went away. The problem could have been caused
while fixing some by coding issue. Maybe someone with more understanding of
the code can spot an issue in the code. While  many applications use the
raw MIDI interface. believe Bitwig and most others use the sequencer API to
open ports.

Just wanted to log this just in case anyone else experiences this

Thanks.


More information about the Alsa-devel mailing list