aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul Adenot <[email protected]>2020-07-23 16:20:25 +0200
committerPaul Adenot <[email protected]>2020-09-09 14:30:03 +0200
commit955bb9476937e5eacb3cece539b87f04663a86d0 (patch)
treeb58bd82b3fbfc181dd2e5fb9259ad32c7e99af89
parent2929eac3221187ad0a4619f0fba3d59fb732ad49 (diff)
downloadcubeb-955bb9476937e5eacb3cece539b87f04663a86d0.tar.gz
cubeb-955bb9476937e5eacb3cece539b87f04663a86d0.zip
Separate the role and the fact that the stream is being used for voice. Use a resampler setting to lower latency when the stream is for voice
Picking the default communication device was tried, and is not what users expect it seems. Using a lower setting for resampling voice prevent adding too much latency: 120 frames for 16k->48k in DESKTOP vs 72 in VOICE, and lowers CPU usage.
-rw-r--r--src/cubeb_wasapi.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index 341a6a4..2754d7f 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -245,6 +245,7 @@ struct cubeb_stream {
cubeb_stream_params output_stream_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
/* A MMDevice role for this stream: either communication or console here. */
ERole role;
+ bool voice;
/* The input and output device, or NULL for default. */
std::unique_ptr<const wchar_t[]> input_device;
std::unique_ptr<const wchar_t[]> output_device;
@@ -2213,7 +2214,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
target_sample_rate,
stm->data_callback,
stm->user_ptr,
- CUBEB_RESAMPLER_QUALITY_DESKTOP));
+ stm->voice ? CUBEB_RESAMPLER_QUALITY_VOIP : CUBEB_RESAMPLER_QUALITY_DESKTOP));
if (!stm->resampler) {
LOG("Could not get a resampler");
return CUBEB_ERROR;
@@ -2303,11 +2304,13 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
if (stm->output_stream_params.prefs & CUBEB_STREAM_PREF_VOICE ||
stm->input_stream_params.prefs & CUBEB_STREAM_PREF_VOICE) {
- stm->role = eCommunications;
+ stm->voice = true;
} else {
- stm->role = eConsole;
+ stm->voice = false;
}
+ stm->role = eConsole;
+
if (input_stream_params) {
stm->input_stream_params = *input_stream_params;
stm->input_device = utf8_to_wstr(reinterpret_cast<char const *>(input_device));