winealsa.drv: Fix default device creation logic.

This commit is contained in:
Andrew Eikum 2011-09-30 08:34:26 -05:00 committed by Alexandre Julliard
parent 25ae02b4ed
commit d41f6a6f02
1 changed files with 7 additions and 13 deletions

View File

@ -294,8 +294,7 @@ static BOOL alsa_try_open(const char *devnode, snd_pcm_stream_t stream)
} }
static HRESULT alsa_get_card_devices(snd_pcm_stream_t stream, WCHAR **ids, char **keys, static HRESULT alsa_get_card_devices(snd_pcm_stream_t stream, 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;
@ -327,11 +326,8 @@ static HRESULT alsa_get_card_devices(snd_pcm_stream_t stream, WCHAR **ids, char
} }
sprintf(devnode, "plughw:%d,%d", card, device); sprintf(devnode, "plughw:%d,%d", card, device);
if(!alsa_try_open(devnode, stream)){ if(!alsa_try_open(devnode, stream))
if(count_failed)
++(*num);
continue; continue;
}
if(ids && keys){ if(ids && keys){
DWORD len, cardlen; DWORD len, cardlen;
@ -380,7 +376,7 @@ static HRESULT alsa_get_card_devices(snd_pcm_stream_t stream, WCHAR **ids, char
} }
static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys, static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys,
UINT *num, BOOL count_failed) UINT *num)
{ {
snd_pcm_stream_t stream = (flow == eRender ? SND_PCM_STREAM_PLAYBACK : snd_pcm_stream_t stream = (flow == eRender ? SND_PCM_STREAM_PLAYBACK :
SND_PCM_STREAM_CAPTURE); SND_PCM_STREAM_CAPTURE);
@ -397,8 +393,7 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, char **keys,
memcpy(*keys, defname, sizeof(defname)); memcpy(*keys, defname, sizeof(defname));
} }
++*num; ++*num;
}else if(count_failed) }
++*num;
for(err = snd_card_next(&card); card != -1 && err >= 0; for(err = snd_card_next(&card); card != -1 && err >= 0;
err = snd_card_next(&card)){ err = snd_card_next(&card)){
@ -431,8 +426,7 @@ 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(stream, ids, keys, num, ctl, card, cardnameW, alsa_get_card_devices(stream, ids, keys, num, ctl, card, cardnameW);
count_failed);
HeapFree(GetProcessHeap(), 0, cardnameW); HeapFree(GetProcessHeap(), 0, cardnameW);
@ -453,7 +447,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, TRUE); hr = alsa_enum_devices(flow, NULL, NULL, num);
if(FAILED(hr)) if(FAILED(hr))
return hr; return hr;
@ -474,7 +468,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, char ***keys,
*def_index = 0; *def_index = 0;
hr = alsa_enum_devices(flow, *ids, *keys, num, FALSE); hr = alsa_enum_devices(flow, *ids, *keys, num);
if(FAILED(hr)){ if(FAILED(hr)){
int i; int i;
for(i = 0; i < *num; ++i){ for(i = 0; i < *num; ++i){