aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_wasapi.cpp
diff options
context:
space:
mode:
authorChun-Min Chang <[email protected]>2022-03-22 16:24:21 -0700
committerChun-Min Chang <[email protected]>2022-03-23 09:21:42 -0700
commit1e13faa57baf7d7277518f54f98d0af95ef19e86 (patch)
treefa5de3e68f9148fa0d51e81df37a8506e9237dc4 /src/cubeb_wasapi.cpp
parent5a2a20c6055d26e0a30fae8f1cf6f6cb975c5c97 (diff)
downloadcubeb-1e13faa57baf7d7277518f54f98d0af95ef19e86.tar.gz
cubeb-1e13faa57baf7d7277518f54f98d0af95ef19e86.zip
Get default_period only when we need it
`default_period` is used to calculate the input latency. We can avoid calling for output.
Diffstat (limited to 'src/cubeb_wasapi.cpp')
-rw-r--r--src/cubeb_wasapi.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index 4dae4c6..fc547b7 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -2225,15 +2225,6 @@ setup_wasapi_stream_one_side(cubeb_stream * stm,
flags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
}
- // Sanity check the latency, it may be that the device doesn't support it.
- REFERENCE_TIME minimum_period;
- REFERENCE_TIME default_period;
- hr = audio_client->GetDevicePeriod(&default_period, &minimum_period);
- if (FAILED(hr)) {
- LOG("Could not get device period: %lx", hr);
- return CUBEB_ERROR;
- }
-
REFERENCE_TIME latency_hns = frames_to_hns(stream_params->rate, stm->latency);
stm->input_bluetooth_handsfree = false;
@@ -2246,6 +2237,15 @@ setup_wasapi_stream_one_side(cubeb_stream * stm,
const char * HANDSFREE_TAG = "BTHHFENUM";
size_t len = sizeof(HANDSFREE_TAG);
if (direction == eCapture) {
+ // Sanity check the latency, it may be that the device doesn't support it.
+ REFERENCE_TIME minimum_period;
+ REFERENCE_TIME default_period;
+ hr = audio_client->GetDevicePeriod(&default_period, &minimum_period);
+ if (FAILED(hr)) {
+ LOG("Could not get device period: %lx", hr);
+ return CUBEB_ERROR;
+ }
+
uint32_t default_period_frames =
hns_to_frames(device_info.default_rate, default_period);
if (strlen(device_info.group_id) >= len &&