From 7e8d7d298c5279436bc55699b8938347e33210df Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Thu, 20 May 2004 08:29:58 +0000 Subject: [PATCH] fixed a major memory leak and removed a bit of redundancy (d1x r1.5) --- ChangeLog | 3 ++ arch/win32/digi.c | 104 +++++++++++++++++----------------------------- 2 files changed, 40 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec4dd007..e0653a90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-05-20 Matthew Mueller + * arch/win32/digi.c: fixed a major memory leak and removed a bit + of redundancy (d1x r1.5) + * arch/win32/digi.c: call digi_reset_digi_sounds in digi_close to fix crashing (d1x r1.4) diff --git a/arch/win32/digi.c b/arch/win32/digi.c index 85243ec9..7a2ab837 100644 --- a/arch/win32/digi.c +++ b/arch/win32/digi.c @@ -183,20 +183,40 @@ int digi_xlat_sound(int soundno) return Sounds[soundno]; } +// added 2000/01/15 Matt Mueller -- remove some duplication (and fix a big memory leak, in the kill=0 one case) +static int DS_release_slot(int slot, int kill) +{ + if (SoundSlots[slot].lpsb) + { + unsigned int s; + + IDirectSoundBuffer_GetStatus(SoundSlots[slot].lpsb, &s); + if (s & DSBSTATUS_PLAYING) + { + if (kill) + IDirectSoundBuffer_Stop(SoundSlots[slot].lpsb); + else + return 0; + } + IDirectSoundBuffer_Release(SoundSlots[slot].lpsb); + SoundSlots[slot].playing = 0; + SoundSlots[slot].lpsb = NULL; + + return 1; + } + + return 0; +} + static int get_free_slot() { int i; - unsigned int s; + for (i=0; i