Avoid (expensive) audio interpolation when sample rates already match

This commit is contained in:
heapo 2018-12-06 09:15:47 -08:00
parent d6f17bdcc9
commit 4c83e5cd1e
2 changed files with 8 additions and 4 deletions

View file

@ -285,8 +285,11 @@ void AudioRenderer::VoiceState::RefreshBuffer() {
break;
}
samples =
Interpolate(interp_state, std::move(samples), GetInfo().sample_rate, STREAM_SAMPLE_RATE);
// Only interpolate when necessary, expensive.
if (GetInfo().sample_rate != STREAM_SAMPLE_RATE) {
samples = Interpolate(interp_state, std::move(samples), GetInfo().sample_rate,
STREAM_SAMPLE_RATE);
}
is_refresh_pending = false;
}