From a5b4b54820b9266a2916981002e9be66fd0a7710 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 9 Apr 2010 12:59:47 +1000 Subject: Just one (static) waveInCriticalSection but multiple QAudioInput to record from different soundcards Task-number:QTBUG-9221 Reviewed-by:Andrew den Exter --- src/multimedia/audio/qaudioinput_win32_p.cpp | 10 ++++------ src/multimedia/audio/qaudioinput_win32_p.h | 2 ++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 8 +++----- src/multimedia/audio/qaudiooutput_win32_p.h | 2 ++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index ec0359a..bf13c43 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -57,8 +57,6 @@ QT_BEGIN_NAMESPACE //#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 @@ void CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, 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; diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h index d555eff..a12c75e 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -122,6 +122,8 @@ private: volatile int waveFreeBlockCount; int waveCurrentBlock; + CRITICAL_SECTION waveInCriticalSection; + static void CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index f3ba079..e818723 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE -static CRITICAL_SECTION waveOutCriticalSection; - static const int minimumIntervalTime = 50; QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): @@ -107,16 +105,16 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, case WOM_CLOSE: return; case WOM_DONE: - EnterCriticalSection(&waveOutCriticalSection); + EnterCriticalSection(&qAudio->waveOutCriticalSection); if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { - LeaveCriticalSection(&waveOutCriticalSection); + LeaveCriticalSection(&qAudio->waveOutCriticalSection); return; } qAudio->waveFreeBlockCount++; if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; qAudio->feedback(); - LeaveCriticalSection(&waveOutCriticalSection); + LeaveCriticalSection(&qAudio->waveOutCriticalSection); break; default: return; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index 6e0899f..a7a0b07 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -119,6 +119,8 @@ private: static void CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + CRITICAL_SECTION waveOutCriticalSection; + WAVEHDR* allocateBlocks(int size, int count); void freeBlocks(WAVEHDR* blockArray); bool open(); -- cgit v0.12