diff options
Diffstat (limited to 'src/multimedia/audio/qaudiooutput_alsa_p.cpp')
-rw-r--r-- | src/multimedia/audio/qaudiooutput_alsa_p.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index cfd3c55..0d37d61 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE //#define DEBUG_AUDIO 1 +static const int minimumIntervalTime = 50; + QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): settings(audioFormat) { @@ -271,6 +273,7 @@ bool QAudioOutputPrivate::open() qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()"; #endif timeStamp.restart(); + elapsedTimeOffset = 0; int dir; int err=-1; @@ -404,6 +407,8 @@ bool QAudioOutputPrivate::open() // Step 6: Start audio processing timer->start(period_time/1000); + timeStamp.restart(); + elapsedTimeOffset = 0; errorState = QAudio::NoError; totalTimeValue = 0; opened = true; @@ -500,7 +505,10 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int ms) { - intervalTime = ms; + if(ms >= minimumIntervalTime) + intervalTime = ms; + else + intervalTime = minimumIntervalTime; } int QAudioOutputPrivate::notifyInterval() const @@ -629,8 +637,9 @@ bool QAudioOutputPrivate::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; |