From b33659d9be1e5a1ad9932e6763ad9381c4d56a40 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 6 Oct 2020 13:24:04 +0200 Subject: [PATCH] Make RAW WASAPI streams opt-in --- include/cubeb/cubeb.h | 4 +++- src/cubeb_wasapi.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/cubeb/cubeb.h b/include/cubeb/cubeb.h index 43fff5d..66780cd 100644 --- a/include/cubeb/cubeb.h +++ b/include/cubeb/cubeb.h @@ -230,12 +230,14 @@ typedef enum { 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. + 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 selected, as well as the quality of the stream, for example to accomodate bluetooth SCO modes on bluetooth devices. */ + CUBEB_STREAM_PREF_RAW = 0x08 /**< Windows only. Bypass all signal processing + except for always on APO, driver and hardware. */ } cubeb_stream_prefs; /** Stream format initialization parameters. */ diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp index 8dc8022..5572ad7 100644 --- a/src/cubeb_wasapi.cpp +++ b/src/cubeb_wasapi.cpp @@ -2102,9 +2102,12 @@ int setup_wasapi_stream_one_side(cubeb_stream * stm, LOG("Could not get cubeb_device_info."); } - if (initialize_iaudioclient2(audio_client) != CUBEB_OK) { - LOG("Can't create the reconfigure event, error: %lx", GetLastError()); - // This is not fatal. + if (stm->output_stream_params.prefs & CUBEB_STREAM_PREF_RAW || + stm->input_stream_params.prefs & CUBEB_STREAM_PREF_RAW) { + if (initialize_iaudioclient2(audio_client) != CUBEB_OK) { + LOG("Can't initialize an IAudioClient2, error: %lx", GetLastError()); + // This is not fatal. + } } #if 0 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1590902