aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2022-04-02 15:25:01 +1300
committerMatthew Gregan <[email protected]>2022-04-11 20:35:16 +1200
commit1079b1f926f3494371d693be9a1a742aa8e0d102 (patch)
tree9c005b9dc525322552cf408bcbeca152371a9ae8
parent7864397ce16758d0994380676825a44fa4578b87 (diff)
downloadcubeb-1079b1f926f3494371d693be9a1a742aa8e0d102.tar.gz
cubeb-1079b1f926f3494371d693be9a1a742aa8e0d102.zip
wasapi: Avoid enumerating DEVICE_STATE_NOTPRESENT devices.
Devices in this state are not visible in the Sound Control Panel or other typical places in the OS audio UI, so there's little point in including them in cubeb's device list. On my test machine, this reduces the number of devices enumerated from 118 to 25 - reducing the cost of an initial cubeb_enumerate_devices from ~215ms to ~67ms (and a subsequent call from ~22ms to ~14ms).
-rw-r--r--src/cubeb_wasapi.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index fbdbdca..7e1c1e5 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -3359,8 +3359,10 @@ wasapi_enumerate_devices(cubeb * context, cubeb_device_type type,
return CUBEB_ERROR;
}
- hr = enumerator->EnumAudioEndpoints(flow, DEVICE_STATEMASK_ALL,
- collection.receive());
+ hr = enumerator->EnumAudioEndpoints(
+ flow,
+ DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED | DEVICE_STATE_UNPLUGGED,
+ collection.receive());
if (FAILED(hr)) {
LOG("Could not enumerate audio endpoints: %lx", hr);
return CUBEB_ERROR;