diff options
author | Chris Robinson <[email protected]> | 2018-11-01 16:00:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-01 16:00:16 -0700 |
commit | 11967dc2dae5e8364dc78bea6f644570e06bf999 (patch) | |
tree | 27c456aa83db4dec78bdb82947ce00e1b29ab2d5 /Alc/backends/pulseaudio.cpp | |
parent | 69162cf9c6dcf938d5c7d1f949f307142604c65a (diff) |
Use a wrapper function to simplify a check
Diffstat (limited to 'Alc/backends/pulseaudio.cpp')
-rw-r--r-- | Alc/backends/pulseaudio.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp index 15f02e1a..a52a028d 100644 --- a/Alc/backends/pulseaudio.cpp +++ b/Alc/backends/pulseaudio.cpp @@ -516,6 +516,14 @@ struct DevMap { { } }; +static bool checkName(const std::vector<DevMap> &list, const std::string &name) +{ + return std::find_if(list.cbegin(), list.cend(), + [&name](const DevMap &entry) -> bool + { return entry.name == name; } + ) != list.cend(); +} + static std::vector<DevMap> PlaybackDevices; static std::vector<DevMap> CaptureDevices; @@ -612,10 +620,7 @@ static void PulsePlayback_deviceCallback(pa_context *UNUSED(context), const pa_s */ int count{1}; std::string newname{info->description}; - while(std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(), - [&newname](const DevMap &entry) -> bool - { return entry.name == newname; } - ) != PlaybackDevices.cend()) + while(checkName(PlaybackDevices, newname)) { newname = info->description; newname += " #"; @@ -1323,10 +1328,7 @@ static void PulseCapture_deviceCallback(pa_context *UNUSED(context), const pa_so */ int count{1}; std::string newname{info->description}; - while(std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(), - [&newname](const DevMap &entry) -> bool - { return entry.name == newname; } - ) != CaptureDevices.cend()) + while(checkName(CaptureDevices, newname)) { newname = info->description; newname += " #"; |