aboutsummaryrefslogtreecommitdiff
path: root/backends/midi/alsa.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2010-07-27 13:01:10 +0000
committerJohannes Schickel2010-07-27 13:01:10 +0000
commit2db4e71b6693f47f2fc48c78e8cff5e570c1f8d1 (patch)
treece2ee4fa6aef1bbb88ad2119f01ab2f2cc060afb /backends/midi/alsa.cpp
parent601fe8ee7d5c2bffdc117ee6ff97d2d2df373d6c (diff)
downloadscummvm-rg350-2db4e71b6693f47f2fc48c78e8cff5e570c1f8d1.tar.gz
scummvm-rg350-2db4e71b6693f47f2fc48c78e8cff5e570c1f8d1.tar.bz2
scummvm-rg350-2db4e71b6693f47f2fc48c78e8cff5e570c1f8d1.zip
ALSA: Simplify device querying code.
Thanks to eriktorbjorn for some quick testing. svn-id: r51366
Diffstat (limited to 'backends/midi/alsa.cpp')
-rw-r--r--backends/midi/alsa.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index a895ef8b80..1f7f7d2ba3 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -314,46 +314,41 @@ AlsaDevices AlsaMusicPlugin::getAlsaDevices() const {
MusicDevices AlsaMusicPlugin::getDevices() const {
MusicDevices devices;
- Common::Array<bool> used;
AlsaDevices::iterator d;
- int i;
AlsaDevices alsaDevices = getAlsaDevices();
- for (i = 0, d = alsaDevices.begin(); d != alsaDevices.end(); ++i, ++d) {
- used.push_back(false);
- }
-
// Since the default behaviour is to use the first device in the list,
// try to put something sensible there. We used to have 17:0 and 65:0
// as defaults.
- for (i = 0, d = alsaDevices.begin(); d != alsaDevices.end(); ++i, ++d) {
- int client = d->getClient();
+ for (d = alsaDevices.begin(); d != alsaDevices.end();) {
+ const int client = d->getClient();
+
if (client == 17 || client == 65) {
devices.push_back(MusicDevice(this, d->getName(), d->getType()));
- used[i] = true;
+ d = alsaDevices.erase(d);
+ } else {
+ ++d;
}
}
// 128:0 is probably TiMidity, or something like that, so that's
// probably a good second choice.
- for (i = 0, d = alsaDevices.begin(); d != alsaDevices.end(); ++i, ++d) {
+ for (d = alsaDevices.begin(); d != alsaDevices.end();) {
if (d->getClient() == 128) {
devices.push_back(MusicDevice(this, d->getName(), d->getType()));
- used[i] = true;
+ d = alsaDevices.erase(d);
+ } else {
+ ++d;
}
}
// Add the remaining devices in the order they were found.
- for (i = 0, d = alsaDevices.begin(); d != alsaDevices.end(); ++i, ++d) {
-
- if (!used[i]) {
- devices.push_back(MusicDevice(this, d->getName(), d->getType()));
- }
- }
+ for (d = alsaDevices.begin(); d != alsaDevices.end(); ++d)
+ devices.push_back(MusicDevice(this, d->getName(), d->getType()));
return devices;
}