diff options
author | Chris Robinson <[email protected]> | 2020-09-10 22:05:25 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-10 22:05:25 -0700 |
commit | a4bfba4cb56686860c3edd9d910703b1c0caf209 (patch) | |
tree | 22e7d581bf01428fb933def647fef3496864cf74 | |
parent | 21162cf5fc26f07c4cc90870f9de0293dabbc273 (diff) |
Recognize GUID name strings with the DSound backend
-rw-r--r-- | alc/backends/dsound.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index c1921430..1c0b371c 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -329,11 +329,18 @@ void DSoundPlayback::open(const ALCchar *name) else { auto iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(), - [name](const DevMap &entry) -> bool - { return entry.name == name; } - ); + [name](const DevMap &entry) -> bool { return entry.name == name; }); if(iter == PlaybackDevices.cend()) - throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name}; + { + GUID id{}; + hr = CLSIDFromString(utf8_to_wstr(name).c_str(), &id); + if(SUCCEEDED(hr)) + iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(), + [&id](const DevMap &entry) -> bool { return entry.guid == id; }); + if(iter == PlaybackDevices.cend()) + throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", + name}; + } guid = &iter->guid; } @@ -608,11 +615,18 @@ void DSoundCapture::open(const ALCchar *name) else { auto iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(), - [name](const DevMap &entry) -> bool - { return entry.name == name; } - ); + [name](const DevMap &entry) -> bool { return entry.name == name; }); if(iter == CaptureDevices.cend()) - throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", name}; + { + GUID id{}; + hr = CLSIDFromString(utf8_to_wstr(name).c_str(), &id); + if(SUCCEEDED(hr)) + iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(), + [&id](const DevMap &entry) -> bool { return entry.guid == id; }); + if(iter == CaptureDevices.cend()) + throw al::backend_exception{ALC_INVALID_VALUE, "Device name \"%s\" not found", + name}; + } guid = &iter->guid; } |