From 33d91ceeec2f0f8d7f248f97966357388115a995 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 11 Sep 2020 01:40:36 -0700 Subject: Avoid repeating string literals --- alc/backends/wasapi.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'alc/backends') diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 76c249de..f1f027e6 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -251,6 +251,8 @@ al::vector CaptureDevices; using NameGUIDPair = std::pair; NameGUIDPair get_device_name_and_guid(IMMDevice *device) { + static constexpr char UnknownName[]{"Unknown Device Name"}; + static constexpr char UnknownGuid[]{"Unknown Device GUID"}; std::string name{DEVNAME_HEAD}; std::string guid; @@ -259,7 +261,7 @@ NameGUIDPair get_device_name_and_guid(IMMDevice *device) if(FAILED(hr)) { WARN("OpenPropertyStore failed: 0x%08lx\n", hr); - return std::make_pair("Unknown Device Name", "Unknown Device GUID"); + return std::make_pair(UnknownName, UnknownGuid); } PropVariant pvprop; @@ -267,14 +269,14 @@ NameGUIDPair get_device_name_and_guid(IMMDevice *device) if(FAILED(hr)) { WARN("GetValue Device_FriendlyName failed: 0x%08lx\n", hr); - name += "Unknown Device Name"; + name += UnknownName; } else if(pvprop->vt == VT_LPWSTR) name += wstr_to_utf8(pvprop->pwszVal); else { WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvprop->vt); - name += "Unknown Device Name"; + name += UnknownName; } pvprop.clear(); @@ -282,14 +284,14 @@ NameGUIDPair get_device_name_and_guid(IMMDevice *device) if(FAILED(hr)) { WARN("GetValue AudioEndpoint_GUID failed: 0x%08lx\n", hr); - guid = "Unknown Device GUID"; + guid = UnknownGuid; } else if(pvprop->vt == VT_LPWSTR) guid = wstr_to_utf8(pvprop->pwszVal); else { WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvprop->vt); - guid = "Unknown Device GUID"; + guid = UnknownGuid; } return std::make_pair(std::move(name), std::move(guid)); -- cgit v1.2.3