diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-21 00:29:35 -0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-22 02:42:38 +0200 |
commit | ad6acddbcf5009347ddfadd798f871b09f1ba158 (patch) | |
tree | c09582a3c33a9c8a0f49e942620a52f7fc4b7c3c | |
parent | d68fa0531f50937601d354a81ffa09c9a7e8388e (diff) | |
download | mpv-ad6acddbcf5009347ddfadd798f871b09f1ba158.tar.bz2 mpv-ad6acddbcf5009347ddfadd798f871b09f1ba158.tar.xz |
ao_wasapi: Don't search for devices as part of validation
This could turn valid parameters into syntax errors by the mere presence
or abscence of a device (e.g. USB audio devices), so don't do that.
We do validate that, if the parameter is an integer, it is not negative.
We also respond to the "help" parameter, which does the same as the "list"
suboption but exits after listing.
Demote the validation logging to MSGL_DBG2.
-rw-r--r-- | audio/out/ao_wasapi.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 55fc3006ba..6e26fb5061 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -806,39 +806,22 @@ exit_label: static int validate_device(const m_option_t *opt, struct bstr name, struct bstr param) { - IMMDevice *pDevice = NULL; - - mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: validating device=%s\n", param.start); - if (bstr_equals0(param, "help")) { enumerate_devices(); return M_OPT_EXIT; } - CoInitialize(NULL); + mp_msg(MSGT_AO, MSGL_DBG2, "ao-wasapi: validating device=%s\n", param.start); - int devno = -1; - char *devid = NULL; + char *end; + int devno = (int) strtol(param.start, &end, 10); - if (bstr_startswith0(param, "{")) { // ID as printed by enumerate_devices - devid = param.start; - } else { - unsigned char *end; - devno = (int) strtol(param.start, (char**)&end, 10); - if (end == param.start || *end || devno < 0) { - mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: invalid number \"%s\"!\n", param.start); - return M_OPT_INVALID; - } - } int ret = 1; - if (FAILED(find_and_load_device(&pDevice, devno, devid))) { + if ((end == (void*)param.start || *end) && devno < 0) ret = M_OPT_OUT_OF_RANGE; - } - mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: device=%s %svalid\n", - param.start, ret == 1 ? "" : "not "); - SAFE_RELEASE(pDevice, IMMDevice_Release(pDevice)); - CoUninitialize(); + mp_msg(MSGT_AO, MSGL_DBG2, "ao-wasapi: device=%s %svalid\n", + param.start, ret == 1 ? "" : "not "); return ret; } |