summaryrefslogtreecommitdiff
path: root/examples/audioinput
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2012-01-25 13:50:37 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-25 07:18:48 +0100
commit3b00730ecaeb4f780b897c3f0683c1d449e7c6c7 (patch)
tree66fd49c3bf021e4199935d7ab1fcc096ab24fd24 /examples/audioinput
parent8aef60c1cf3897053a68498db414b91c00eec0fa (diff)
downloadqtmultimedia-3b00730ecaeb4f780b897c3f0683c1d449e7c6c7.tar.gz
Add a volume (gain) property to QAudioInput.
Only implemented for PulseAudio so far, but the API does explain that it's optional. Change-Id: I4543a1c81d810fe92bb08f1ed13f3a3534a371e4 Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'examples/audioinput')
-rw-r--r--examples/audioinput/audioinput.cpp13
-rw-r--r--examples/audioinput/audioinput.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/examples/audioinput/audioinput.cpp b/examples/audioinput/audioinput.cpp
index d21b0cb02..045311cb3 100644
--- a/examples/audioinput/audioinput.cpp
+++ b/examples/audioinput/audioinput.cpp
@@ -235,6 +235,12 @@ void InputTest::initializeWindow()
connect(m_deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int)));
layout->addWidget(m_deviceBox);
+ m_volumeSlider = new QSlider(Qt::Horizontal, this);
+ m_volumeSlider->setRange(0, 100);
+ m_volumeSlider->setValue(100);
+ connect(m_volumeSlider, SIGNAL(valueChanged(int)), SLOT(sliderChanged(int)));
+ layout->addWidget(m_volumeSlider);
+
m_modeButton = new QPushButton(this);
m_modeButton->setText(PushModeLabel);
connect(m_modeButton, SIGNAL(clicked()), SLOT(toggleMode()));
@@ -281,6 +287,7 @@ void InputTest::createAudioInput()
m_audioInput = new QAudioInput(m_device, m_format, this);
connect(m_audioInput, SIGNAL(notify()), SLOT(notified()));
connect(m_audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
+ m_volumeSlider->setValue(m_audioInput->volume() * 100);
m_audioInfo->start();
m_audioInput->start(m_audioInfo);
}
@@ -364,3 +371,9 @@ void InputTest::deviceChanged(int index)
m_device = m_deviceBox->itemData(index).value<QAudioDeviceInfo>();
createAudioInput();
}
+
+void InputTest::sliderChanged(int value)
+{
+ if (m_audioInput)
+ m_audioInput->setVolume(qreal(value) / 100);
+}
diff --git a/examples/audioinput/audioinput.h b/examples/audioinput/audioinput.h
index b14681361..1ef8e6533 100644
--- a/examples/audioinput/audioinput.h
+++ b/examples/audioinput/audioinput.h
@@ -48,6 +48,7 @@
#include <QPushButton>
#include <QComboBox>
#include <QByteArray>
+#include <QSlider>
#include <qaudioinput.h>
@@ -113,6 +114,7 @@ private slots:
void toggleSuspend();
void stateChanged(QAudio::State state);
void deviceChanged(int index);
+ void sliderChanged(int value);
private:
// Owned by layout
@@ -120,6 +122,7 @@ private:
QPushButton *m_modeButton;
QPushButton *m_suspendResumeButton;
QComboBox *m_deviceBox;
+ QSlider *m_volumeSlider;
QAudioDeviceInfo m_device;
AudioInfo *m_audioInfo;