aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-07-08 17:37:35 -0700
committerChris Robinson <[email protected]>2010-07-08 17:37:35 -0700
commit52ad28df92d643a5dd655fe1d5b63a6db47d9322 (patch)
treea29163a51bc734b3f40add2649b2723da64df0e2
parent58ba5fd0dd740771bc158847be5c7cbfe4ff66e8 (diff)
Fix WaveIn device cleanup order
-rw-r--r--Alc/winmm.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 5d927d48..03fe4f2c 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -267,7 +267,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
lBufferSize = wfexCaptureFormat.nAvgBytesPerSec / 20;
lBufferSize -= (lBufferSize % wfexCaptureFormat.nBlockAlign);
- for (i=0;i<4;i++)
+ for(i = 0;i < 4;i++)
{
memset(&pData->WaveInBuffer[i], 0, sizeof(WAVEHDR));
pData->WaveInBuffer[i].dwBufferLength = lBufferSize;
@@ -289,7 +289,10 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
return ALC_TRUE;
failure:
- for (i=0;i<4;i++)
+ if(pData->hWaveInThread)
+ CloseHandle(pData->hWaveInThread);
+
+ for(i = 0;i < 4;i++)
{
if(pData->WaveInBuffer[i].lpData)
{
@@ -298,14 +301,16 @@ failure:
}
}
+ if(pData->pRing)
+ DestroyRingBuffer(pData->pRing);
+
+ if(pData->hWaveInThreadEvent)
+ CloseHandle(pData->hWaveInThreadEvent);
+ if(pData->hWaveInHdrEvent)
+ CloseHandle(pData->hWaveInHdrEvent);
+
if(pData->hWaveInHandle)
waveInClose(pData->hWaveInHandle);
- if(pData->hWaveInThread)
- CloseHandle(pData->hWaveInThread);
- if (pData->hWaveInHdrEvent)
- CloseHandle(pData->hWaveInHdrEvent);
- if (pData->hWaveInThreadEvent)
- CloseHandle(pData->hWaveInThreadEvent);
free(pData);
pDevice->ExtraData = NULL;
@@ -327,31 +332,29 @@ static void WinMMCloseCapture(ALCdevice *pDevice)
// Wait for signal that Wave Thread has been destroyed
WaitForSingleObjectEx(pData->hWaveInThreadEvent, 5000, FALSE);
+ CloseHandle(pData->hWaveInThread);
+ pData->hWaveInThread = 0;
+
// Release the wave buffers
- for (i=0;i<4;i++)
+ for(i = 0;i < 4;i++)
{
waveInUnprepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR));
free(pData->WaveInBuffer[i].lpData);
+ pData->WaveInBuffer[i].lpData = NULL;
}
- // Close the Wave device
- waveInClose(pData->hWaveInHandle);
- pData->hWaveInHandle = 0;
+ DestroyRingBuffer(pData->pRing);
+ pData->pRing = NULL;
- CloseHandle(pData->hWaveInThread);
- pData->hWaveInThread = 0;
+ // Close the Wave device
+ CloseHandle(pData->hWaveInThreadEvent);
+ pData->hWaveInThreadEvent = 0;
- if (pData->hWaveInHdrEvent)
- {
- CloseHandle(pData->hWaveInHdrEvent);
- pData->hWaveInHdrEvent = 0;
- }
+ CloseHandle(pData->hWaveInHdrEvent);
+ pData->hWaveInHdrEvent = 0;
- if (pData->hWaveInThreadEvent)
- {
- CloseHandle(pData->hWaveInThreadEvent);
- pData->hWaveInThreadEvent = 0;
- }
+ waveInClose(pData->hWaveInHandle);
+ pData->hWaveInHandle = 0;
free(pData);
pDevice->ExtraData = NULL;