]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_wav.c
eliminated calls to Matrix4x4_CreateIdentity (now copies from the already existing...
[xonotic/darkplaces.git] / snd_wav.c
index d8af145438f82936a48b894b86bb201ec9b59a0d..b6cfe26cc83d683cf42ac55b20294c00bf76bacd 100644 (file)
--- a/snd_wav.c
+++ b/snd_wav.c
@@ -27,7 +27,7 @@
 #include "snd_wav.h"
 
 
-typedef struct
+typedef struct wavinfo_s
 {
        int             rate;
        int             width;
@@ -38,10 +38,10 @@ typedef struct
 } wavinfo_t;
 
 
-static qbyte *data_p;
-static qbyte *iff_end;
-static qbyte *last_chunk;
-static qbyte *iff_data;
+static unsigned char *data_p;
+static unsigned char *iff_end;
+static unsigned char *last_chunk;
+static unsigned char *iff_data;
 static int iff_chunk_len;
 
 
@@ -86,7 +86,7 @@ static void FindNextChunk(char *name)
                }
                data_p -= 8;
                last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
-               if (!strncmp(data_p, name, 4))
+               if (!strncmp((const char *)data_p, name, 4))
                        return;
        }
 }
@@ -122,7 +122,7 @@ static void DumpChunks(void)
 GetWavinfo
 ============
 */
-static wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength)
+static wavinfo_t GetWavinfo (char *name, unsigned char *wav, int wavlength)
 {
        wavinfo_t info;
        int i;
@@ -139,7 +139,7 @@ static wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength)
 
        // find "RIFF" chunk
        FindChunk("RIFF");
-       if (!(data_p && !strncmp(data_p+8, "WAVE", 4)))
+       if (!(data_p && !strncmp((const char *)data_p+8, "WAVE", 4)))
        {
                Con_Print("Missing RIFF/WAVE chunks\n");
                return info;
@@ -179,7 +179,7 @@ static wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength)
                FindNextChunk ("LIST");
                if (data_p)
                {
-                       if (!strncmp (data_p + 28, "mark", 4))
+                       if (!strncmp ((const 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
@@ -205,7 +205,7 @@ static wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength)
        {
                if (samples < info.samples)
                {
-                       Con_Printf ("Sound %s has a bad loop length", name);
+                       Con_Printf ("Sound %s has a bad loop length\n", name);
                        info.samples = samples;
                }
        }
@@ -225,7 +225,7 @@ WAV_FetchSound
 */
 static const sfxbuffer_t* WAV_FetchSound (channel_t* ch, unsigned int start, unsigned int nbsamples)
 {
-       return ch->sfx->fetcher_data;
+       return (sfxbuffer_t *)ch->sfx->fetcher_data;
 }
 
 /*
@@ -235,7 +235,7 @@ WAV_FreeSfx
 */
 static void WAV_FreeSfx (sfx_t* sfx)
 {
-       sfxbuffer_t* sb = sfx->fetcher_data;
+       sfxbuffer_t* sb = (sfxbuffer_t *)sfx->fetcher_data;
 
        // Free the sound buffer
        sfx->memsize -= (sb->length * sfx->format.channels * sfx->format.width) + sizeof (*sb) - sizeof (sb->data);
@@ -255,7 +255,8 @@ S_LoadWavFile
 */
 qboolean S_LoadWavFile (const char *filename, sfx_t *s)
 {
-       qbyte *data;
+       fs_offset_t filesize;
+       unsigned char *data;
        wavinfo_t info;
        int len;
        size_t memsize;
@@ -266,7 +267,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s)
                return true;
 
        // Load the file
-       data = FS_LoadFile(filename, snd_mempool, false);
+       data = FS_LoadFile(filename, snd_mempool, false, &filesize);
        if (!data)
                return false;
 
@@ -279,7 +280,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s)
 
        Con_DPrintf ("Loading WAV file \"%s\"\n", filename);
 
-       info = GetWavinfo (s->name, data, (int)fs_filesize);
+       info = GetWavinfo (s->name, data, (int)filesize);
        // Stereo sounds are allowed (intended for music)
        if (info.channels < 1 || info.channels > 2)
        {
@@ -295,7 +296,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s)
        len = len * info.width * info.channels;
 
        memsize = len + sizeof (*sb) - sizeof (sb->data);
-       sb = Mem_Alloc (snd_mempool, memsize);
+       sb = (sfxbuffer_t *)Mem_Alloc (snd_mempool, memsize);
        if (sb == NULL)
        {
                Con_Printf("failed to allocate memory for sound \"%s\"\n", s->name);