equal
deleted
inserted
replaced
54 #include "qaudioinput_win32_p.h" |
54 #include "qaudioinput_win32_p.h" |
55 |
55 |
56 QT_BEGIN_NAMESPACE |
56 QT_BEGIN_NAMESPACE |
57 |
57 |
58 //#define DEBUG_AUDIO 1 |
58 //#define DEBUG_AUDIO 1 |
59 |
|
60 static CRITICAL_SECTION waveInCriticalSection; |
|
61 |
59 |
62 static const int minimumIntervalTime = 50; |
60 static const int minimumIntervalTime = 50; |
63 |
61 |
64 QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): |
62 QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): |
65 settings(audioFormat) |
63 settings(audioFormat) |
102 |
100 |
103 switch(uMsg) { |
101 switch(uMsg) { |
104 case WIM_OPEN: |
102 case WIM_OPEN: |
105 break; |
103 break; |
106 case WIM_DATA: |
104 case WIM_DATA: |
107 EnterCriticalSection(&waveInCriticalSection); |
105 EnterCriticalSection(&qAudio->waveInCriticalSection); |
108 if(qAudio->waveFreeBlockCount > 0) |
106 if(qAudio->waveFreeBlockCount > 0) |
109 qAudio->waveFreeBlockCount--; |
107 qAudio->waveFreeBlockCount--; |
110 qAudio->feedback(); |
108 qAudio->feedback(); |
111 LeaveCriticalSection(&waveInCriticalSection); |
109 LeaveCriticalSection(&qAudio->waveInCriticalSection); |
112 break; |
110 break; |
113 case WIM_CLOSE: |
111 case WIM_CLOSE: |
114 EnterCriticalSection(&waveInCriticalSection); |
112 EnterCriticalSection(&qAudio->waveInCriticalSection); |
115 qAudio->finished = true; |
113 qAudio->finished = true; |
116 LeaveCriticalSection(&waveInCriticalSection); |
114 LeaveCriticalSection(&qAudio->waveInCriticalSection); |
117 break; |
115 break; |
118 default: |
116 default: |
119 return; |
117 return; |
120 } |
118 } |
121 } |
119 } |
224 QTime now(QTime::currentTime()); |
222 QTime now(QTime::currentTime()); |
225 qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()"; |
223 qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()"; |
226 #endif |
224 #endif |
227 header = 0; |
225 header = 0; |
228 if(buffer_size == 0) { |
226 if(buffer_size == 0) { |
229 // Default buffer size, 100ms, default period size is 20ms |
227 // Default buffer size, 200ms, default period size is 40ms |
230 buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1; |
228 buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; |
231 period_size = buffer_size/5; |
229 period_size = buffer_size/5; |
232 } else { |
230 } else { |
233 period_size = buffer_size/5; |
231 period_size = buffer_size/5; |
234 } |
232 } |
235 timeStamp.restart(); |
233 timeStamp.restart(); |