summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/pulseaudio/qaudioinput_pulse.cpp6
-rwxr-xr-xtests/auto/integration/qaudioinput/tst_qaudioinput.cpp16
2 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/src/plugins/pulseaudio/qaudioinput_pulse.cpp
index cdb39281e..85e16396d 100644
--- a/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+++ b/src/plugins/pulseaudio/qaudioinput_pulse.cpp
@@ -513,6 +513,12 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
if (!m_pullMode && readBytes >= len)
break;
+
+ if (m_intervalTime && (m_timeStamp.elapsed() + m_elapsedTimeOffset) > m_intervalTime) {
+ emit notify();
+ m_elapsedTimeOffset = m_timeStamp.elapsed() + m_elapsedTimeOffset - m_intervalTime;
+ m_timeStamp.restart();
+ }
}
#ifdef DEBUG_PULSE
diff --git a/tests/auto/integration/qaudioinput/tst_qaudioinput.cpp b/tests/auto/integration/qaudioinput/tst_qaudioinput.cpp
index 7b66c66ce..4db63d007 100755
--- a/tests/auto/integration/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/integration/qaudioinput/tst_qaudioinput.cpp
@@ -55,6 +55,12 @@
//TESTED_COMPONENT=src/multimedia
#define AUDIO_BUFFER 192000
+#define RANGE_ERR 0.2
+
+template<typename T> inline bool qTolerantCompare(T value, T expected)
+{
+ return qAbs(value - expected) < (RANGE_ERR * expected);
+}
#ifndef QTRY_VERIFY2
#define QTRY_VERIFY2(__expr,__msg) \
@@ -469,7 +475,7 @@ void tst_QAudioInput::pull()
QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
- QVERIFY2((processedUs > 2800000 && processedUs < 3200000),
+ QVERIFY2(qTolerantCompare(processedUs, 3040000LL),
QString("processedUSecs() doesn't fall in acceptable range, should be 3040000 (%1)").arg(processedUs).toLocal8Bit().constData());
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");
@@ -567,11 +573,11 @@ void tst_QAudioInput::pullSuspendResume()
QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
- QVERIFY2((processedUs > 2800000 && processedUs < 3200000),
+ QVERIFY2(qTolerantCompare(processedUs, 3040000LL),
QString("processedUSecs() doesn't fall in acceptable range, should be 3040000 (%1)").arg(processedUs).toLocal8Bit().constData());
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");
- QVERIFY2((notifySignal.count() > 20 && notifySignal.count() < 40),
+ QVERIFY2((notifySignal.count() > 10 && notifySignal.count() < 50),
QString("notify() signals emitted (%1) should be 30").arg(notifySignal.count()).toLocal8Bit().constData());
WavHeader::writeDataLength(*audioFiles.at(i),audioFiles.at(i)->pos()-WavHeader::headerLength());
@@ -650,7 +656,7 @@ void tst_QAudioInput::push()
QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
- QVERIFY2((processedUs > 1800000 && processedUs < 2200000),
+ QVERIFY2(qTolerantCompare(processedUs, 2040000LL),
QString("processedUSecs() doesn't fall in acceptable range, should be 2040000 (%1)").arg(processedUs).toLocal8Bit().constData());
QVERIFY2((audioInput.error() == QAudio::NoError), "error() is not QAudio::NoError after stop()");
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");
@@ -777,7 +783,7 @@ void tst_QAudioInput::pushSuspendResume()
QString("didn't emit StoppedState signal after stop(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after stop()");
- QVERIFY2((processedUs > 1800000 && processedUs < 2200000),
+ QVERIFY2(qTolerantCompare(processedUs, 2040000LL),
QString("processedUSecs() doesn't fall in acceptable range, should be 2040000 (%1)").arg(processedUs).toLocal8Bit().constData());
QVERIFY2((audioInput.elapsedUSecs() == (qint64)0), "elapsedUSecs() not equal to zero in StoppedState");