mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 11:34:12 +00:00
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.
This commit is contained in:
parent
4f5271a17f
commit
f7d37b38fe
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue