summaryrefslogtreecommitdiff
path: root/src/plugins/windowsaudio
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-04 11:27:51 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-04 11:30:08 +0100
commitd3a2d9c96994c56d67467c131b8f080510d1a8fd (patch)
tree088c55da965b1fb6bb327b2821afc4755eab8117 /src/plugins/windowsaudio
parent256ff7bb1551f6c62c4ac861472ea29f45dbab3a (diff)
parent75b4283fb05d07fb8654e031f266e9918f1ae647 (diff)
downloadqtmultimedia-d3a2d9c96994c56d67467c131b8f080510d1a8fd.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: Ib038c5e3ebb48c0e46569a35d530fa5ceaf06a32
Diffstat (limited to 'src/plugins/windowsaudio')
-rw-r--r--src/plugins/windowsaudio/qwindowsaudiooutput.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
index c4bbbe85d..815b78979 100644
--- a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
+++ b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp
@@ -53,6 +53,7 @@
#include "qwindowsaudioutils.h"
#include <QtEndian>
#include <QtCore/QDataStream>
+#include <private/qaudiohelpers_p.h>
//#define DEBUG_AUDIO 1
@@ -72,7 +73,7 @@ QWindowsAudioOutput::QWindowsAudioOutput(const QByteArray &device)
audioSource = 0;
pullMode = true;
finished = false;
- volumeCache = (qreal)1.;
+ volumeCache = qreal(1.0);
}
QWindowsAudioOutput::~QWindowsAudioOutput()
@@ -280,8 +281,6 @@ bool QWindowsAudioOutput::open()
timeStampOpened.restart();
elapsedTimeOffset = 0;
- setVolume(volumeCache);
-
errorState = QAudio::NoError;
if(pullMode) {
deviceState = QAudio::ActiveState;
@@ -407,7 +406,11 @@ qint64 QWindowsAudioOutput::write( const char *data, qint64 len )
remain = l;
else
remain = period_size;
- memcpy(current->lpData, p, remain);
+
+ if (volumeCache < qreal(1.0))
+ QAudioHelperInternal::qMultiplySamples(volumeCache, settings, p, current->lpData, remain);
+ else
+ memcpy(current->lpData, p, remain);
l -= remain;
p += remain;
@@ -595,16 +598,10 @@ QAudio::State QWindowsAudioOutput::state() const
void QWindowsAudioOutput::setVolume(qreal v)
{
- const qreal normalizedVolume = qBound(qreal(0.0), v, qreal(1.0));
- if (deviceState != QAudio::ActiveState) {
- volumeCache = normalizedVolume;
+ if (qFuzzyCompare(volumeCache, v))
return;
- }
- const quint16 scaled = normalizedVolume * 0xFFFF;
- DWORD vol = MAKELONG(scaled, scaled);
- MMRESULT res = waveOutSetVolume(hWaveOut, vol);
- if (res == MMSYSERR_NOERROR)
- volumeCache = normalizedVolume;
+
+ volumeCache = qBound(qreal(0), v, qreal(1));
}
qreal QWindowsAudioOutput::volume() const