summaryrefslogtreecommitdiffstats
path: root/examples/multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia')
-rw-r--r--examples/multimedia/audiodevices/audiodevices.cpp75
-rw-r--r--examples/multimedia/audiodevices/audiodevices.h8
-rw-r--r--examples/multimedia/audiodevices/audiodevices.pro2
-rw-r--r--examples/multimedia/audiodevices/audiodevicesbase.ui64
-rw-r--r--examples/multimedia/audiodevices/main.cpp2
-rw-r--r--examples/multimedia/audioinput/audioinput.cpp89
-rw-r--r--examples/multimedia/audioinput/audioinput.h37
-rw-r--r--examples/multimedia/audioinput/main.cpp2
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp40
-rw-r--r--examples/multimedia/audiooutput/audiooutput.h2
-rw-r--r--examples/multimedia/audiooutput/main.cpp2
-rw-r--r--examples/multimedia/videographicsitem/main.cpp2
-rw-r--r--examples/multimedia/videographicsitem/videoitem.cpp2
-rw-r--r--examples/multimedia/videographicsitem/videoitem.h2
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.cpp2
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.h2
-rw-r--r--examples/multimedia/videowidget/main.cpp2
-rw-r--r--examples/multimedia/videowidget/videoplayer.cpp2
-rw-r--r--examples/multimedia/videowidget/videoplayer.h2
-rw-r--r--examples/multimedia/videowidget/videowidget.cpp2
-rw-r--r--examples/multimedia/videowidget/videowidget.h2
-rw-r--r--examples/multimedia/videowidget/videowidgetsurface.cpp2
-rw-r--r--examples/multimedia/videowidget/videowidgetsurface.h2
23 files changed, 194 insertions, 153 deletions
diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp
index e205e03..7d09c38 100644
--- a/examples/multimedia/audiodevices/audiodevices.cpp
+++ b/examples/multimedia/audiodevices/audiodevices.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -40,45 +40,33 @@
****************************************************************************/
-#include <QDebug>
#include <QAudioDeviceInfo>
#include "audiodevices.h"
-AudioDevicesBase::AudioDevicesBase( QMainWindow *parent, Qt::WFlags f )
+AudioDevicesBase::AudioDevicesBase(QWidget *parent, Qt::WFlags f)
+ : QMainWindow(parent, f)
{
- Q_UNUSED(parent)
- Q_UNUSED(f)
- setupUi( this );
+ setupUi(this);
}
AudioDevicesBase::~AudioDevicesBase() {}
-AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f )
- : AudioDevicesBase( parent, f )
+AudioTest::AudioTest(QWidget *parent, Qt::WFlags f)
+ : AudioDevicesBase(parent, f)
{
- nearestFreq->setDisabled(true);
- nearestChannel->setDisabled(true);
- nearestCodec->setDisabled(true);
- nearestSampleSize->setDisabled(true);
- nearestSampleType->setDisabled(true);
- nearestEndian->setDisabled(true);
- logOutput->setDisabled(true);
-
mode = QAudio::AudioOutput;
- modeBox->addItem("Input");
- modeBox->addItem("Output");
- connect(testButton,SIGNAL(clicked()),SLOT(test()));
- connect(modeBox,SIGNAL(activated(int)),SLOT(modeChanged(int)));
- connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int)));
- connect(frequencyBox,SIGNAL(activated(int)),SLOT(freqChanged(int)));
- connect(channelsBox,SIGNAL(activated(int)),SLOT(channelChanged(int)));
- connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int)));
- connect(sampleSizesBox,SIGNAL(activated(int)),SLOT(sampleSizeChanged(int)));
- connect(sampleTypesBox,SIGNAL(activated(int)),SLOT(sampleTypeChanged(int)));
- connect(endianBox,SIGNAL(activated(int)),SLOT(endianChanged(int)));
+ connect(testButton, SIGNAL(clicked()), SLOT(test()));
+ connect(modeBox, SIGNAL(activated(int)), SLOT(modeChanged(int)));
+ connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int)));
+ connect(frequencyBox, SIGNAL(activated(int)), SLOT(freqChanged(int)));
+ connect(channelsBox, SIGNAL(activated(int)), SLOT(channelChanged(int)));
+ connect(codecsBox, SIGNAL(activated(int)), SLOT(codecChanged(int)));
+ connect(sampleSizesBox, SIGNAL(activated(int)), SLOT(sampleSizeChanged(int)));
+ connect(sampleTypesBox, SIGNAL(activated(int)), SLOT(sampleTypeChanged(int)));
+ connect(endianBox, SIGNAL(activated(int)), SLOT(endianChanged(int)));
modeBox->setCurrentIndex(0);
modeChanged(0);
@@ -98,7 +86,7 @@ void AudioTest::test()
if (!deviceInfo.isNull()) {
if (deviceInfo.isFormatSupported(settings)) {
- logOutput->append("Success");
+ logOutput->append(tr("Success"));
nearestFreq->setText("");
nearestChannel->setText("");
nearestCodec->setText("");
@@ -136,16 +124,16 @@ void AudioTest::test()
}
}
else
- logOutput->append("No Device");
+ logOutput->append(tr("No Device"));
}
void AudioTest::modeChanged(int idx)
{
// mode has changed
- if(idx == 0)
- mode=QAudio::AudioInput;
+ if (idx == 0)
+ mode = QAudio::AudioInput;
else
- mode=QAudio::AudioOutput;
+ mode = QAudio::AudioOutput;
deviceBox->clear();
foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode))
@@ -176,23 +164,23 @@ void AudioTest::deviceChanged(int idx)
codecsBox->clear();
QStringList codecz = deviceInfo.supportedCodecs();
- for(int i = 0; i < codecz.size(); ++i)
+ for (int i = 0; i < codecz.size(); ++i)
codecsBox->addItem(QString("%1").arg(codecz.at(i)));
- if(codecz.size())
+ if (codecz.size())
settings.setCodec(codecz.at(0));
// Add false to create failed condition!
codecsBox->addItem("audio/test");
sampleSizesBox->clear();
QList<int> sampleSizez = deviceInfo.supportedSampleSizes();
- for(int i = 0; i < sampleSizez.size(); ++i)
+ for (int i = 0; i < sampleSizez.size(); ++i)
sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i)));
- if(sampleSizez.size())
+ if (sampleSizez.size())
settings.setSampleSize(sampleSizez.at(0));
sampleTypesBox->clear();
QList<QAudioFormat::SampleType> sampleTypez = deviceInfo.supportedSampleTypes();
- for(int i = 0; i < sampleTypez.size(); ++i) {
+ for (int i = 0; i < sampleTypez.size(); ++i) {
switch(sampleTypez.at(i)) {
case QAudioFormat::SignedInt:
sampleTypesBox->addItem("SignedInt");
@@ -206,14 +194,14 @@ void AudioTest::deviceChanged(int idx)
case QAudioFormat::Unknown:
sampleTypesBox->addItem("Unknown");
}
- if(sampleTypez.size())
+ if (sampleTypez.size())
settings.setSampleType(sampleTypez.at(0));
}
endianBox->clear();
QList<QAudioFormat::Endian> endianz = deviceInfo.supportedByteOrders();
- for(int i = 0; i < endianz.size(); ++i) {
- switch(endianz.at(i)) {
+ for (int i = 0; i < endianz.size(); ++i) {
+ switch (endianz.at(i)) {
case QAudioFormat::LittleEndian:
endianBox->addItem("Little Endian");
break;
@@ -222,7 +210,7 @@ void AudioTest::deviceChanged(int idx)
break;
}
}
- if(endianz.size())
+ if (endianz.size())
settings.setByteOrder(endianz.at(0));
}
@@ -249,7 +237,7 @@ void AudioTest::sampleSizeChanged(int idx)
void AudioTest::sampleTypeChanged(int idx)
{
- switch(sampleTypesBox->itemText(idx).toInt()) {
+ switch (sampleTypesBox->itemText(idx).toInt()) {
case QAudioFormat::SignedInt:
settings.setSampleType(QAudioFormat::SignedInt);
break;
@@ -263,7 +251,7 @@ void AudioTest::sampleTypeChanged(int idx)
void AudioTest::endianChanged(int idx)
{
- switch(endianBox->itemText(idx).toInt()) {
+ switch (endianBox->itemText(idx).toInt()) {
case QAudioFormat::LittleEndian:
settings.setByteOrder(QAudioFormat::LittleEndian);
break;
@@ -271,4 +259,3 @@ void AudioTest::endianChanged(int idx)
settings.setByteOrder(QAudioFormat::BigEndian);
}
}
-
diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h
index 5fe5547..15ace92 100644
--- a/examples/multimedia/audiodevices/audiodevices.h
+++ b/examples/multimedia/audiodevices/audiodevices.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -49,7 +49,7 @@
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
{
public:
- AudioDevicesBase( QMainWindow *parent = 0, Qt::WFlags f = 0 );
+ AudioDevicesBase(QWidget *parent = 0, Qt::WFlags f = 0);
virtual ~AudioDevicesBase();
};
@@ -57,10 +57,10 @@ class AudioTest : public AudioDevicesBase
{
Q_OBJECT
public:
- AudioTest( QMainWindow *parent = 0, Qt::WFlags f = 0 );
+ AudioTest(QWidget *parent = 0, Qt::WFlags f = 0);
virtual ~AudioTest();
- QAudioDeviceInfo deviceInfo;
+ QAudioDeviceInfo deviceInfo;
QAudioFormat settings;
QAudio::Mode mode;
diff --git a/examples/multimedia/audiodevices/audiodevices.pro b/examples/multimedia/audiodevices/audiodevices.pro
index 232da09..1cb4679 100644
--- a/examples/multimedia/audiodevices/audiodevices.pro
+++ b/examples/multimedia/audiodevices/audiodevices.pro
@@ -1,7 +1,7 @@
HEADERS = audiodevices.h
SOURCES = audiodevices.cpp \
main.cpp
-FORMS += audiodevicesbase.ui
+FORMS += audiodevicesbase.ui
QT += multimedia
diff --git a/examples/multimedia/audiodevices/audiodevicesbase.ui b/examples/multimedia/audiodevices/audiodevicesbase.ui
index 5207338..faa39dc 100644
--- a/examples/multimedia/audiodevices/audiodevicesbase.ui
+++ b/examples/multimedia/audiodevices/audiodevicesbase.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>AudioDevicesBase</string>
+ <string>Audio Devices</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
@@ -41,7 +41,18 @@
<widget class="QComboBox" name="deviceBox"/>
</item>
<item row="1" column="1">
- <widget class="QComboBox" name="modeBox"/>
+ <widget class="QComboBox" name="modeBox">
+ <item>
+ <property name="text">
+ <string>Input</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Output</string>
+ </property>
+ </item>
+ </widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="actualLabel">
@@ -93,7 +104,11 @@
<widget class="QComboBox" name="frequencyBox"/>
</item>
<item row="4" column="1">
- <widget class="QLineEdit" name="nearestFreq"/>
+ <widget class="QLineEdit" name="nearestFreq">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="actualChannelsLabel">
@@ -113,7 +128,11 @@
<widget class="QComboBox" name="channelsBox"/>
</item>
<item row="6" column="1">
- <widget class="QLineEdit" name="nearestChannel"/>
+ <widget class="QLineEdit" name="nearestChannel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="actualCodecLabel">
@@ -133,7 +152,11 @@
<widget class="QComboBox" name="codecsBox"/>
</item>
<item row="8" column="1">
- <widget class="QLineEdit" name="nearestCodec"/>
+ <widget class="QLineEdit" name="nearestCodec">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="actualSampleSizeLabel">
@@ -153,7 +176,11 @@
<widget class="QComboBox" name="sampleSizesBox"/>
</item>
<item row="10" column="1">
- <widget class="QLineEdit" name="nearestSampleSize"/>
+ <widget class="QLineEdit" name="nearestSampleSize">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="actualSampleTypeLabel">
@@ -173,7 +200,11 @@
<widget class="QComboBox" name="sampleTypesBox"/>
</item>
<item row="12" column="1">
- <widget class="QLineEdit" name="nearestSampleType"/>
+ <widget class="QLineEdit" name="nearestSampleType">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="actualEndianLabel">
@@ -193,10 +224,17 @@
<widget class="QComboBox" name="endianBox"/>
</item>
<item row="14" column="1">
- <widget class="QLineEdit" name="nearestEndian"/>
+ <widget class="QLineEdit" name="nearestEndian">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
<item row="15" column="0" colspan="2">
<widget class="QTextEdit" name="logOutput">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="minimumSize">
<size>
<width>0</width>
@@ -216,16 +254,6 @@
</item>
</layout>
</widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>504</width>
- <height>19</height>
- </rect>
- </property>
- </widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
diff --git a/examples/multimedia/audiodevices/main.cpp b/examples/multimedia/audiodevices/main.cpp
index d5ddd4f..0ea18a1 100644
--- a/examples/multimedia/audiodevices/main.cpp
+++ b/examples/multimedia/audiodevices/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp
index 62afd73..8cc9948 100644
--- a/examples/multimedia/audioinput/audioinput.cpp
+++ b/examples/multimedia/audioinput/audioinput.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -52,8 +52,8 @@
#define BUFFER_SIZE 4096
-AudioInfo::AudioInfo(QObject* parent, QAudioInput* device)
- :QIODevice( parent )
+AudioInfo::AudioInfo(QObject *parent, QAudioInput *device)
+ :QIODevice(parent)
{
input = device;
@@ -90,21 +90,24 @@ qint64 AudioInfo::writeData(const char *data, qint64 len)
m_maxValue = 0;
- qint16* s = (qint16*)data;
+ qint16 *s = (qint16*)data;
// sample format is S16LE, only!
- for(int i=0;i<samples;i++) {
+ for (int i = 0; i < samples; ++i) {
qint16 sample = *s;
s++;
- if(abs(sample) > m_maxValue) m_maxValue = abs(sample);
+ if (abs(sample) > m_maxValue) m_maxValue = abs(sample);
}
// check for clipping
- if(m_maxValue>=(maxAmp-1)) clipping = true;
+ if (m_maxValue >= (maxAmp - 1))
+ clipping = true;
float value = ((float)m_maxValue/(float)maxAmp);
- if(clipping) m_maxValue = 100;
- else m_maxValue = (int)(value*100);
+ if (clipping)
+ m_maxValue = 100;
+ else
+ m_maxValue = (int)(value*100);
emit update();
@@ -132,25 +135,25 @@ void RenderArea::paintEvent(QPaintEvent * /* event */)
QPainter painter(this);
painter.setPen(Qt::black);
- painter.drawRect(QRect(painter.viewport().left()+10, painter.viewport().top()+10,
- painter.viewport().right()-20, painter.viewport().bottom()-20));
-
- if(level == 0)
+ painter.drawRect(QRect(painter.viewport().left()+10,
+ painter.viewport().top()+10,
+ painter.viewport().right()-20,
+ painter.viewport().bottom()-20));
+ if (level == 0)
return;
painter.setPen(Qt::red);
int pos = ((painter.viewport().right()-20)-(painter.viewport().left()+11))*level/100;
- int x1,y1,x2,y2;
- for(int i=0;i<10;i++) {
- x1 = painter.viewport().left()+11;
- y1 = painter.viewport().top()+10+i;
- x2 = painter.viewport().left()+20+pos;
- y2 = painter.viewport().top()+10+i;
- if(x2 < painter.viewport().left()+10)
+ for (int i = 0; i < 10; ++i) {
+ int x1 = painter.viewport().left()+11;
+ int y1 = painter.viewport().top()+10+i;
+ int x2 = painter.viewport().left()+20+pos;
+ int y2 = painter.viewport().top()+10+i;
+ if (x2 < painter.viewport().left()+10)
x2 = painter.viewport().left()+10;
- painter.drawLine(QPoint(x1,y1),QPoint(x2,y2));
+ painter.drawLine(QPoint(x1, y1),QPoint(x2, y2));
}
}
@@ -171,20 +174,20 @@ InputTest::InputTest()
deviceBox = new QComboBox(this);
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
- for(int i = 0; i < devices.size(); ++i) {
+ for(int i = 0; i < devices.size(); ++i)
deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i)));
- }
- connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int)));
+
+ connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int)));
layout->addWidget(deviceBox);
button = new QPushButton(this);
button->setText(tr("Click for Push Mode"));
- connect(button,SIGNAL(clicked()),SLOT(toggleMode()));
+ connect(button, SIGNAL(clicked()), SLOT(toggleMode()));
layout->addWidget(button);
button2 = new QPushButton(this);
button2->setText(tr("Click To Suspend"));
- connect(button2,SIGNAL(clicked()),SLOT(toggleSuspend()));
+ connect(button2, SIGNAL(clicked()), SLOT(toggleSuspend()));
layout->addWidget(button2);
window->setLayout(layout);
@@ -195,7 +198,6 @@ InputTest::InputTest()
pullMode = true;
- // AudioInfo class only supports mono S16LE samples!
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
@@ -203,11 +205,22 @@ 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)));
+ connect(audioInput, SIGNAL(notify()), SLOT(status()));
+ connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(state(QAudio::State)));
audioinfo = new AudioInfo(this,audioInput);
- connect(audioinfo,SIGNAL(update()),SLOT(refreshDisplay()));
+ connect(audioinfo, SIGNAL(update()), SLOT(refreshDisplay()));
audioinfo->start();
audioInput->start(audioinfo);
}
@@ -240,7 +253,7 @@ void InputTest::toggleMode()
if (pullMode) {
button->setText(tr("Click for Pull Mode"));
input = audioInput->start();
- connect(input,SIGNAL(readyRead()),SLOT(readMore()));
+ connect(input, SIGNAL(readyRead()), SLOT(readMore()));
pullMode = false;
} else {
button->setText(tr("Click for Push Mode"));
@@ -253,25 +266,25 @@ void InputTest::toggleSuspend()
{
// toggle suspend/resume
if(audioInput->state() == QAudio::SuspendedState) {
- qWarning()<<"status: Suspended, resume()";
+ qWarning() << "status: Suspended, resume()";
audioInput->resume();
button2->setText("Click To Suspend");
} else if (audioInput->state() == QAudio::ActiveState) {
- qWarning()<<"status: Active, suspend()";
+ qWarning() << "status: Active, suspend()";
audioInput->suspend();
button2->setText("Click To Resume");
} else if (audioInput->state() == QAudio::StoppedState) {
- qWarning()<<"status: Stopped, resume()";
+ qWarning() << "status: Stopped, resume()";
audioInput->resume();
button2->setText("Click To Suspend");
} else if (audioInput->state() == QAudio::IdleState) {
- qWarning()<<"status: IdleState";
+ qWarning() << "status: IdleState";
}
}
void InputTest::state(QAudio::State state)
{
- qWarning()<<" state="<<state;
+ qWarning() << " state=" << state;
}
void InputTest::refreshDisplay()
@@ -289,8 +302,8 @@ void InputTest::deviceChanged(int idx)
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)));
+ connect(audioInput, SIGNAL(notify()), SLOT(status()));
+ connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(state(QAudio::State)));
audioinfo->start();
audioInput->start(audioinfo);
}
diff --git a/examples/multimedia/audioinput/audioinput.h b/examples/multimedia/audioinput/audioinput.h
index 14e1bac..abe2be1 100644
--- a/examples/multimedia/audioinput/audioinput.h
+++ b/examples/multimedia/audioinput/audioinput.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -52,7 +52,7 @@ class AudioInfo : public QIODevice
{
Q_OBJECT
public:
- AudioInfo(QObject* parent, QAudioInput* device);
+ AudioInfo(QObject *parent, QAudioInput *device);
~AudioInfo();
void start();
@@ -63,7 +63,7 @@ public:
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
- QAudioInput* input;
+ QAudioInput *input;
private:
int m_maxValue;
@@ -97,21 +97,6 @@ public:
InputTest();
~InputTest();
- QAudioDeviceInfo device;
- QAudioFormat format;
- QAudioInput* audioInput;
- AudioInfo* audioinfo;
- QIODevice* input;
- RenderArea* canvas;
-
- bool pullMode;
-
- QPushButton* button;
- QPushButton* button2;
- QComboBox* deviceBox;
-
- char* buffer;
-
private slots:
void refreshDisplay();
void status();
@@ -120,5 +105,21 @@ private slots:
void toggleSuspend();
void state(QAudio::State s);
void deviceChanged(int idx);
+
+private:
+ AudioInfo *audioinfo;
+ QAudioDeviceInfo device;
+ QAudioFormat format;
+ QAudioInput *audioInput;
+ QIODevice *input;
+ RenderArea *canvas;
+
+ bool pullMode;
+
+ QPushButton *button;
+ QPushButton *button2;
+ QComboBox *deviceBox;
+
+ char *buffer;
};
diff --git a/examples/multimedia/audioinput/main.cpp b/examples/multimedia/audioinput/main.cpp
index d7e9c6c..42104cf 100644
--- a/examples/multimedia/audioinput/main.cpp
+++ b/examples/multimedia/audioinput/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 244840d..0c57f4d 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -103,10 +103,10 @@ int Generator::fillData(char *start, int frequency, int seconds)
qint64 Generator::readData(char *data, qint64 maxlen)
{
int len = maxlen;
- if(len > 16384)
+ if (len > 16384)
len = 16384;
- if(len < (SECONDS*SYSTEM_FREQ*2)-pos) {
+ if (len < (SECONDS*SYSTEM_FREQ*2)-pos) {
// Normal
memcpy(data,t+pos,len);
pos+=len;
@@ -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)));
@@ -200,15 +212,15 @@ void AudioTest::deviceChanged(int idx)
void AudioTest::status()
{
- qWarning()<<"byteFree = "<<audioOutput->bytesFree()<<" bytes, elapsedUSecs = "<<audioOutput->elapsedUSecs()<<", processedUSecs = "<<audioOutput->processedUSecs();
+ qWarning() << "byteFree = " << audioOutput->bytesFree() << " bytes, elapsedUSecs = " << audioOutput->elapsedUSecs() << ", processedUSecs = " << audioOutput->processedUSecs();
}
void AudioTest::writeMore()
{
- if(!audioOutput)
+ if (!audioOutput)
return;
- if(audioOutput->state() == QAudio::StoppedState)
+ if (audioOutput->state() == QAudio::StoppedState)
return;
int l;
@@ -217,9 +229,9 @@ void AudioTest::writeMore()
int chunks = audioOutput->bytesFree()/audioOutput->periodSize();
while(chunks) {
l = gen->read(buffer,audioOutput->periodSize());
- if(l > 0)
+ if (l > 0)
out = output->write(buffer,l);
- if(l != audioOutput->periodSize())
+ if (l != audioOutput->periodSize())
break;
chunks--;
}
@@ -247,24 +259,24 @@ void AudioTest::toggle()
void AudioTest::togglePlay()
{
// toggle suspend/resume
- if(audioOutput->state() == QAudio::SuspendedState) {
- qWarning()<<"status: Suspended, resume()";
+ if (audioOutput->state() == QAudio::SuspendedState) {
+ qWarning() << "status: Suspended, resume()";
audioOutput->resume();
button2->setText("Click To Suspend");
} else if (audioOutput->state() == QAudio::ActiveState) {
- qWarning()<<"status: Active, suspend()";
+ qWarning() << "status: Active, suspend()";
audioOutput->suspend();
button2->setText("Click To Resume");
} else if (audioOutput->state() == QAudio::StoppedState) {
- qWarning()<<"status: Stopped, resume()";
+ qWarning() << "status: Stopped, resume()";
audioOutput->resume();
button2->setText("Click To Suspend");
} else if (audioOutput->state() == QAudio::IdleState) {
- qWarning()<<"status: IdleState";
+ qWarning() << "status: IdleState";
}
}
void AudioTest::state(QAudio::State state)
{
- qWarning()<<" state="<<state;
+ qWarning() << " state=" << state;
}
diff --git a/examples/multimedia/audiooutput/audiooutput.h b/examples/multimedia/audiooutput/audiooutput.h
index 6c07a3a..372cf78 100644
--- a/examples/multimedia/audiooutput/audiooutput.h
+++ b/examples/multimedia/audiooutput/audiooutput.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/audiooutput/main.cpp b/examples/multimedia/audiooutput/main.cpp
index 79ec99e..b2b3a06 100644
--- a/examples/multimedia/audiooutput/main.cpp
+++ b/examples/multimedia/audiooutput/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videographicsitem/main.cpp b/examples/multimedia/videographicsitem/main.cpp
index 3bf4c6d..4031010 100644
--- a/examples/multimedia/videographicsitem/main.cpp
+++ b/examples/multimedia/videographicsitem/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videographicsitem/videoitem.cpp b/examples/multimedia/videographicsitem/videoitem.cpp
index 99e8df8..c587c17 100644
--- a/examples/multimedia/videographicsitem/videoitem.cpp
+++ b/examples/multimedia/videographicsitem/videoitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videographicsitem/videoitem.h b/examples/multimedia/videographicsitem/videoitem.h
index 96f578a..733b289 100644
--- a/examples/multimedia/videographicsitem/videoitem.h
+++ b/examples/multimedia/videographicsitem/videoitem.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videographicsitem/videoplayer.cpp b/examples/multimedia/videographicsitem/videoplayer.cpp
index 9ac4152..4e1f5ca 100644
--- a/examples/multimedia/videographicsitem/videoplayer.cpp
+++ b/examples/multimedia/videographicsitem/videoplayer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videographicsitem/videoplayer.h b/examples/multimedia/videographicsitem/videoplayer.h
index 8e73e4c..ccb0a08 100644
--- a/examples/multimedia/videographicsitem/videoplayer.h
+++ b/examples/multimedia/videographicsitem/videoplayer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/main.cpp b/examples/multimedia/videowidget/main.cpp
index f5edf73..b327949 100644
--- a/examples/multimedia/videowidget/main.cpp
+++ b/examples/multimedia/videowidget/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videoplayer.cpp b/examples/multimedia/videowidget/videoplayer.cpp
index cd146e8..12d17cf 100644
--- a/examples/multimedia/videowidget/videoplayer.cpp
+++ b/examples/multimedia/videowidget/videoplayer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videoplayer.h b/examples/multimedia/videowidget/videoplayer.h
index 6547415..6994459 100644
--- a/examples/multimedia/videowidget/videoplayer.h
+++ b/examples/multimedia/videowidget/videoplayer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videowidget.cpp b/examples/multimedia/videowidget/videowidget.cpp
index f73a52f..25b3618 100644
--- a/examples/multimedia/videowidget/videowidget.cpp
+++ b/examples/multimedia/videowidget/videowidget.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videowidget.h b/examples/multimedia/videowidget/videowidget.h
index 8c343bf..ba5f641 100644
--- a/examples/multimedia/videowidget/videowidget.h
+++ b/examples/multimedia/videowidget/videowidget.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videowidgetsurface.cpp b/examples/multimedia/videowidget/videowidgetsurface.cpp
index b69375c..5a37cd3 100644
--- a/examples/multimedia/videowidget/videowidgetsurface.cpp
+++ b/examples/multimedia/videowidget/videowidgetsurface.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/examples/multimedia/videowidget/videowidgetsurface.h b/examples/multimedia/videowidget/videowidgetsurface.h
index 83439d3..39802b8 100644
--- a/examples/multimedia/videowidget/videowidgetsurface.h
+++ b/examples/multimedia/videowidget/videowidgetsurface.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**