From 4f68dfda402aa6d40fbde3ee18fd4e535779e4d3 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 11 Aug 2020 14:27:46 +0100 Subject: [PATCH] Only tune audio buffer sizes on Windows --- Audio/soundin.cpp | 4 ++++ Audio/soundout.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Audio/soundin.cpp b/Audio/soundin.cpp index 19c41f61b..ad9e43444 100644 --- a/Audio/soundin.cpp +++ b/Audio/soundin.cpp @@ -82,7 +82,11 @@ void SoundInput::start(QAudioDeviceInfo const& device, int framesPerBuffer, Audi //qDebug () << "SoundIn default buffer size (bytes):" << m_stream->bufferSize () << "period size:" << m_stream->periodSize (); // the Windows MME version of QAudioInput uses 1/5 of the buffer // size for period size other platforms seem to optimize themselves +#if defined (Q_OS_WIN) m_stream->setBufferSize (m_stream->format ().bytesForFrames (framesPerBuffer * 5)); +#else + Q_UNUSED (framesPerBuffer); +#endif if (sink->initialize (QIODevice::WriteOnly, channel)) { m_stream->start (sink); diff --git a/Audio/soundout.cpp b/Audio/soundout.cpp index 71625a3f6..cda5fa333 100644 --- a/Audio/soundout.cpp +++ b/Audio/soundout.cpp @@ -85,7 +85,9 @@ void SoundOutput::restart (QIODevice * source) //qDebug () << "SoundOut default buffer size (bytes):" << m_stream->bufferSize () << "period size:" << m_stream->periodSize (); if (m_framesBuffered) { +#if defined (Q_OS_WIN) m_stream->setBufferSize (m_stream->format().bytesForFrames (m_framesBuffered)); +#endif } m_stream->setCategory ("production"); m_stream->start (source);