summaryrefslogtreecommitdiff
path: root/RtAudio.cpp
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2015-04-05 17:20:10 -0400
committerGary Scavone <gary@music.mcgill.ca>2015-04-05 17:20:10 -0400
commit661a34e77d2a34d4144e11c82715082eaf0fd4b3 (patch)
tree41f7f4b7393aa8cbc2626c94d0322f967fe6748d /RtAudio.cpp
parent8e58b61517bff3edcd8dac6afffdf538f2fa1ca1 (diff)
Update to DS code for getDeviceCount() when cleaning out devices that may have disappeared
Diffstat (limited to 'RtAudio.cpp')
-rw-r--r--RtAudio.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp
index 4d4c85f..dfa992d 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -5295,14 +5295,11 @@ unsigned int RtApiDs :: getDeviceCount( void )
error( RtAudioError::WARNING );
}
- // Clean out any devices that may have disappeared.
- std::vector< int > indices;
- for ( unsigned int i=0; i<dsDevices.size(); i++ )
- if ( dsDevices[i].found == false ) indices.push_back( i );
- //unsigned int nErased = 0;
- for ( unsigned int i=0; i<indices.size(); i++ )
- dsDevices.erase( dsDevices.begin()+indices[i] );
- //dsDevices.erase( dsDevices.begin()-nErased++ );
+ // Clean out any devices that may have disappeared (code update submitted by Eli Zehngut).
+ for ( unsigned int i=0; i<dsDevices.size(); ) {
+ if ( dsDevices[i].found == false ) dsDevices.erase( dsDevices.begin() + i );
+ else i++;
+ }
return static_cast<unsigned int>(dsDevices.size());
}