Skip to content

Commit 10e46b6

Browse files
committed
Use default latencies
1 parent 6f16c8e commit 10e46b6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/audio/AudioPortAudio.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,22 @@ AudioPortAudio::AudioPortAudio(bool& successful, AudioEngine* engine)
126126

127127
const auto sampleRate = engine->baseSampleRate();
128128
const auto framesPerBuffer = engine->framesPerPeriod();
129-
const auto latency = static_cast<PaTime>(framesPerBuffer) / sampleRate;
129+
const auto inputLatency
130+
= inputDeviceIndex == paNoDevice ? 0. : Pa_GetDeviceInfo(inputDeviceIndex)->defaultLowInputLatency;
131+
const auto outputLatency
132+
= outputDeviceIndex == paNoDevice ? 0. : Pa_GetDeviceInfo(outputDeviceIndex)->defaultLowOutputLatency;
130133

131134
auto inputParameters = PaStreamParameters{.device = inputDeviceIndex,
132135
.channelCount = inputDeviceChannels,
133136
.sampleFormat = paFloat32,
134-
.suggestedLatency = latency,
137+
.suggestedLatency = inputLatency,
135138
.hostApiSpecificStreamInfo = nullptr
136139
};
137140

138141
auto outputParameters = PaStreamParameters{.device = outputDeviceIndex,
139142
.channelCount = outputDeviceChannels,
140143
.sampleFormat = paFloat32,
141-
.suggestedLatency = latency,
144+
.suggestedLatency = outputLatency,
142145
.hostApiSpecificStreamInfo = nullptr
143146
};
144147

0 commit comments

Comments
 (0)