summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudioinput_win32_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio/qaudioinput_win32_p.cpp')
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index 31441ae..d4226f5 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE
static CRITICAL_SECTION waveInCriticalSection;
+static const int minimumIntervalTime = 50;
+
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
settings(audioFormat)
{
@@ -226,6 +228,7 @@ bool QAudioInputPrivate::open()
period_size = buffer_size/2;
#endif
timeStamp.restart();
+ elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();
wfx.wBitsPerSample = settings.sampleSize();
wfx.nChannels = settings.channels();
@@ -297,6 +300,7 @@ bool QAudioInputPrivate::open()
return false;
}
timeStampOpened.restart();
+ elapsedTimeOffset = 0;
totalTimeValue = 0;
errorState = QAudio::NoError;
deviceState = QAudio::ActiveState;
@@ -473,7 +477,10 @@ int QAudioInputPrivate::periodSize() const
void QAudioInputPrivate::setNotifyInterval(int ms)
{
- intervalTime = ms;
+ if(ms >= minimumIntervalTime)
+ intervalTime = ms;
+ else
+ intervalTime = minimumIntervalTime;
}
int QAudioInputPrivate::notifyInterval() const
@@ -524,8 +531,9 @@ bool QAudioInputPrivate::deviceReady()
if(deviceState != QAudio::ActiveState)
return true;
- if(timeStamp.elapsed() > intervalTime && intervalTime > 50) {
+ if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify();
+ elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime;
timeStamp.restart();
}
return true;