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>
This commit is contained in:
committed by
Qt by Nokia
parent
8aef60c1cf
commit
3b00730eca
@@ -101,6 +101,8 @@ private slots:
|
||||
|
||||
void reset();
|
||||
|
||||
void volume();
|
||||
|
||||
private:
|
||||
typedef QSharedPointer<QFile> FilePtr;
|
||||
|
||||
@@ -840,6 +842,31 @@ void tst_QAudioInput::reset()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioInput::volume()
|
||||
{
|
||||
const qreal half(0.5f);
|
||||
const qreal one(1.0f);
|
||||
// Hard to automatically test, but we can test the get/set a little
|
||||
for (int i=0; i < testFormats.count(); i++) {
|
||||
QAudioInput audioInput(testFormats.at(i), this);
|
||||
|
||||
qreal volume = audioInput.volume();
|
||||
audioInput.setVolume(half);
|
||||
QVERIFY(qFuzzyCompare(audioInput.volume(), half) || qFuzzyCompare(audioInput.volume(), one));
|
||||
|
||||
// Wait a while to see if this changes
|
||||
QTest::qWait(500);
|
||||
QVERIFY(qFuzzyCompare(audioInput.volume(), half) || qFuzzyCompare(audioInput.volume(), one));
|
||||
|
||||
audioInput.setVolume(volume);
|
||||
QVERIFY(qFuzzyCompare(audioInput.volume(), volume));
|
||||
|
||||
// Wait a while to see if this changes
|
||||
QTest::qWait(500);
|
||||
QVERIFY(qFuzzyCompare(audioInput.volume(), volume));
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioInput)
|
||||
|
||||
#include "tst_qaudioinput.moc"
|
||||
|
||||
Reference in New Issue
Block a user