|
From: Yoda-JM <yo...@us...> - 2010-08-15 14:52:54
|
Module: performous
Branch: joinmenu
Commit: 89d958378a472a339bf38db6c2ff6a81ec5c7451
Author: Tapio Vierros <tap...@gm...>
Date: Sun Jul 18 17:05:09 2010 +0300
Audio device matching by name, first exact, then if not found, partial.
---
libs/libda/include/libda/portaudio.hpp | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libs/libda/include/libda/portaudio.hpp b/libs/libda/include/libda/portaudio.hpp
index d6e33b1..c1ab993 100644
--- a/libs/libda/include/libda/portaudio.hpp
+++ b/libs/libda/include/libda/portaudio.hpp
@@ -58,14 +58,21 @@ namespace portaudio {
int tmp;
if (iss >> tmp && iss.get() == EOF && tmp >= 0 && tmp < count) val = tmp;
}
- // Try name matching
+ // Try matching exact name
if (val < 0) for (int i = 0; i != count; ++i) {
PaDeviceInfo const* info = Pa_GetDeviceInfo(i);
if (!info) continue;
if (inputDevice && info->maxInputChannels == 0) continue;
if (!inputDevice && info->maxOutputChannels == 0) continue;
- val = i;
- break;
+ if (info->name == name) { val = i; break; }
+ }
+ // Try matching partial name
+ if (val < 0) for (int i = 0; i != count; ++i) {
+ PaDeviceInfo const* info = Pa_GetDeviceInfo(i);
+ if (!info) continue;
+ if (inputDevice && info->maxInputChannels == 0) continue;
+ if (!inputDevice && info->maxOutputChannels == 0) continue;
+ if (std::string(info->name).find(name) != std::string::npos) { val = i; break; }
}
// Error handling
std::string dir = inputDevice ? "input" : "output";
|