diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2009-09-24 01:55:52 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2009-09-24 02:40:13 (GMT) |
commit | fb50411e4c0c132631f8237933fbb0972fa4c9aa (patch) | |
tree | 89aa19161710ccf0d2c0e11c0494ddef893eb19c /examples | |
parent | 609dd32580b1e07213a2b2efdd4d854c34e8f6d7 (diff) | |
download | Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.zip Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.tar.gz Qt-fb50411e4c0c132631f8237933fbb0972fa4c9aa.tar.bz2 |
AudioService API changes; QString->const QString&, remove QAudioDeviceId use QAudioDeviceInfo.
Reviewed-by: Bill King
Diffstat (limited to 'examples')
6 files changed, 21 insertions, 32 deletions
diff --git a/examples/multimedia/audio/audiodevices/audiodevices.cpp b/examples/multimedia/audio/audiodevices/audiodevices.cpp index 0d305ff..4198605 100644 --- a/examples/multimedia/audio/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audio/audiodevices/audiodevices.cpp @@ -80,8 +80,6 @@ AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) connect(sampleTypesBox,SIGNAL(activated(int)),SLOT(sampleTypeChanged(int))); connect(endianBox,SIGNAL(activated(int)),SLOT(endianChanged(int))); - device = 0; - modeBox->setCurrentIndex(0); modeChanged(0); deviceBox->setCurrentIndex(0); @@ -98,8 +96,8 @@ void AudioTest::test() logOutput->clear(); logOutput->append("NOTE: an invalid codec audio/test exists for testing, to get a fail condition."); - if(device) { - if(device->isFormatSupported(settings)) { + if (!deviceInfo.isNull()) { + if (deviceInfo.isFormatSupported(settings)) { logOutput->append("Success"); nearestFreq->setText(""); nearestChannel->setText(""); @@ -108,7 +106,7 @@ void AudioTest::test() nearestSampleType->setText(""); nearestEndian->setText(""); } else { - QAudioFormat nearest = device->nearestFormat(settings); + QAudioFormat nearest = deviceInfo.nearestFormat(settings); logOutput->append(tr("Failed")); nearestFreq->setText(QString("%1").arg(nearest.frequency())); nearestChannel->setText(QString("%1").arg(nearest.channels())); @@ -150,40 +148,34 @@ void AudioTest::modeChanged(int idx) mode=QAudio::AudioOutput; deviceBox->clear(); - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(mode); - for(int i = 0; i < devices.size(); ++i) { - deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); - } + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(mode)) + deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); } void AudioTest::deviceChanged(int idx) { - delete device; - device = 0; - if (deviceBox->count() == 0) return; // device has changed - deviceHandle = deviceBox->itemData(idx).value<QAudioDeviceId>(); - device = new QAudioDeviceInfo(deviceHandle, this); + deviceInfo = deviceBox->itemData(idx).value<QAudioDeviceInfo>(); frequencyBox->clear(); - QList<int> freqz = device->supportedFrequencies(); + QList<int> freqz = deviceInfo.supportedFrequencies(); for(int i = 0; i < freqz.size(); ++i) frequencyBox->addItem(QString("%1").arg(freqz.at(i))); if(freqz.size()) settings.setFrequency(freqz.at(0)); channelsBox->clear(); - QList<int> chz = device->supportedChannels(); + QList<int> chz = deviceInfo.supportedChannels(); for(int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); if(chz.size()) settings.setChannels(chz.at(0)); codecsBox->clear(); - QStringList codecz = device->supportedCodecs(); + QStringList codecz = deviceInfo.supportedCodecs(); for(int i = 0; i < codecz.size(); ++i) codecsBox->addItem(QString("%1").arg(codecz.at(i))); if(codecz.size()) @@ -192,14 +184,14 @@ void AudioTest::deviceChanged(int idx) codecsBox->addItem("audio/test"); sampleSizesBox->clear(); - QList<int> sampleSizez = device->supportedSampleSizes(); + QList<int> sampleSizez = deviceInfo.supportedSampleSizes(); for(int i = 0; i < sampleSizez.size(); ++i) sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i))); if(sampleSizez.size()) settings.setSampleSize(sampleSizez.at(0)); sampleTypesBox->clear(); - QList<QAudioFormat::SampleType> sampleTypez = device->supportedSampleTypes(); + QList<QAudioFormat::SampleType> sampleTypez = deviceInfo.supportedSampleTypes(); for(int i = 0; i < sampleTypez.size(); ++i) { switch(sampleTypez.at(i)) { case QAudioFormat::SignedInt: @@ -219,7 +211,7 @@ void AudioTest::deviceChanged(int idx) } endianBox->clear(); - QList<QAudioFormat::Endian> endianz = device->supportedByteOrders(); + QList<QAudioFormat::Endian> endianz = deviceInfo.supportedByteOrders(); for(int i = 0; i < endianz.size(); ++i) { switch(endianz.at(i)) { case QAudioFormat::LittleEndian: diff --git a/examples/multimedia/audio/audiodevices/audiodevices.h b/examples/multimedia/audio/audiodevices/audiodevices.h index acf492d..5fe5547 100644 --- a/examples/multimedia/audio/audiodevices/audiodevices.h +++ b/examples/multimedia/audio/audiodevices/audiodevices.h @@ -60,8 +60,7 @@ public: AudioTest( QMainWindow *parent = 0, Qt::WFlags f = 0 ); virtual ~AudioTest(); - QAudioDeviceId deviceHandle; - QAudioDeviceInfo* device; + QAudioDeviceInfo deviceInfo; QAudioFormat settings; QAudio::Mode mode; diff --git a/examples/multimedia/audio/audioinput/audioinput.cpp b/examples/multimedia/audio/audioinput/audioinput.cpp index a586bf3..c09e7d9 100644 --- a/examples/multimedia/audio/audioinput/audioinput.cpp +++ b/examples/multimedia/audio/audioinput/audioinput.cpp @@ -250,9 +250,9 @@ InputTest::InputTest() layout->addWidget(canvas); deviceBox = new QComboBox(this); - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) { - deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); } connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -367,7 +367,7 @@ void InputTest::deviceChanged(int idx) audioInput->disconnect(this); delete audioInput; - device = deviceBox->itemData(idx).value<QAudioDeviceId>(); + device = deviceBox->itemData(idx).value<QAudioDeviceInfo>(); audioInput = new QAudioInput(device, format, this); connect(audioInput,SIGNAL(notify()),SLOT(status())); connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); diff --git a/examples/multimedia/audio/audioinput/audioinput.h b/examples/multimedia/audio/audioinput/audioinput.h index c1bc602..7ba6f1f 100644 --- a/examples/multimedia/audio/audioinput/audioinput.h +++ b/examples/multimedia/audio/audioinput/audioinput.h @@ -116,7 +116,7 @@ public: InputTest(); ~InputTest(); - QAudioDeviceId device; + QAudioDeviceInfo device; QAudioFormat format; QAudioInput* audioInput; Spectrum* spec; diff --git a/examples/multimedia/audio/audiooutput/audiooutput.cpp b/examples/multimedia/audio/audiooutput/audiooutput.cpp index d239eb0..19f7a3f 100644 --- a/examples/multimedia/audio/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audio/audiooutput/audiooutput.cpp @@ -142,10 +142,8 @@ AudioTest::AudioTest() QVBoxLayout* layout = new QVBoxLayout; deviceBox = new QComboBox(this); - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); - for(int i = 0; i < devices.size(); ++i) { - deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); - } + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::deviceList(QAudio::AudioOutput)) + deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(deviceBox); @@ -200,7 +198,7 @@ void AudioTest::deviceChanged(int idx) audioOutput->disconnect(this); delete audioOutput; - device = deviceBox->itemData(idx).value<QAudioDeviceId>(); + device = deviceBox->itemData(idx).value<QAudioDeviceInfo>(); audioOutput = new QAudioOutput(device,settings,this); connect(audioOutput,SIGNAL(notify()),SLOT(status())); connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); diff --git a/examples/multimedia/audio/audiooutput/audiooutput.h b/examples/multimedia/audio/audiooutput/audiooutput.h index e2c22ee..a5c0289 100644 --- a/examples/multimedia/audio/audiooutput/audiooutput.h +++ b/examples/multimedia/audio/audiooutput/audiooutput.h @@ -87,7 +87,7 @@ public: AudioTest(); ~AudioTest(); - QAudioDeviceId device; + QAudioDeviceInfo device; Generator* gen; QAudioOutput* audioOutput; QIODevice* output; |