mirror of https://github.com/mpv-player/mpv
ao_wasapi: correct check for specified device on default change
Correctly avoid a reload if the current device was specified by the user through --audio-device. Previously, we only recognized if the user had specified --ao=wasapi:device=.
This commit is contained in:
parent
f1072be3b7
commit
e927ff1666
|
@ -119,6 +119,7 @@ char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey);
|
||||||
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
|
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
|
||||||
|
|
||||||
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
|
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
|
||||||
|
bstr wasapi_get_specified_device_string(struct ao *ao);
|
||||||
LPWSTR find_deviceID(struct ao *ao);
|
LPWSTR find_deviceID(struct ao *ao);
|
||||||
|
|
||||||
void wasapi_dispatch(struct ao *ao);
|
void wasapi_dispatch(struct ao *ao);
|
||||||
|
|
|
@ -122,7 +122,6 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
|
||||||
{
|
{
|
||||||
change_notify *change = (change_notify *)This;
|
change_notify *change = (change_notify *)This;
|
||||||
struct ao *ao = change->ao;
|
struct ao *ao = change->ao;
|
||||||
struct wasapi_state *state = ao->priv;
|
|
||||||
|
|
||||||
// don't care about "eCapture" or non-"eMultimedia" roles
|
// don't care about "eCapture" or non-"eMultimedia" roles
|
||||||
if (flow == eCapture || role != eMultimedia) return S_OK;
|
if (flow == eCapture || role != eMultimedia) return S_OK;
|
||||||
|
@ -133,9 +132,10 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
|
||||||
ao_hotplug_event(ao);
|
ao_hotplug_event(ao);
|
||||||
} else {
|
} else {
|
||||||
// stay on the device the user specified
|
// stay on the device the user specified
|
||||||
if (state->opt_device) {
|
bstr device = wasapi_get_specified_device_string(ao);
|
||||||
|
if (device.len) {
|
||||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
|
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
|
||||||
"staying on specified device %s\n", state->opt_device);
|
"staying on specified device %.*s\n", BSTR_P(device));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -858,14 +858,19 @@ static LPWSTR select_device(struct mp_log *l, struct device_desc *d)
|
||||||
(wcslen(d->deviceID) + 1) * sizeof(wchar_t));
|
(wcslen(d->deviceID) + 1) * sizeof(wchar_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR find_deviceID(struct ao *ao)
|
bstr wasapi_get_specified_device_string(struct ao *ao)
|
||||||
{
|
{
|
||||||
LPWSTR deviceID = NULL;
|
|
||||||
struct wasapi_state *state = ao->priv;
|
struct wasapi_state *state = ao->priv;
|
||||||
bstr device = bstr_strip(bstr0(state->opt_device));
|
bstr device = bstr_strip(bstr0(state->opt_device));
|
||||||
if (!device.len)
|
if (!device.len)
|
||||||
device = bstr_strip(bstr0(ao->device));
|
device = bstr_strip(bstr0(ao->device));
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPWSTR find_deviceID(struct ao *ao)
|
||||||
|
{
|
||||||
|
LPWSTR deviceID = NULL;
|
||||||
|
bstr device = wasapi_get_specified_device_string(ao);
|
||||||
MP_DBG(ao, "Find device \'%.*s\'\n", BSTR_P(device));
|
MP_DBG(ao, "Find device \'%.*s\'\n", BSTR_P(device));
|
||||||
|
|
||||||
struct device_desc *d = NULL;
|
struct device_desc *d = NULL;
|
||||||
|
|
Loading…
Reference in New Issue