Andrew Eikum : mmdevapi: Only return ACTIVE devices from GetDefaultAudioEndpoint.
Alexandre Julliard
julliard at winehq.org
Wed Feb 15 13:14:04 CST 2012
Module: wine
Branch: master
Commit: f7d37b38fe5914cb81f0fbca3902b0862eb842d9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f7d37b38fe5914cb81f0fbca3902b0862eb842d9
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Tue Feb 14 11:50:05 2012 -0600
mmdevapi: Only return ACTIVE devices from GetDefaultAudioEndpoint.
This prevents invalid devices from being created if the user adds a
device, sets it as default, and then removes it.
---
dlls/mmdevapi/devenum.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c
index 06a1adf..ba55368 100644
--- a/dlls/mmdevapi/devenum.c
+++ b/dlls/mmdevapi/devenum.c
@@ -942,7 +942,7 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
if(RegOpenKeyW(HKEY_CURRENT_USER, reg_key, &key) == ERROR_SUCCESS){
const WCHAR *reg_x_name, *reg_vx_name;
WCHAR def_id[256];
- DWORD size = sizeof(def_id);
+ DWORD size = sizeof(def_id), state;
if(flow == eRender){
reg_x_name = reg_out_nameW;
@@ -957,8 +957,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
(BYTE*)def_id, &size) == ERROR_SUCCESS){
hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device);
if(SUCCEEDED(hr)){
- RegCloseKey(key);
- return S_OK;
+ if(SUCCEEDED(IMMDevice_GetState(*device, &state)) &&
+ state == DEVICE_STATE_ACTIVE){
+ RegCloseKey(key);
+ return S_OK;
+ }
}
TRACE("Unable to find voice device %s\n", wine_dbgstr_w(def_id));
@@ -968,8 +971,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
(BYTE*)def_id, &size) == ERROR_SUCCESS){
hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device);
if(SUCCEEDED(hr)){
- RegCloseKey(key);
- return S_OK;
+ if(SUCCEEDED(IMMDevice_GetState(*device, &state)) &&
+ state == DEVICE_STATE_ACTIVE){
+ RegCloseKey(key);
+ return S_OK;
+ }
}
TRACE("Unable to find device %s\n", wine_dbgstr_w(def_id));
More information about the wine-cvs
mailing list