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

winealsa.drv: Allow creation of the default device even if all real devices failed to open.

parent c0a8694b
...@@ -238,7 +238,8 @@ int WINAPI AUDDRV_GetPriority(void) ...@@ -238,7 +238,8 @@ int WINAPI AUDDRV_GetPriority(void)
} }
static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys, static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
UINT *num, snd_ctl_t *ctl, int card, const WCHAR *cardnameW) UINT *num, snd_ctl_t *ctl, int card, const WCHAR *cardnameW,
BOOL count_failed)
{ {
static const WCHAR dashW[] = {' ','-',' ',0}; static const WCHAR dashW[] = {' ','-',' ',0};
int err, device; int err, device;
...@@ -276,6 +277,8 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys, ...@@ -276,6 +277,8 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
if((err = snd_pcm_open(&handle, devnode, stream, SND_PCM_NONBLOCK)) < 0){ if((err = snd_pcm_open(&handle, devnode, stream, SND_PCM_NONBLOCK)) < 0){
WARN("The device \"%s\" failed to open, pretending it doesn't exist: %d (%s)\n", WARN("The device \"%s\" failed to open, pretending it doesn't exist: %d (%s)\n",
devnode, err, snd_strerror(err)); devnode, err, snd_strerror(err));
if(count_failed)
++(*num);
continue; continue;
} }
...@@ -328,7 +331,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys, ...@@ -328,7 +331,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
} }
static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys, static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys,
UINT *num) UINT *num, BOOL count_failed)
{ {
int err, card; int err, card;
...@@ -365,7 +368,8 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys, ...@@ -365,7 +368,8 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys,
} }
MultiByteToWideChar(CP_UNIXCP, 0, cardname, -1, cardnameW, len); MultiByteToWideChar(CP_UNIXCP, 0, cardname, -1, cardnameW, len);
alsa_get_card_devices(flow, ids, keys, num, ctl, card, cardnameW); alsa_get_card_devices(flow, ids, keys, num, ctl, card, cardnameW,
count_failed);
HeapFree(GetProcessHeap(), 0, cardnameW); HeapFree(GetProcessHeap(), 0, cardnameW);
...@@ -386,7 +390,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys, ...@@ -386,7 +390,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys,
TRACE("%d %p %p %p %p\n", flow, ids, keys, num, def_index); TRACE("%d %p %p %p %p\n", flow, ids, keys, num, def_index);
hr = alsa_enum_devices(flow, NULL, NULL, num); hr = alsa_enum_devices(flow, NULL, NULL, num, TRUE);
if(FAILED(hr)) if(FAILED(hr))
return hr; return hr;
...@@ -411,7 +415,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys, ...@@ -411,7 +415,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys,
memcpy((*keys)[0], defname, sizeof(defname)); memcpy((*keys)[0], defname, sizeof(defname));
*def_index = 0; *def_index = 0;
hr = alsa_enum_devices(flow, (*ids) + 1, (*keys) + 1, num); hr = alsa_enum_devices(flow, (*ids) + 1, (*keys) + 1, num, FALSE);
if(FAILED(hr)){ if(FAILED(hr)){
int i; int i;
for(i = 0; i < *num; ++i){ for(i = 0; i < *num; ++i){
......
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