--- a/src/multimedia/audio/qaudioinput_win32_p.cpp Wed Apr 21 12:15:23 2010 +0300
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp Wed Apr 21 20:15:53 2010 +0300
@@ -57,8 +57,6 @@
//#define DEBUG_AUDIO 1
-static CRITICAL_SECTION waveInCriticalSection;
-
static const int minimumIntervalTime = 50;
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
@@ -104,16 +102,16 @@
case WIM_OPEN:
break;
case WIM_DATA:
- EnterCriticalSection(&waveInCriticalSection);
+ EnterCriticalSection(&qAudio->waveInCriticalSection);
if(qAudio->waveFreeBlockCount > 0)
qAudio->waveFreeBlockCount--;
qAudio->feedback();
- LeaveCriticalSection(&waveInCriticalSection);
+ LeaveCriticalSection(&qAudio->waveInCriticalSection);
break;
case WIM_CLOSE:
- EnterCriticalSection(&waveInCriticalSection);
+ EnterCriticalSection(&qAudio->waveInCriticalSection);
qAudio->finished = true;
- LeaveCriticalSection(&waveInCriticalSection);
+ LeaveCriticalSection(&qAudio->waveInCriticalSection);
break;
default:
return;
@@ -158,7 +156,8 @@
int count = buffer_size/period_size;
for(int i = 0; i < count; i++) {
- waveInUnprepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR));
+ if (blocks->dwFlags & WHDR_PREPARED)
+ waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR));
blocks+=sizeof(WAVEHDR);
}
HeapFree(GetProcessHeap(), 0, blockArray);
@@ -226,8 +225,8 @@
#endif
header = 0;
if(buffer_size == 0) {
- // Default buffer size, 100ms, default period size is 20ms
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1;
+ // Default buffer size, 200ms, default period size is 40ms
+ buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
period_size = buffer_size/5;
} else {
period_size = buffer_size/5;