summaryrefslogtreecommitdiffstats
path: root/examples/multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia')
-rw-r--r--examples/multimedia/audio/audiodevices/audiodevices.cpp32
-rw-r--r--examples/multimedia/audio/audiodevices/audiodevices.h3
-rw-r--r--examples/multimedia/audio/audioinput/audioinput.cpp6
-rw-r--r--examples/multimedia/audio/audioinput/audioinput.h2
-rw-r--r--examples/multimedia/audio/audiooutput/audiooutput.cpp8
-rw-r--r--examples/multimedia/audio/audiooutput/audiooutput.h2
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;