diff options
author | Chris Robinson <[email protected]> | 2010-07-12 16:37:44 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-07-12 16:37:44 -0700 |
commit | 26127cd2f2bdc37d25bd35fa70626dd75916df85 (patch) | |
tree | 41cb4375ce748d0215cb8158632b6c5ee87a5e37 /Alc/winmm.c | |
parent | 42d9140afe5d4d689372684be0e82d1eeb5d72fa (diff) |
Use a long single buffer for WaveIn's capture buffers
Diffstat (limited to 'Alc/winmm.c')
-rw-r--r-- | Alc/winmm.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c index 03fe4f2c..317906f7 100644 --- a/Alc/winmm.c +++ b/Alc/winmm.c @@ -188,6 +188,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName DWORD ulCapturedDataSize; WinMMData *pData = NULL; ALint lDeviceID = 0; + ALbyte *BufferData; ALint lBufferSize; ALuint i; @@ -267,11 +268,17 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName lBufferSize = wfexCaptureFormat.nAvgBytesPerSec / 20; lBufferSize -= (lBufferSize % wfexCaptureFormat.nBlockAlign); + BufferData = calloc(4, lBufferSize); + if(!BufferData) + goto failure; + for(i = 0;i < 4;i++) { memset(&pData->WaveInBuffer[i], 0, sizeof(WAVEHDR)); pData->WaveInBuffer[i].dwBufferLength = lBufferSize; - pData->WaveInBuffer[i].lpData = calloc(1,pData->WaveInBuffer[i].dwBufferLength); + pData->WaveInBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData : + (pData->WaveInBuffer[i-1].lpData + + pData->WaveInBuffer[i-1].dwBufferLength)); pData->WaveInBuffer[i].dwFlags = 0; pData->WaveInBuffer[i].dwLoops = 0; waveInPrepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR)); @@ -297,7 +304,8 @@ failure: if(pData->WaveInBuffer[i].lpData) { waveInUnprepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR)); - free(pData->WaveInBuffer[i].lpData); + if(i == 0) + free(pData->WaveInBuffer[i].lpData); } } @@ -339,7 +347,8 @@ static void WinMMCloseCapture(ALCdevice *pDevice) for(i = 0;i < 4;i++) { waveInUnprepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR)); - free(pData->WaveInBuffer[i].lpData); + if(i == 0) + free(pData->WaveInBuffer[i].lpData); pData->WaveInBuffer[i].lpData = NULL; } |