summaryrefslogtreecommitdiff
path: root/src/multimedia/audio/qaudioinput_win32_p.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-10-04 13:57:07 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-10-04 13:57:07 +1000
commitabcea22c5ba45d00c713d25a77773efbf6d941f7 (patch)
tree9cd98ebad82fc8ef80ff53c47da10f80ec114ffe /src/multimedia/audio/qaudioinput_win32_p.cpp
parent33b76a659b2f44fa7038e375bbfb4cfd449ae617 (diff)
parente2c45cbacaa0f48e1397572d3e5baa847c86e9b1 (diff)
downloadqt4-tools-abcea22c5ba45d00c713d25a77773efbf6d941f7.tar.gz
Merge remote branch 'origin/4.6' into 4.7-from-4.6
Conflicts: src/multimedia/audio/qaudioinput_win32_p.cpp
Diffstat (limited to 'src/multimedia/audio/qaudioinput_win32_p.cpp')
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index ece1c26c3e..1cde15969a 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -214,18 +214,44 @@ bool QAudioInputPrivate::open()
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
header = 0;
- if(buffer_size == 0) {
- // Default buffer size, 200ms, default period size is 40ms
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
- period_size = buffer_size/5;
+ period_size = 0;
+
+ if (!settings.isValid()) {
+ qWarning("QAudioInput: open error, invalid format.");
+ } else if (settings.channels() <= 0) {
+ qWarning("QAudioInput: open error, invalid number of channels (%d).",
+ settings.channels());
+ } else if (settings.sampleSize() <= 0) {
+ qWarning("QAudioInput: open error, invalid sample size (%d).",
+ settings.sampleSize());
+ } else if (settings.frequency() < 8000 || settings.frequency() > 48000) {
+ qWarning("QAudioInput: open error, frequency out of range (%d).", settings.frequency());
+ } else if (buffer_size == 0) {
+
+ buffer_size
+ = (settings.frequency()
+ * settings.channels()
+ * settings.sampleSize()
+#ifndef Q_OS_WINCE // Default buffer size, 200ms, default period size is 40ms
+ + 39) / 40;
+ period_size = buffer_size / 5;
} else {
- period_size = buffer_size/5;
- }
-#ifdef Q_OS_WINCE
- // For wince reduce size to 40ms for buffer size and 20ms period
- buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.04;
- period_size = buffer_size/2;
+ period_size = buffer_size / 5;
+#else // For wince reduce size to 40ms for buffer size and 20ms period
+ + 199) / 200;
+ period_size = buffer_size / 2;
+ } else {
+ period_size = buffer_size / 2;
#endif
+ }
+
+ if (period_size == 0) {
+ errorState = QAudio::OpenError;
+ deviceState = QAudio::StoppedState;
+ emit stateChanged(deviceState);
+ return false;
+ }
+
timeStamp.restart();
elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();