Commit f7d37b38 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

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.
parent 4f5271a1
...@@ -942,7 +942,7 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa ...@@ -942,7 +942,7 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
if(RegOpenKeyW(HKEY_CURRENT_USER, reg_key, &key) == ERROR_SUCCESS){ if(RegOpenKeyW(HKEY_CURRENT_USER, reg_key, &key) == ERROR_SUCCESS){
const WCHAR *reg_x_name, *reg_vx_name; const WCHAR *reg_x_name, *reg_vx_name;
WCHAR def_id[256]; WCHAR def_id[256];
DWORD size = sizeof(def_id); DWORD size = sizeof(def_id), state;
if(flow == eRender){ if(flow == eRender){
reg_x_name = reg_out_nameW; reg_x_name = reg_out_nameW;
...@@ -957,8 +957,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa ...@@ -957,8 +957,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
(BYTE*)def_id, &size) == ERROR_SUCCESS){ (BYTE*)def_id, &size) == ERROR_SUCCESS){
hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device); hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device);
if(SUCCEEDED(hr)){ if(SUCCEEDED(hr)){
RegCloseKey(key); if(SUCCEEDED(IMMDevice_GetState(*device, &state)) &&
return S_OK; state == DEVICE_STATE_ACTIVE){
RegCloseKey(key);
return S_OK;
}
} }
TRACE("Unable to find voice device %s\n", wine_dbgstr_w(def_id)); TRACE("Unable to find voice device %s\n", wine_dbgstr_w(def_id));
...@@ -968,8 +971,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa ...@@ -968,8 +971,11 @@ static HRESULT WINAPI MMDevEnum_GetDefaultAudioEndpoint(IMMDeviceEnumerator *ifa
(BYTE*)def_id, &size) == ERROR_SUCCESS){ (BYTE*)def_id, &size) == ERROR_SUCCESS){
hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device); hr = IMMDeviceEnumerator_GetDevice(iface, def_id, device);
if(SUCCEEDED(hr)){ if(SUCCEEDED(hr)){
RegCloseKey(key); if(SUCCEEDED(IMMDevice_GetState(*device, &state)) &&
return S_OK; state == DEVICE_STATE_ACTIVE){
RegCloseKey(key);
return S_OK;
}
} }
TRACE("Unable to find device %s\n", wine_dbgstr_w(def_id)); TRACE("Unable to find device %s\n", wine_dbgstr_w(def_id));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment