]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mem.c
Add GL_ExtensionSupported in vid_null.c because vid_shared.c relies on
[xonotic/darkplaces.git] / snd_mem.c
index 2678da63b0b2c00d17b7360d051b9587ea17f41b..f6f9c145d85c073cf9aa2421f5cdab6d3dc17068 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "snd_main.h"
 #include "snd_ogg.h"
 #include "snd_wav.h"
-#include "snd_modplug.h"
 
 
 /*
@@ -59,12 +58,12 @@ snd_ringbuffer_t *Snd_CreateRingBuffer (const snd_format_t* format, unsigned int
                        maxframes = sampleframes;
 
                memsize = maxframes * format->width * format->channels;
-               ringbuffer->ring = Mem_Alloc(snd_mempool, memsize);
+               ringbuffer->ring = (unsigned char *) Mem_Alloc(snd_mempool, memsize);
                ringbuffer->maxframes = maxframes;
        }
        else
        {
-               ringbuffer->ring = buffer;
+               ringbuffer->ring = (unsigned char *) buffer;
                ringbuffer->maxframes = sampleframes;
        }
 
@@ -82,7 +81,7 @@ snd_buffer_t *Snd_CreateSndBuffer (const unsigned char *samples, unsigned int sa
        size_t newsampleframes, memsize;
        snd_buffer_t* sb;
 
-       newsampleframes = (double)sampleframes * (double)sb_speed / (double)in_format->speed;
+       newsampleframes = (size_t) ceil((double)sampleframes * (double)sb_speed / (double)in_format->speed);
 
        memsize = newsampleframes * in_format->channels * in_format->width;
        memsize += sizeof (*sb) - sizeof (sb->samples);
@@ -91,7 +90,7 @@ snd_buffer_t *Snd_CreateSndBuffer (const unsigned char *samples, unsigned int sa
        sb->format.channels = in_format->channels;
        sb->format.width = in_format->width;
        sb->format.speed = sb_speed;
-       sb->maxframes = newsampleframes;
+       sb->maxframes = (unsigned int)newsampleframes;
        sb->nbframes = 0;
 
        if (!Snd_AppendToSndBuffer (sb, samples, sampleframes, in_format))
@@ -124,7 +123,7 @@ qboolean Snd_AppendToSndBuffer (snd_buffer_t* sb, const unsigned char *samples,
                return false;
        }
 
-       outcount = (double)sampleframes * (double)sb->format.speed / (double)format->speed;
+       outcount = (size_t) ((double)sampleframes * (double)sb->format.speed / (double)format->speed);
 
        // If the sound buffer is too short
        if (outcount > sb->maxframes - sb->nbframes)
@@ -290,7 +289,7 @@ qboolean Snd_AppendToSndBuffer (snd_buffer_t* sb, const unsigned char *samples,
                }
        }
 
-       sb->nbframes += outcount;
+       sb->nbframes += (unsigned int)outcount;
        return true;
 }
 
@@ -326,6 +325,8 @@ qboolean S_LoadSound (sfx_t *sfx, qboolean complain)
        if (developer_loading.integer)
                Con_Printf("loading sound %s\n", sfx->name);
 
+       SCR_PushLoadingScreen(true, sfx->name, 1);
+
        // LordHavoc: if the sound filename does not begin with sound/, try adding it
        if (strncasecmp(sfx->name, "sound/", 6))
        {
@@ -334,18 +335,13 @@ qboolean S_LoadSound (sfx_t *sfx, qboolean complain)
                if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
                {
                        if (S_LoadWavFile (namebuffer, sfx))
-                               return true;
+                               goto loaded;
                        memcpy (namebuffer + len - 3, "ogg", 4);
                }
                if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".ogg"))
                {
                        if (OGG_LoadVorbisFile (namebuffer, sfx))
-                               return true;
-               }
-               else
-               {
-                       if (ModPlug_LoadModPlugFile (namebuffer, sfx))
-                               return true;
+                               goto loaded;
                }
        }
 
@@ -358,23 +354,24 @@ qboolean S_LoadSound (sfx_t *sfx, qboolean complain)
        if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
        {
                if (S_LoadWavFile (namebuffer, sfx))
-                       return true;
+                       goto loaded;
                memcpy (namebuffer + len - 3, "ogg", 4);
        }
        if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".ogg"))
        {
                if (OGG_LoadVorbisFile (namebuffer, sfx))
-                       return true;
-       }
-       else
-       {
-               if (ModPlug_LoadModPlugFile (namebuffer, sfx))
-                       return true;
+                       goto loaded;
        }
 
        // Can't load the sound!
        sfx->flags |= SFXFLAG_FILEMISSING;
        if (complain)
                Con_DPrintf("failed to load sound \"%s\"\n", sfx->name);
+
+       SCR_PopLoadingScreen(false);
        return false;
+
+loaded:
+       SCR_PopLoadingScreen(false);
+       return true;
 }