From 205e664b4d820aa3b047c035266f32b4b81a0414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 27 Jan 2023 13:08:07 +0800 Subject: [PATCH] Sound (Windows): show more detailed information --- src/detection/sound/sound_windows.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index 23f094feb..57b8fa45b 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -34,7 +34,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = NULL; - if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDevices))) + if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED, &pDevices))) return "EnumAudioEndpoints() failed"; uint32_t deviceCount; @@ -55,9 +55,13 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) continue; + DWORD immState; + if (FAILED(immDevice->GetState(&immState))) + continue; + FFSoundDevice* device = (FFSoundDevice*) ffListAdd(devices); device->main = wcscmp(mainDeviceId, immDeviceId) == 0; - device->active = device->main; + device->active = !!(immState & DEVICE_STATE_ACTIVE); device->volume = 0; ffStrbufInit(&device->name); ffStrbufInit(&device->manufacturer); @@ -65,7 +69,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U { PROPVARIANT __attribute__((__cleanup__(PropVariantClear))) friendlyName; PropVariantInit(&friendlyName); - if (SUCCEEDED(immPropStore->GetValue(PKEY_Device_DeviceDesc, &friendlyName))) + if (SUCCEEDED(immPropStore->GetValue(PKEY_Device_FriendlyName, &friendlyName))) ffStrbufSetWS(&device->name, friendlyName.pwszVal); if (SUCCEEDED(immPropStore->GetValue(PKEY_DeviceInterface_FriendlyName, &friendlyName))) ffStrbufSetWS(&device->manufacturer, friendlyName.pwszVal);