diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 00:12:46 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 00:12:46 (GMT) |
commit | 0a9af9856022393ce7c1c14b953106ab54f0cfed (patch) | |
tree | a7bd3d0e6daf683ba8c93e7b4ec9ad2f28c46d52 /src/multimedia/audio/qaudioinput_alsa_p.cpp | |
parent | 6e2c3e7306883cd4618742e37861e326e9c91895 (diff) | |
parent | 8cda4ebd5611a6680cd311ff7cadfcc43c6f1686 (diff) | |
download | Qt-0a9af9856022393ce7c1c14b953106ab54f0cfed.zip Qt-0a9af9856022393ce7c1c14b953106ab54f0cfed.tar.gz Qt-0a9af9856022393ce7c1c14b953106ab54f0cfed.tar.bz2 |
Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into 4.7-integration
* 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: (48 commits)
Remove test cases which cause stack overflow
Avoid a crash in the OpenVG paint engine when clipping to an empty path
Fix last character being overwritten in password field
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 038b62085831eef4dee423361c65ecd55b7b9b1d )
QSslSocket: Improve error handling
Compile when bootstrapping qmake
Fix regression in tst_qrand::testqrand()
syncqt: don't try to split %module's values
syncqt: fix wrong paths in include/ActiveQt/headers.pri
Fix a crash when recursing into QSharedPointer from QSharedPointer::clear()
Fix a couple of memory leaks due to not releasing CFTypes on Mac
Initalize the nativeDialogInUse variable
The Q_WGL define was removed years ago.
Compile
QUUid::createUuid() should not generate identical sequences on UNIX
typos fixed
Use lower case for including system header files
Added trace statements to Phonon MMF backend
Fix crash when removing columns in merged row
MMF Phonon backend: call winId() from VideoWidget constructor
...
Diffstat (limited to 'src/multimedia/audio/qaudioinput_alsa_p.cpp')
-rw-r--r-- | src/multimedia/audio/qaudioinput_alsa_p.cpp | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index c9a8b71..58669b3 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -120,7 +120,7 @@ int QAudioInputPrivate::xrun_recovery(int err) if(err < 0) reset = true; else { - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable <= 0) reset = true; } @@ -408,7 +408,7 @@ bool QAudioInputPrivate::open() snd_pcm_start(handle); // Step 5: Setup timer - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if(pullMode) connect(audioSource,SIGNAL(readyRead()),this,SLOT(userFeed())); @@ -437,19 +437,29 @@ void QAudioInputPrivate::close() } } -int QAudioInputPrivate::bytesReady() const +int QAudioInputPrivate::checkBytesReady() { if(resuming) - return period_size; - - if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) - return 0; - int frames = snd_pcm_avail_update(handle); - if (frames < 0) return frames; - if((int)frames > (int)buffer_frames) - frames = buffer_frames; + bytesAvailable = period_size; + else if(deviceState != QAudio::ActiveState + && deviceState != QAudio::IdleState) + bytesAvailable = 0; + else { + int frames = snd_pcm_avail_update(handle); + if (frames < 0) { + bytesAvailable = frames; + } else { + if((int)frames > (int)buffer_frames) + frames = buffer_frames; + bytesAvailable = snd_pcm_frames_to_bytes(handle, frames); + } + } + return bytesAvailable; +} - return snd_pcm_frames_to_bytes(handle, frames); +int QAudioInputPrivate::bytesReady() const +{ + return qMax(bytesAvailable, 0); } qint64 QAudioInputPrivate::read(char* data, qint64 len) @@ -460,12 +470,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if ( !handle ) return 0; - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable < 0) { // bytesAvailable as negative is error code, try to recover from it. xrun_recovery(bytesAvailable); - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if (bytesAvailable < 0) { // recovery failed must stop and set error. close(); @@ -639,11 +649,25 @@ bool QAudioInputPrivate::deviceReady() InputPrivate* a = qobject_cast<InputPrivate*>(audioSource); a->trigger(); } - bytesAvailable = bytesReady(); + bytesAvailable = checkBytesReady(); if(deviceState != QAudio::ActiveState) return true; + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = checkBytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; |