summaryrefslogtreecommitdiff
path: root/src/plugins/windowsaudio
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2017-11-13 09:36:41 +0100
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2017-11-23 12:14:06 +0000
commita621c53dd9103c3d41cb16763f7b7dba372b67a6 (patch)
tree9fe65292d22fc677a26273b2bccc8c2aac370201 /src/plugins/windowsaudio
parentb04e044e24d67dc6092d964247900e081b628623 (diff)
downloadqtmultimedia-a621c53dd9103c3d41cb16763f7b7dba372b67a6.tar.gz
Fix crash when no supported formats are returned
If waveInGetDevCaps or waveOutGetDevCaps returns MMSYSERR_NOERROR it does not mean that there are supported formats in the dwFormats field. Task-number: QTBUG-54242 Change-Id: I767ccc9570681685a27abd979ba9754034058e6f Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/windowsaudio')
-rw-r--r--src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
index 83e9ccfc8..c054c0f76 100644
--- a/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
+++ b/src/plugins/windowsaudio/qwindowsaudiodeviceinfo.cpp
@@ -238,21 +238,16 @@ void QWindowsAudioDeviceInfo::updateLists()
if (!sizez.isEmpty())
return;
- bool hasCaps = false;
DWORD fmt = 0;
if(mode == QAudio::AudioOutput) {
WAVEOUTCAPS woc;
- if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR) {
- hasCaps = true;
+ if (waveOutGetDevCaps(devId, &woc, sizeof(WAVEOUTCAPS)) == MMSYSERR_NOERROR)
fmt = woc.dwFormats;
- }
} else {
WAVEINCAPS woc;
- if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) {
- hasCaps = true;
+ if (waveInGetDevCaps(devId, &woc, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
fmt = woc.dwFormats;
- }
}
sizez.clear();
@@ -260,7 +255,7 @@ void QWindowsAudioDeviceInfo::updateLists()
channelz.clear();
typez.clear();
- if (hasCaps) {
+ if (fmt) {
// Check sample size
if ((fmt & WAVE_FORMAT_1M08)
|| (fmt & WAVE_FORMAT_1S08)