mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
Mix_QuickLoad_RAW sets a flag in the Mix_Chunk so that Mix_FreeChunk doesn't actually Free the sound.
Checks for the flag when freeing, and if it's 0, we free the data manually after Mix_FreeChunk. I went back to Z_Malloc and Z_Free for this because they still work after this.
This commit is contained in:
parent
725a65c1f7
commit
7b417b573c
1 changed files with 16 additions and 1 deletions
|
@ -178,7 +178,7 @@ static Mix_Chunk *ds2chunk(void *stream)
|
|||
return NULL; // would and/or did wrap, can't store.
|
||||
break;
|
||||
}
|
||||
sound = malloc(newsamples<<2); // samples * frequency shift * bytes per sample * channels
|
||||
sound = Z_Malloc(newsamples<<2, PU_SOUND, 0); // samples * frequency shift * bytes per sample * channels
|
||||
|
||||
s = (SINT8 *)stream;
|
||||
d = (INT16 *)sound;
|
||||
|
@ -401,7 +401,22 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
|||
void I_FreeSfx(sfxinfo_t *sfx)
|
||||
{
|
||||
if (sfx->data)
|
||||
{
|
||||
Mix_Chunk *chunk = (Mix_Chunk*)sfx->data;
|
||||
UINT8 *abufdata = NULL;
|
||||
if (chunk->allocated == 0)
|
||||
{
|
||||
// We allocated the data in this chunk, so get the abuf from mixer, then let it free the chunk, THEN we free the data
|
||||
// I believe this should ensure the sound is not playing when we free it
|
||||
abufdata = chunk->abuf;
|
||||
}
|
||||
Mix_FreeChunk(sfx->data);
|
||||
if (abufdata)
|
||||
{
|
||||
// I'm going to assume we used Z_Malloc to allocate this data.
|
||||
Z_Free(abufdata);
|
||||
}
|
||||
}
|
||||
sfx->data = NULL;
|
||||
sfx->lumpnum = LUMPERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue