]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mem.c
Attempt to make loading screens not stay cached, to avoid loading GPU memory when...
[xonotic/darkplaces.git] / snd_mem.c
index 1c85951504a891264eb9669c9b9dae471c68be12..11b0a9d9a9a22a394497c627ff8293a9cb8e2824 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "snd_wav.h"
 #include "snd_modplug.h"
 
+unsigned char resampling_buffer [48000 * 2 * 2];
+
 
 /*
 ====================
@@ -82,7 +84,7 @@ snd_buffer_t *Snd_CreateSndBuffer (const unsigned char *samples, unsigned int sa
        size_t newsampleframes, memsize;
        snd_buffer_t* sb;
 
-       newsampleframes = (size_t) ((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);
@@ -326,6 +328,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 +338,18 @@ 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;
+                               goto loaded;
                }
                else
                {
                        if (ModPlug_LoadModPlugFile (namebuffer, sfx))
-                               return true;
+                               goto loaded;
                }
        }
 
@@ -358,23 +362,29 @@ 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;
+                       goto loaded;
        }
        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;
 }