mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 18:45:29 +00:00
Return slightly more descriptive soundio errors when RefreshDevices fails for WASAPI.
This commit is contained in:
parent
17dc688ddc
commit
a8201986a0
19
src/wasapi.c
19
src/wasapi.c
|
@ -671,6 +671,9 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
{
|
{
|
||||||
if(hr != E_NOTFOUND) {
|
if(hr != E_NOTFOUND) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
|
if(hr == E_OUTOFMEMORY) {
|
||||||
|
return SoundIoErrorNoMem;
|
||||||
|
}
|
||||||
return SoundIoErrorOpeningDevice;
|
return SoundIoErrorOpeningDevice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,7 +684,9 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
}
|
}
|
||||||
if (FAILED(hr = IMMDevice_GetId(rd.default_render_device, &rd.lpwstr))) {
|
if (FAILED(hr = IMMDevice_GetId(rd.default_render_device, &rd.lpwstr))) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
return SoundIoErrorOpeningDevice;
|
// MSDN states the IMMDevice_GetId can fail if the device is NULL, or if we're out of memory
|
||||||
|
// We know the device point isn't NULL so we're necessarily out of memory
|
||||||
|
return SoundIoErrorNoMem;
|
||||||
}
|
}
|
||||||
if ((err = from_lpwstr(rd.lpwstr, &rd.default_render_id, &rd.default_render_id_len))) {
|
if ((err = from_lpwstr(rd.lpwstr, &rd.default_render_id, &rd.default_render_id_len))) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
|
@ -695,6 +700,9 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
{
|
{
|
||||||
if(hr != E_NOTFOUND) {
|
if(hr != E_NOTFOUND) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
|
if(hr == E_OUTOFMEMORY) {
|
||||||
|
return SoundIoErrorNoMem;
|
||||||
|
}
|
||||||
return SoundIoErrorOpeningDevice;
|
return SoundIoErrorOpeningDevice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,7 +713,9 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
}
|
}
|
||||||
if (FAILED(hr = IMMDevice_GetId(rd.default_capture_device, &rd.lpwstr))) {
|
if (FAILED(hr = IMMDevice_GetId(rd.default_capture_device, &rd.lpwstr))) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
return SoundIoErrorOpeningDevice;
|
// MSDN states the IMMDevice_GetId can fail if the device is NULL, or if we're out of memory
|
||||||
|
// We know the device point isn't NULL so we're necessarily out of memory.
|
||||||
|
return SoundIoErrorNoMem;
|
||||||
}
|
}
|
||||||
if ((err = from_lpwstr(rd.lpwstr, &rd.default_capture_id, &rd.default_capture_id_len))) {
|
if ((err = from_lpwstr(rd.lpwstr, &rd.default_capture_id, &rd.default_capture_id_len))) {
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
|
@ -718,11 +728,16 @@ static int refresh_devices(struct SoundIoPrivate *si) {
|
||||||
eAll, DEVICE_STATE_ACTIVE, &rd.collection)))
|
eAll, DEVICE_STATE_ACTIVE, &rd.collection)))
|
||||||
{
|
{
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
|
if(hr == E_OUTOFMEMORY) {
|
||||||
|
return SoundIoErrorNoMem;
|
||||||
|
}
|
||||||
return SoundIoErrorOpeningDevice;
|
return SoundIoErrorOpeningDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT unsigned_count;
|
UINT unsigned_count;
|
||||||
if (FAILED(hr = IMMDeviceCollection_GetCount(rd.collection, &unsigned_count))) {
|
if (FAILED(hr = IMMDeviceCollection_GetCount(rd.collection, &unsigned_count))) {
|
||||||
|
// In theory this shouldn't happen since the only documented failure case is that
|
||||||
|
// rd.collection is NULL, but then EnumAudioEndpoints should have failed.
|
||||||
deinit_refresh_devices(&rd);
|
deinit_refresh_devices(&rd);
|
||||||
return SoundIoErrorOpeningDevice;
|
return SoundIoErrorOpeningDevice;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue