diff options
author | Paul Adenot <[email protected]> | 2020-09-17 12:01:46 +0200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2020-09-17 14:07:31 +0200 |
commit | b66d91554b8c3bf3159c04577bcf46a1a451e718 (patch) | |
tree | 09380e81cfdcec28ad34a8e84a8173bfcd8aaeb7 | |
parent | 61293b23d3b7ad270a15a11ced3427e2e6ca2d87 (diff) | |
download | cubeb-b66d91554b8c3bf3159c04577bcf46a1a451e718.tar.gz cubeb-b66d91554b8c3bf3159c04577bcf46a1a451e718.zip |
Always return a valid string (possibly empty) for the group_id and the friendly_name in the WASAPI backend
-rw-r--r-- | src/cubeb_wasapi.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp index a0b42ee..d46b0f2 100644 --- a/src/cubeb_wasapi.cpp +++ b/src/cubeb_wasapi.cpp @@ -2932,6 +2932,12 @@ wasapi_create_device(cubeb * ctx, cubeb_device_info& ret, IMMDeviceEnumerator * hr = propstore->GetValue(PKEY_Device_FriendlyName, &namevar); if (SUCCEEDED(hr)) { ret.friendly_name = wstr_to_utf8(namevar.pwszVal); + } else { + // This is not fatal, but a valid string is expected in all cases. + char* empty = new char[1]; + empty[0] = '\0'; + ret.friendly_name = empty; + } devnode = wasapi_get_device_node(enumerator, dev); if (devnode) { @@ -2946,6 +2952,13 @@ wasapi_create_device(cubeb * ctx, cubeb_device_info& ret, IMMDeviceEnumerator * } } + if (!ret.group_id) { + // This is not fatal, but a valid string is expected in all cases. + char* empty = new char[1]; + empty[0] = '\0'; + ret.group_id = empty; + } + ret.preferred = CUBEB_DEVICE_PREF_NONE; if (wasapi_is_default_device(flow, eConsole, device_id.get(), enumerator)) { ret.preferred = (cubeb_device_pref)(ret.preferred | CUBEB_DEVICE_PREF_MULTIMEDIA); @@ -3005,6 +3018,8 @@ wasapi_create_device(cubeb * ctx, cubeb_device_info& ret, IMMDeviceEnumerator * ret.latency_hi = 0; } + XASSERT(ret.friendly_name && ret.group_id); + return CUBEB_OK; } |