From fb84c6974d0026aab7e23aedd4136952b1c6ab7b Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Mon, 4 Jan 2016 17:04:40 -0800 Subject: ao_wasapi: avoid some redundant error messages in device selection If these error conditions are triggered, the called function will have already output a sufficiently informantive error message. --- audio/out/ao_wasapi_utils.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 39dbbb2cae..10f686c6ab 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -906,6 +906,8 @@ exit_label: static void select_device(struct wasapi_state *state, struct device_desc *d) { + if (!d) + return; MP_VERBOSE(state, "Selecting device \'%s\' (%s)\n", d->id, d->name); state->deviceID = talloc_memdup(NULL, d->deviceID, (wcslen(d->deviceID) + 1) * sizeof(wchar_t)); @@ -946,13 +948,9 @@ static HRESULT find_device(struct ao *ao) goto exit_label; if (!device.len) { + MP_VERBOSE(ao, "No device specified. Selecting default.\n"); d = default_device_desc(enumerator); - if (d) { - MP_VERBOSE(ao, "No device specified. Selecting default\n"); - select_device(state, d); - } else { - MP_ERR(ao, "Failed to get default device.\n"); - } + select_device(state, d); goto exit_label; } @@ -960,13 +958,9 @@ static HRESULT find_device(struct ao *ao) bstr rest; long long devno = bstrtoll(device, &rest, 10); if (!rest.len && 0 <= devno && devno < enumerator->count) { + MP_VERBOSE(ao, "Selecting device by number: #%lld\n", devno); d = device_desc_for_num(enumerator, devno); - if (d) { - MP_VERBOSE(ao, "Selecting device by number: #%lld\n", devno); - select_device(state, d); - } else { - MP_ERR(ao, "Failed to get device #%lld.\n", devno); - } + select_device(state, d); goto exit_label; } @@ -974,10 +968,8 @@ static HRESULT find_device(struct ao *ao) bstr_eatstart0(&device, "{0.0.0.00000000}."); for (int i = 0; i < enumerator->count; i++) { d = device_desc_for_num(enumerator, i); - if (!d) { - MP_ERR(ao, "Failed to get device #%d.\n", i); + if (!d) goto exit_label; - } if (bstrcmp(device, bstr_strip(bstr0(d->id))) == 0) { MP_VERBOSE(ao, "Selecting device by id: \'%.*s\'\n", BSTR_P(device)); -- cgit v1.2.3