summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/audioinput/audioinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia/audioinput/audioinput.cpp')
-rw-r--r--examples/multimedia/audioinput/audioinput.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp
index 62afd73..75bddd6 100644
--- a/examples/multimedia/audioinput/audioinput.cpp
+++ b/examples/multimedia/audioinput/audioinput.cpp
@@ -195,7 +195,6 @@ InputTest::InputTest()
pullMode = true;
- // AudioInfo class only supports mono S16LE samples!
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
@@ -203,6 +202,17 @@ InputTest::InputTest()
format.setByteOrder(QAudioFormat::LittleEndian);
format.setCodec("audio/pcm");
+ QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
+ if (!info.isFormatSupported(format)) {
+ qWarning()<<"default format not supported try to use nearest";
+ format = info.nearestFormat(format);
+ }
+
+ if(format.sampleSize() != 16) {
+ qWarning()<<"audio device doesn't support 16 bit samples, example cannot run";
+ return;
+ }
+
audioInput = new QAudioInput(format,this);
connect(audioInput,SIGNAL(notify()),SLOT(status()));
connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State)));