diff -r 56cd8111b7f7 -r 41300fa6a67c examples/multimedia/audiooutput/audiooutput.cpp --- a/examples/multimedia/audiooutput/audiooutput.cpp Tue Jan 26 12:42:25 2010 +0200 +++ b/examples/multimedia/audiooutput/audiooutput.cpp Tue Feb 02 00:43:10 2010 +0200 @@ -134,7 +134,7 @@ QVBoxLayout* layout = new QVBoxLayout; deviceBox = new QComboBox(this); - foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -170,6 +170,18 @@ 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))); @@ -200,7 +212,7 @@ void AudioTest::status() { - qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"byteFree = "<bytesFree()<<" bytes, elapsedUSecs = "<elapsedUSecs()<<", processedUSecs = "<processedUSecs(); } void AudioTest::writeMore() @@ -208,7 +220,7 @@ if(!audioOutput) return; - if(audioOutput->state() == QAudio::StopState) + if(audioOutput->state() == QAudio::StoppedState) return; int l; @@ -234,7 +246,7 @@ if (pullMode) { button->setText("Click for Pull Mode"); - output = audioOutput->start(0); + output = audioOutput->start(); pullMode = false; timer->start(20); } else { @@ -247,7 +259,7 @@ void AudioTest::togglePlay() { // toggle suspend/resume - if(audioOutput->state() == QAudio::SuspendState) { + if(audioOutput->state() == QAudio::SuspendedState) { qWarning()<<"status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); @@ -255,7 +267,7 @@ qWarning()<<"status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); - } else if (audioOutput->state() == QAudio::StopState) { + } else if (audioOutput->state() == QAudio::StoppedState) { qWarning()<<"status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend");