mmdevapi: Only enumerate devices that can be opened during initialization.
This commit is contained in:
parent
deac5ceb1c
commit
2174717fbd
|
@ -229,19 +229,22 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
|
||||||
static const WCHAR dashW[] = {' ','-',' ',0};
|
static const WCHAR dashW[] = {' ','-',' ',0};
|
||||||
int err, device;
|
int err, device;
|
||||||
snd_pcm_info_t *info;
|
snd_pcm_info_t *info;
|
||||||
|
snd_pcm_stream_t stream = (flow == eRender ? SND_PCM_STREAM_PLAYBACK :
|
||||||
|
SND_PCM_STREAM_CAPTURE);
|
||||||
|
|
||||||
info = HeapAlloc(GetProcessHeap(), 0, snd_pcm_info_sizeof());
|
info = HeapAlloc(GetProcessHeap(), 0, snd_pcm_info_sizeof());
|
||||||
if(!info)
|
if(!info)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
snd_pcm_info_set_subdevice(info, 0);
|
snd_pcm_info_set_subdevice(info, 0);
|
||||||
snd_pcm_info_set_stream(info,
|
snd_pcm_info_set_stream(info, stream);
|
||||||
flow == eRender ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE);
|
|
||||||
|
|
||||||
device = -1;
|
device = -1;
|
||||||
for(err = snd_ctl_pcm_next_device(ctl, &device); device != -1 && err >= 0;
|
for(err = snd_ctl_pcm_next_device(ctl, &device); device != -1 && err >= 0;
|
||||||
err = snd_ctl_pcm_next_device(ctl, &device)){
|
err = snd_ctl_pcm_next_device(ctl, &device)){
|
||||||
const char *devname;
|
const char *devname;
|
||||||
|
char devnode[32];
|
||||||
|
snd_pcm_t *handle;
|
||||||
|
|
||||||
snd_pcm_info_set_device(info, device);
|
snd_pcm_info_set_device(info, device);
|
||||||
|
|
||||||
|
@ -255,6 +258,15 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(devnode, "hw:%d,%d", card, device);
|
||||||
|
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",
|
||||||
|
devnode, err, snd_strerror(err));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_pcm_close(handle);
|
||||||
|
|
||||||
if(ids && keys){
|
if(ids && keys){
|
||||||
DWORD len, cardlen;
|
DWORD len, cardlen;
|
||||||
|
|
||||||
|
@ -286,7 +298,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, WCHAR **ids, char **keys,
|
||||||
HeapFree(GetProcessHeap(), 0, ids[*num]);
|
HeapFree(GetProcessHeap(), 0, ids[*num]);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
sprintf(keys[*num], "hw:%d,%d", card, device);
|
memcpy(keys[*num], devnode, sizeof(devnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
++(*num);
|
++(*num);
|
||||||
|
|
|
@ -285,6 +285,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
|
||||||
*def_index = -1;
|
*def_index = -1;
|
||||||
for(i = 0; i < sysinfo.numaudios; ++i){
|
for(i = 0; i < sysinfo.numaudios; ++i){
|
||||||
oss_audioinfo ai = {0};
|
oss_audioinfo ai = {0};
|
||||||
|
int fd;
|
||||||
|
|
||||||
ai.dev = i;
|
ai.dev = i;
|
||||||
if(ioctl(mixer_fd, SNDCTL_AUDIOINFO, &ai) < 0){
|
if(ioctl(mixer_fd, SNDCTL_AUDIOINFO, &ai) < 0){
|
||||||
|
@ -293,6 +294,17 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(flow == eRender)
|
||||||
|
fd = open(ai.devnode, O_WRONLY, 0);
|
||||||
|
else
|
||||||
|
fd = open(ai.devnode, O_RDONLY, 0);
|
||||||
|
if(fd < 0){
|
||||||
|
WARN("Opening device \"%s\" failed, pretending it doesn't exist: %d (%s)",
|
||||||
|
ai.devnode, errno, strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
|
||||||
if((flow == eCapture && (ai.caps & PCM_CAP_INPUT)) ||
|
if((flow == eCapture && (ai.caps & PCM_CAP_INPUT)) ||
|
||||||
(flow == eRender && (ai.caps & PCM_CAP_OUTPUT))){
|
(flow == eRender && (ai.caps & PCM_CAP_OUTPUT))){
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
Loading…
Reference in New Issue