summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/audiooutput
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-12-07 22:07:13 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-12-07 22:07:13 (GMT)
commitb70f9d3969fdf7789ba1c5f4d942b2625b1bf689 (patch)
tree1e485f62affa6f8a6273307d013677c5ea1e782b /examples/multimedia/audiooutput
parent322db8410bf7609f072837d554e7256dc385265b (diff)
downloadQt-b70f9d3969fdf7789ba1c5f4d942b2625b1bf689.zip
Qt-b70f9d3969fdf7789ba1c5f4d942b2625b1bf689.tar.gz
Qt-b70f9d3969fdf7789ba1c5f4d942b2625b1bf689.tar.bz2
audioinput and audiooutput examples not using isFormatSupported
function. The examples failed to easy, added check to test and get if required a format to use from the backend. Increases the chance of examples working on various platforms like n900. Reviewed-by:Justin McPherson
Diffstat (limited to 'examples/multimedia/audiooutput')
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 244840d..b6047db 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -170,6 +170,18 @@ AudioTest::AudioTest()
settings.setCodec("audio/pcm");
settings.setByteOrder(QAudioFormat::LittleEndian);
settings.setSampleType(QAudioFormat::SignedInt);
+
+ QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
+ if (!info.isFormatSupported(settings)) {
+ qWarning()<<"default format not supported try to use nearest";
+ settings = info.nearestFormat(settings);
+ }
+
+ if(settings.sampleSize() != 16) {
+ qWarning()<<"audio device doesn't support 16 bit samples, example cannot run";
+ return;
+ }
+
audioOutput = new QAudioOutput(settings,this);
connect(audioOutput,SIGNAL(notify()),SLOT(status()));
connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State)));