Do not assume the global MIDI channel is always the first channel.
Use instead the channel returned by the DEVICE INQUIRY reply
message when identifying the microX.
In the presence of multiple raw MIDI devices, libasound crashes
somewhere in snd_config_update (called when opening a device).
I am not sure to understand what causes the problem (it may be
a libasound bug?), but it seems that making sure that
snd_config_update is called only once (by calling it ourselves,
and then using the _lconf-suffixed functions) is enough to
prevent the crash.
Do not use xmalloc-style die-on-error wrappers for memory allocation
functions. Use standard functions and handle out-of-memory errors
properly when needed.
Complete the Doxygen comments in the midi.c, sysex.c and
microx.c modules. Also add a Doxygen settings file to
generate the documentation from these comments.
In the ALSA backend, do not set midi->error to the count of bytes
written or read if the write or read operation was successful. Set
it instead to zero.
All read/write functions return -1 on error.
Add Doxygen-like comments to each public function of the midi.c
module to document the possible returned values.
Before letting the open function of a MIDI backend trying to open
the port, perform a basic check on the port name, and avoid calling
the backend on a port which is obviously not recognizable by that
backend.
The array holding the listed MIDI ports was being corrupted if any
of the *_midi_get_ports functions was called more than once, due
to a mishandling of operator priority.
Use function pointers in the midi_io_t structure to call static
backend-dependent functions when the public, backend-independent
functions are called.
The actual choice of backend is done upon opening the MIDI port:
the open function of each backend is called, the first one that
succeeds at opening the port will set the backend for all the
following operations on that port.
Do not select one MIDI backend against the other(s). Detect all
available MIDI backends (for now, ALSA and OSS only) and enable
them all. Provide the user with options to disable some backends,
but make sure that at least one backend is available and enabled.
The OSS backend is considered to be always available, since it has
no compile-time dependency.
Do not use a callback function to iterate through the available
MIDI ports. Instead, get a list of all the available ports as
an automatically allocated string array, then iterate on the
array members.
Do not use a default MIDI port fixed at compile-time. If no port is
specified with the -p option, send a Device Inquiry to each
available MIDI port until a device answers with the correct
identification.