Keep track of the actual device names in the audio and MIDI prefs
This fixes one of my pet peeves with the device prefs, namely that audio and midi devices get messed up if new devices get plugged in or existing devices unplugged between invocations. Currently only the device indices are kept in the prefs, but these indices keep changing all the time as the device list is changing. This affects, in particular, the ALSA audio, portaudio and portmidi backends. (The Jack audio and ALSA MIDI backends don't really suffer from this as only the number of input and output ports is configurable in these cases.)
We resolve this by keeping track of the actual device names in addition to the device indices. This enables us to remap device indices on the fly during startup, so that the right devices are opened. More precisely, when reading the device indices from the prefs, it is checked whether a corresponding device name has been saved. If so, then the device name is used to find the actual index for that device. If no device name was saved (old prefs), or if the name doesn't exist any more (presumably because the device was unplugged), then we fall back to the previous behavior of using the saved device index as is -- which will give fairly random results depending on what's currently in the device list, but then we can't help it.
Note that this doesn't provide hotplugging support, which is really what we'd like to have, but is currently impossible due to backend limitations. That is, you still can't plug or unplug devices and have Purr Data pick up the new device list while it keeps running. But at least Purr Data will not connect to the wrong devices on relaunch any more, which is a major annoyance when hotplugging audio or MIDI devices during a session (which is pretty common in this day and age).