dquakeplus' snd_mem.c

This commit is contained in:
cypress 2024-09-05 18:11:31 -07:00
parent 142407d4af
commit a8215c6dbe

View file

@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@ -38,7 +38,7 @@ void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
int i;
int sample, samplefrac, fracstep;
sfxcache_t *sc;
sc = Cache_Check (&sfx->cache);
if (!sc)
return;
@ -105,19 +105,17 @@ sfxcache_t *S_LoadSound (sfx_t *s)
byte stackbuf[1*1024]; // avoid dirtying the cache heap
// see if still in memory
sc = Cache_Check (&s->cache);
if (sc)
if ((sc = Cache_Check (&s->cache)))
return sc;
//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf);
// load it in
Q_strcpy(namebuffer, s->name);
Q_strcpy(namebuffer, "");
Q_strcat(namebuffer, s->name);
// Con_Printf ("loading %s\n",namebuffer);
data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf));
if (!data)
if (!(data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf))))
{
Con_Printf ("Couldn't load %s\n", namebuffer);
return NULL;
@ -130,7 +128,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
return NULL;
}
stepscale = (float)info.rate / shm->speed;
stepscale = (float)info.rate / shm->speed;
len = info.samples / stepscale;
len = len * info.width * info.channels;
@ -138,7 +136,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
sc = Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
if (!sc)
return NULL;
sc->length = info.samples;
sc->loopstart = info.loopstart;
sc->speed = info.rate;
@ -199,7 +197,7 @@ void FindNextChunk(char *name)
data_p = NULL;
return;
}
data_p += 4;
iff_chunk_len = GetLittleLong();
if (iff_chunk_len < 0)
@ -211,7 +209,7 @@ void FindNextChunk(char *name)
// Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
data_p -= 8;
last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
if (!strncmp(data_p, name, 4))
if (!strncmp((char*) data_p, name, 4))
return;
}
}
@ -226,12 +224,16 @@ void FindChunk(char *name)
void DumpChunks(void)
{
char str[5];
str[4] = 0;
data_p=iff_data;
do
{
memcpy (str, data_p, 4);
#ifdef PSP_VFPU
memcpy_vfpu(str, data_p, 4);
#else
memcpy(str, data_p, 4);
#endif // PSP_VFPU
data_p += 4;
iff_chunk_len = GetLittleLong();
Con_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
@ -255,13 +257,13 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
if (!wav)
return info;
iff_data = wav;
iff_end = wav + wavlength;
// find "RIFF" chunk
FindChunk("RIFF");
if (!(data_p && !strncmp(data_p+8, "WAVE", 4)))
if (!(data_p && !strncmp((char*) data_p+8, "WAVE", 4)))
{
Con_Printf("Missing RIFF/WAVE chunks\n");
return info;
@ -302,7 +304,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
FindNextChunk ("LIST");
if (data_p)
{
if (!strncmp (data_p + 28, "mark", 4))
if (!strncmp ((char*) data_p + 28, "mark", 4))
{ // this is not a proper parse, but it works with cooledit...
data_p += 24;
i = GetLittleLong (); // samples in loop
@ -334,7 +336,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
info.samples = samples;
info.dataofs = data_p - wav;
return info;
}