Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
dquakeplus' snd_mem.c
Browse files Browse the repository at this point in the history
  • Loading branch information
MotoLegacy committed Sep 6, 2024
1 parent 142407d commit a8215c6
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions source/snd_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -130,15 +128,15 @@ 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;

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;
Expand Down Expand Up @@ -199,7 +197,7 @@ void FindNextChunk(char *name)
data_p = NULL;
return;
}

data_p += 4;
iff_chunk_len = GetLittleLong();
if (iff_chunk_len < 0)
Expand All @@ -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;
}
}
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -334,7 +336,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
info.samples = samples;

info.dataofs = data_p - wav;

return info;
}

0 comments on commit a8215c6

Please sign in to comment.