summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudiooutput_win32_p.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-10-04 03:57:07 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-10-04 03:57:07 (GMT)
commitabcea22c5ba45d00c713d25a77773efbf6d941f7 (patch)
tree9cd98ebad82fc8ef80ff53c47da10f80ec114ffe /src/multimedia/audio/qaudiooutput_win32_p.cpp
parent33b76a659b2f44fa7038e375bbfb4cfd449ae617 (diff)
parente2c45cbacaa0f48e1397572d3e5baa847c86e9b1 (diff)
downloadQt-abcea22c5ba45d00c713d25a77773efbf6d941f7.zip
Qt-abcea22c5ba45d00c713d25a77773efbf6d941f7.tar.gz
Qt-abcea22c5ba45d00c713d25a77773efbf6d941f7.tar.bz2
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/qaudiooutput_win32_p.cpp')
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 99bada2..1f304e3 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -251,20 +251,38 @@ bool QAudioOutputPrivate::open()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
- if (!(settings.frequency() >= 8000 && settings.frequency() <= 48000)) {
+
+ period_size = 0;
+
+ if (!settings.isValid()) {
+ qWarning("QAudioOutput: open error, invalid format.");
+ } else if (settings.channels() <= 0) {
+ qWarning("QAudioOutput: open error, invalid number of channels (%d).",
+ settings.channels());
+ } else if (settings.sampleSize() <= 0) {
+ qWarning("QAudioOutput: open error, invalid sample size (%d).",
+ settings.sampleSize());
+ } else if (settings.frequency() < 8000 || settings.frequency() > 48000) {
+ qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency());
+ } else if (buffer_size == 0) {
+ // Default buffer size, 200ms, default period size is 40ms
+ buffer_size
+ = (settings.frequency()
+ * settings.channels()
+ * settings.sampleSize()
+ + 39) / 40;
+ period_size = buffer_size / 5;
+ } else {
+ period_size = buffer_size / 5;
+ }
+
+ if (period_size == 0) {
errorState = QAudio::OpenError;
deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
- qWarning("QAudioOutput: open error, frequency out of range.");
return false;
}
- 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;
- } else {
- period_size = buffer_size/5;
- }
+
waveBlocks = allocateBlocks(period_size, buffer_size/period_size);
mutex.lock();