aboutsummaryrefslogtreecommitdiffstats
path: root/pulse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'pulse.cc')
-rw-r--r--pulse.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/pulse.cc b/pulse.cc
index 3a248de..f6b633b 100644
--- a/pulse.cc
+++ b/pulse.cc
@@ -151,12 +151,23 @@ Card* PulseClient::GetCard(const uint32_t& index) {
Card* PulseClient::GetCard(const string& name) {
long val;
+ vector<Card> res;
if (xstrtol(name.c_str(), &val) == 0) return GetCard(val);
for (Card& card : cards_) {
- if (card.name_ == name) return &card;
+ if (card.name_.find(name) != string::npos) res.push_back(card);
}
- return nullptr;
+
+ switch (res.size()) {
+ case 0:
+ return nullptr;
+ case 1:
+ break;
+ default:
+ warnx("warning: ambiguous result for '%s', using '%s'",
+ name.c_str(), res[0].name_.c_str());
+ }
+ return &res[0];
}
Card* PulseClient::GetCard(const Device& device) {
@@ -176,12 +187,24 @@ Device* PulseClient::get_device(vector<Device>& devices,
Device* PulseClient::get_device(vector<Device>& devices, const string& name) {
long val;
+ vector<Device> res;
if (xstrtol(name.c_str(), &val) == 0) return get_device(devices, val);
for (Device& device : devices) {
- if (device.name_ == name) return &device;
+ if (device.name_.find(name) != string::npos) res.push_back(device);
}
- return nullptr;
+
+ switch (res.size()) {
+ case 0:
+ return nullptr;
+ case 1:
+ break;
+ default:
+ warnx("warning: ambiguous result for '%s', using '%s'",
+ name.c_str(), res[0].name_.c_str());
+ }
+
+ return &res[0];
}
Device* PulseClient::GetDevice(const uint32_t& index, enum DeviceType type) {