diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-15 12:11:08 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-15 12:11:08 (GMT) |
commit | 90d7b8dd7968c3e63cd3d9b7e8e1b5d83b20b475 (patch) | |
tree | a519424035cdbd92d665c748ffa6ecfa8d553f3b /src/multimedia/audio/qaudioinput_alsa_p.cpp | |
parent | 065f26ef3996368ba67ff5d8e34b20106c359a95 (diff) | |
parent | 02d1a0422c42889813bb2586503aff43a3509e09 (diff) | |
download | Qt-90d7b8dd7968c3e63cd3d9b7e8e1b5d83b20b475.zip Qt-90d7b8dd7968c3e63cd3d9b7e8e1b5d83b20b475.tar.gz Qt-90d7b8dd7968c3e63cd3d9b7e8e1b5d83b20b475.tar.bz2 |
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts:
src/gui/styles/qs60style_s60.cpp
Diffstat (limited to 'src/multimedia/audio/qaudioinput_alsa_p.cpp')
-rw-r--r-- | src/multimedia/audio/qaudioinput_alsa_p.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 6010f3c..ead9995 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -121,6 +121,11 @@ int QAudioInputPrivate::xrun_recovery(int err) err = snd_pcm_prepare(handle); if(err < 0) reset = true; + else { + bytesAvailable = bytesReady(); + if (bytesAvailable <= 0) + reset = true; + } } else if((err == -ESTRPIPE)||(err == -EIO)) { errorState = QAudio::IOError; @@ -443,6 +448,7 @@ int QAudioInputPrivate::bytesReady() const 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; @@ -459,6 +465,20 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) bytesAvailable = bytesReady(); + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = bytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + int count=0, err = 0; while(count < 5) { int chunks = bytesAvailable/period_size; @@ -588,7 +608,11 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::processedUSecs() const { - return qint64(1000000) * totalTimeValue / settings.frequency(); + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; } void QAudioInputPrivate::suspend() |