diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-12 03:02:00 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-12 03:02:00 +0200 |
commit | 19445bb152eec07536ca6186aca78ac8eafe77e1 (patch) | |
tree | 070ed386f717d780ac95a210b17bb0684013ba42 /src/plugins/windowsaudio | |
parent | e2d022c48e50aa23469d861cc382910fda594994 (diff) | |
parent | 14a77698a01782f27e395bbc8694b808455d4ba1 (diff) | |
download | qtmultimedia-19445bb152eec07536ca6186aca78ac8eafe77e1.tar.gz |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: If607130a5ae7aaad3bd6323c2ba2beabaee4e096
Diffstat (limited to 'src/plugins/windowsaudio')
-rw-r--r-- | src/plugins/windowsaudio/qwindowsaudioinput.cpp | 25 | ||||
-rw-r--r-- | src/plugins/windowsaudio/qwindowsaudioinput.h | 1 | ||||
-rw-r--r-- | src/plugins/windowsaudio/qwindowsaudiooutput.cpp | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/plugins/windowsaudio/qwindowsaudioinput.cpp b/src/plugins/windowsaudio/qwindowsaudioinput.cpp index 4771fe1cc..00b36cfe4 100644 --- a/src/plugins/windowsaudio/qwindowsaudioinput.cpp +++ b/src/plugins/windowsaudio/qwindowsaudioinput.cpp @@ -74,14 +74,13 @@ QWindowsAudioInput::QWindowsAudioInput(const QByteArray &device) waveBlockOffset = 0; mixerID = 0; + cachedVolume = 1.0f; memset(&mixerLineControls, 0, sizeof(mixerLineControls)); - initMixer(); } QWindowsAudioInput::~QWindowsAudioInput() { stop(); - closeMixer(); } void QT_WIN_CALLBACK QWindowsAudioInput::waveInProc( HWAVEIN hWaveIn, UINT uMsg, @@ -183,6 +182,7 @@ QAudio::State QWindowsAudioInput::state() const void QWindowsAudioInput::setVolume(qreal volume) { + cachedVolume = volume; for (DWORD i = 0; i < mixerLineControls.cControls; i++) { MIXERCONTROLDETAILS controlDetails; @@ -204,7 +204,6 @@ void QWindowsAudioInput::setVolume(qreal volume) qreal QWindowsAudioInput::volume() const { - DWORD volume = 0; for (DWORD i = 0; i < mixerLineControls.cControls; i++) { if ((mixerLineControls.pamxctrl[i].dwControlType != MIXERCONTROL_CONTROLTYPE_FADER) && (mixerLineControls.pamxctrl[i].dwControlType != MIXERCONTROL_CONTROLTYPE_VOLUME)) { @@ -226,11 +225,10 @@ qreal QWindowsAudioInput::volume() const continue; if (controlDetails.cbDetails < sizeof(MIXERCONTROLDETAILS_UNSIGNED)) continue; - volume = detailsUnsigned.dwValue; - break; + return detailsUnsigned.dwValue / 65535.0; } - return volume / 65535.0; + return cachedVolume; } void QWindowsAudioInput::setFormat(const QAudioFormat& fmt) @@ -378,6 +376,7 @@ bool QWindowsAudioInput::open() elapsedTimeOffset = 0; totalTimeValue = 0; errorState = QAudio::NoError; + initMixer(); return true; } @@ -396,6 +395,7 @@ void QWindowsAudioInput::close() mutex.unlock(); waveInClose(hWaveIn); + closeMixer(); int count = 0; while(!finished && count < 500) { @@ -406,17 +406,10 @@ void QWindowsAudioInput::close() void QWindowsAudioInput::initMixer() { - QDataStream ds(&m_device, QIODevice::ReadOnly); - quint32 inputDevice; - ds >> inputDevice; - - if (int(inputDevice) < 0) - return; - // Get the Mixer ID from the Sound Device ID UINT mixerIntID = 0; - if (mixerGetID(reinterpret_cast<HMIXEROBJ>(quintptr(inputDevice)), - &mixerIntID, MIXER_OBJECTF_WAVEIN) != MMSYSERR_NOERROR) + if (mixerGetID(reinterpret_cast<HMIXEROBJ>(hWaveIn), + &mixerIntID, MIXER_OBJECTF_HWAVEIN) != MMSYSERR_NOERROR) return; mixerID = reinterpret_cast<HMIXEROBJ>(quintptr(mixerIntID)); @@ -436,6 +429,8 @@ void QWindowsAudioInput::initMixer() mixerLineControls.pamxctrl = new MIXERCONTROL[mixerLineControls.cControls]; if (mixerGetLineControls(mixerID, &mixerLineControls, MIXER_GETLINECONTROLSF_ALL) != MMSYSERR_NOERROR) closeMixer(); + else + setVolume(cachedVolume); } } diff --git a/src/plugins/windowsaudio/qwindowsaudioinput.h b/src/plugins/windowsaudio/qwindowsaudioinput.h index e61a50a89..a0feae257 100644 --- a/src/plugins/windowsaudio/qwindowsaudioinput.h +++ b/src/plugins/windowsaudio/qwindowsaudioinput.h @@ -147,6 +147,7 @@ private: void closeMixer(); HMIXEROBJ mixerID; MIXERLINECONTROLS mixerLineControls; + qreal cachedVolume; private slots: void feedback(); diff --git a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp index 104055f30..26eecb768 100644 --- a/src/plugins/windowsaudio/qwindowsaudiooutput.cpp +++ b/src/plugins/windowsaudio/qwindowsaudiooutput.cpp @@ -241,6 +241,10 @@ bool QWindowsAudioOutput::open() period_size = buffer_size / 5; } + // Make even size of wave block to prevent crackling + // due to waveOutWrite() does not like odd buffer length + period_size &= ~1; + if (period_size == 0) { errorState = QAudio::OpenError; deviceState = QAudio::StoppedState; |