wasapi: Add flag to disable default device switching. (#507)

This has been merged in Gecko via BMO# 1427011 for quite some time.
This commit is contained in:
Matthew Gregan 2019-05-17 09:21:59 +12:00 коммит произвёл GitHub
Родитель 64aa80f330
Коммит b9e2c50e51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -227,6 +227,9 @@ typedef enum {
specified on the input params and an
output device to loopback from should
be passed in place of an input device. */
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
default device on OS
changes. */
CUBEB_STREAM_PREF_VOICE = 0x04 /**< This stream is going to transport voice data.
Depending on the backend and platform, this can
change the audio input or output devices

Просмотреть файл

@ -2158,11 +2158,16 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
return rv;
}
HRESULT hr = register_notification_client(stm.get());
if (FAILED(hr)) {
/* this is not fatal, we can still play audio, but we won't be able
to keep using the default audio endpoint if it changes. */
LOG("failed to register notification client, %lx", hr);
if (!((input_stream_params ?
(input_stream_params->prefs & CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING) : 0) ||
(output_stream_params ?
(output_stream_params->prefs & CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING) : 0))) {
HRESULT hr = register_notification_client(stm.get());
if (FAILED(hr)) {
/* this is not fatal, we can still play audio, but we won't be able
to keep using the default audio endpoint if it changes. */
LOG("failed to register notification client, %lx", hr);
}
}
*stream = stm.release();
@ -2208,7 +2213,9 @@ void wasapi_stream_destroy(cubeb_stream * stm)
stm->emergency_bailout = nullptr;
}
unregister_notification_client(stm);
if (stm->notification_client) {
unregister_notification_client(stm);
}
CloseHandle(stm->reconfigure_event);
CloseHandle(stm->refill_event);