diff options
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/audio/audio.pri | 4 | ||||
-rw-r--r-- | src/multimedia/audio/qaudioinput_alsa_p.cpp | 21 | ||||
-rw-r--r-- | src/multimedia/audio/qaudioinput_win32_p.cpp | 11 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_win32_p.cpp | 2 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index f03d0ac..7b2f9ad 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -42,8 +42,8 @@ mac { wince*:LIBS += -lcoredll } else:symbian { - INCLUDEPATH += $${EPOCROOT}/epoc32/include/mmf/common - INCLUDEPATH += $${EPOCROOT}/epoc32/include/mmf/server + INCLUDEPATH += $${EPOCROOT}epoc32/include/mmf/common + INCLUDEPATH += $${EPOCROOT}epoc32/include/mmf/server HEADERS += $$PWD/qaudio_symbian_p.h \ $$PWD/qaudiodeviceinfo_symbian_p.h \ diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index ddafa3d..5265915 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -482,19 +482,18 @@ int QAudioInputPrivate::bytesReady() const qint64 QAudioInputPrivate::read(char* data, qint64 len) { - Q_UNUSED(len) - // Read in some audio data and write it to QIODevice, pull mode if ( !handle ) return 0; - bytesAvailable = checkBytesReady(); + // bytesAvaiable is saved as a side effect of checkBytesReady(). + int bytesToRead = checkBytesReady(); - if (bytesAvailable < 0) { + if (bytesToRead < 0) { // bytesAvailable as negative is error code, try to recover from it. - xrun_recovery(bytesAvailable); - bytesAvailable = checkBytesReady(); - if (bytesAvailable < 0) { + xrun_recovery(bytesToRead); + bytesToRead = checkBytesReady(); + if (bytesToRead < 0) { // recovery failed must stop and set error. close(); errorState = QAudio::IOError; @@ -504,9 +503,11 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) } } + bytesToRead = qMin<qint64>(len, bytesToRead); + bytesToRead -= bytesToRead % period_size; int count=0, err = 0; while(count < 5) { - int chunks = bytesAvailable/period_size; + int chunks = bytesToRead/period_size; int frames = chunks*period_frames; if(frames > (int)buffer_frames) frames = buffer_frames; @@ -554,6 +555,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) emit stateChanged(deviceState); } } else { + bytesAvailable -= err; totalTimeValue += err; resuming = false; if (deviceState != QAudio::ActiveState) { @@ -566,6 +568,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) } else { memcpy(data,audioBuffer,err); + bytesAvailable -= err; totalTimeValue += err; resuming = false; if (deviceState != QAudio::ActiveState) { @@ -661,7 +664,7 @@ bool QAudioInputPrivate::deviceReady() { if(pullMode) { // reads some audio data and writes it to QIODevice - read(0,0); + read(0, buffer_size); } else { // emits readyRead() so user will call read() on QIODevice to get some audio data InputPrivate* a = qobject_cast<InputPrivate*>(audioSource); diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 1cde159..0ec2492 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -400,9 +400,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) resuming = false; } } else { + l = qMin<qint64>(len, waveBlocks[header].dwBytesRecorded); // push mode - memcpy(p,waveBlocks[header].lpData,waveBlocks[header].dwBytesRecorded); - l = waveBlocks[header].dwBytesRecorded; + memcpy(p, waveBlocks[header].lpData, l); + + len -= l; + #ifdef DEBUG_AUDIO qDebug()<<"IN: "<<waveBlocks[header].dwBytesRecorded<<", OUT: "<<l; #endif @@ -457,7 +460,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) mutex.lock(); if(!pullMode) { - if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) + if(len < period_size || waveFreeBlockCount == buffer_size/period_size) done = true; } else { if(waveFreeBlockCount == buffer_size/period_size) @@ -568,7 +571,7 @@ bool QAudioInputPrivate::deviceReady() if(pullMode) { // reads some audio data and writes it to QIODevice - read(0,0); + read(0, buffer_size); } else { // emits readyRead() so user will call read() on QIODevice to get some audio data InputPrivate* a = qobject_cast<InputPrivate*>(audioSource); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 1f304e3..1b054e5 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -586,7 +586,7 @@ bool QAudioOutputPrivate::deviceReady() } } if ( out < l) { - // Didnt write all data + // Didn't write all data audioSource->seek(audioSource->pos()-(l-out)); } if(startup) |