aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-07-28 08:27:52 -0700
committerChris Robinson <[email protected]>2011-07-28 08:27:52 -0700
commitf986f7dfad389efbef97dbed44bf0d99b18dddba (patch)
tree233912ab0cb434e1dd8974f7792881609b28b602
parentbcbc1dea251f9873fc749b1167e20694442e8f8e (diff)
Wait until all headers are unprepared before freeing the buffer
-rw-r--r--Alc/winmm.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c
index c1192928..08a626df 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -458,6 +458,7 @@ static ALCboolean WinMMResetPlayback(ALCdevice *device)
static void WinMMStopPlayback(ALCdevice *device)
{
WinMMData *pData = (WinMMData*)device->ExtraData;
+ void *buffer = NULL;
int i;
if(pData->hWaveThread == NULL)
@@ -478,10 +479,10 @@ static void WinMMStopPlayback(ALCdevice *device)
for(i = 0;i < 4;i++)
{
waveOutUnprepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR));
- if(i == 0)
- free(pData->WaveBuffer[i].lpData);
+ if(i == 0) buffer = pData->WaveBuffer[i].lpData;
pData->WaveBuffer[i].lpData = NULL;
}
+ free(buffer);
}
@@ -640,6 +641,7 @@ failure:
static void WinMMCloseCapture(ALCdevice *pDevice)
{
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
+ void *buffer = NULL;
int i;
// Call waveOutReset to shutdown wave device
@@ -656,10 +658,10 @@ static void WinMMCloseCapture(ALCdevice *pDevice)
for(i = 0;i < 4;i++)
{
waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR));
- if(i == 0)
- free(pData->WaveBuffer[i].lpData);
+ if(i == 0) buffer = pData->WaveBuffer[i].lpData;
pData->WaveBuffer[i].lpData = NULL;
}
+ free(buffer);
DestroyRingBuffer(pData->pRing);
pData->pRing = NULL;