From 339f0075c8a6d3431ad08be9e0f8c85fa48556b1 Mon Sep 17 00:00:00 2001 From: "michal.szwaj" Date: Mon, 19 Mar 2018 16:14:09 +0100 Subject: [PATCH] Use game category for audio output to reduce audio latency --- src/autoapp/Projection/AudioOutput.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/autoapp/Projection/AudioOutput.cpp b/src/autoapp/Projection/AudioOutput.cpp index 7b309d5..f211987 100644 --- a/src/autoapp/Projection/AudioOutput.cpp +++ b/src/autoapp/Projection/AudioOutput.cpp @@ -52,8 +52,9 @@ void AudioOutput::createAudioOutput() OPENAUTO_LOG(debug) << "[AudioOutput] create."; audioOutput_ = std::make_unique(QAudioDeviceInfo::defaultOutputDevice(), audioFormat_); - // Default volume level (max) produces crackles - audioOutput_->setVolume(static_cast(0.90)); + // Setting this category switching to the low latency mode + // See: http://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/pulseaudio/qaudiooutput_pulse.cpp?h=5.7#n58 + audioOutput_->setCategory("game"); } bool AudioOutput::open() @@ -103,15 +104,12 @@ void AudioOutput::onStartPlayback() audioOutput_->start(&audioBuffer_); playbackStarted_ = true; } - else - { - audioOutput_->resume(); - } } void AudioOutput::onSuspendPlayback() { - audioOutput_->suspend(); + // QAudioOutput is in pull mode so suspending/resuming are not needed. + // Keep this interface for any further purposes } void AudioOutput::onStopPlayback()