Fix issue with sounds being expired from cache

git-svn-id: https://svn.eduke32.com/eduke32@7874 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-08-01 07:10:16 +00:00 committed by Christoph Oelckers
parent 1a0c56f0f1
commit 2a3c80f95d
2 changed files with 19 additions and 3 deletions

View file

@ -191,7 +191,7 @@ int32_t cacheFindBlock(int32_t newbytes, int32_t *besto, int32_t *bestz)
for (native_t i=o1, zz=z; i<o2; i+=cac[zz++].leng) for (native_t i=o1, zz=z; i<o2; i+=cac[zz++].leng)
{ {
if (*cac[zz].lock == 0) if (*cac[zz].lock == 0 || *cac[zz].lock == 255)
continue; continue;
else if (*cac[zz].lock >= 200) else if (*cac[zz].lock >= 200)
{ {
@ -317,7 +317,7 @@ void cacheAgeEntries(void)
{ {
if ((((*cac[agecount].lock)-2)&255) < 198) if ((((*cac[agecount].lock)-2)&255) < 198)
(*cac[agecount].lock)--; (*cac[agecount].lock)--;
else if (*cac[agecount].lock >= 200) else if (*cac[agecount].lock == 255)
cnt++; cnt++;
} }

View file

@ -72,7 +72,9 @@ void S_SoundStartup(void)
voice.clock = 0; voice.clock = 0;
} }
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[i] = 199; g_soundlocks[i] = 199;
#endif
} }
cacheAllSounds(); cacheAllSounds();
@ -448,7 +450,7 @@ int32_t S_LoadSound(int num)
} }
int32_t l = kfilelength(fp); int32_t l = kfilelength(fp);
g_soundlocks[num] = 200; g_soundlocks[num] = 255;
snd.siz = l; snd.siz = l;
cacheAllocateBlock((intptr_t *)&snd.ptr, l, (char *)&g_soundlocks[num]); cacheAllocateBlock((intptr_t *)&snd.ptr, l, (char *)&g_soundlocks[num]);
l = kread(fp, snd.ptr, l); l = kread(fp, snd.ptr, l);
@ -705,14 +707,18 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
if (snd.num > 0 && PN(spriteNum) != MUSICANDSFX) if (snd.num > 0 && PN(spriteNum) != MUSICANDSFX)
S_StopEnvSound(sndNum, spriteNum); S_StopEnvSound(sndNum, spriteNum);
#ifdef CACHING_DOESNT_SUCK
if (++g_soundlocks[sndNum] < 200) if (++g_soundlocks[sndNum] < 200)
g_soundlocks[sndNum] = 200; g_soundlocks[sndNum] = 200;
#endif
int const sndSlot = S_GetSlot(sndNum); int const sndSlot = S_GetSlot(sndNum);
if (sndSlot >= MAXSOUNDINSTANCES) if (sndSlot >= MAXSOUNDINSTANCES)
{ {
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[sndNum]--; g_soundlocks[sndNum]--;
#endif
return -1; return -1;
} }
@ -720,7 +726,9 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
if (repeatp && (snd.m & SF_ONEINST_INTERNAL) && snd.num > 0) if (repeatp && (snd.m & SF_ONEINST_INTERNAL) && snd.num > 0)
{ {
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[sndNum]--; g_soundlocks[sndNum]--;
#endif
return -1; return -1;
} }
@ -729,7 +737,9 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos)
if (voice <= FX_Ok) if (voice <= FX_Ok)
{ {
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[sndNum]--; g_soundlocks[sndNum]--;
#endif
return -1; return -1;
} }
@ -764,14 +774,18 @@ int S_PlaySound(int num)
int const pitch = S_GetPitch(num); int const pitch = S_GetPitch(num);
#ifdef CACHING_DOESNT_SUCK
if (++g_soundlocks[num] < 200) if (++g_soundlocks[num] < 200)
g_soundlocks[num] = 200; g_soundlocks[num] = 200;
#endif
sndnum = S_GetSlot(num); sndnum = S_GetSlot(num);
if (sndnum >= MAXSOUNDINSTANCES) if (sndnum >= MAXSOUNDINSTANCES)
{ {
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[num]--; g_soundlocks[num]--;
#endif
return -1; return -1;
} }
@ -782,7 +796,9 @@ int S_PlaySound(int num)
if (voice <= FX_Ok) if (voice <= FX_Ok)
{ {
#ifdef CACHING_DOESNT_SUCK
g_soundlocks[num]--; g_soundlocks[num]--;
#endif
return -1; return -1;
} }