shithub: choc

Download patch

ref: e66653a8a67f3613344ae4ea30b37403d6ff17cf
parent: 1dbed3064b9392de6deef18c47df8ee41708563e
author: Simon Howard <[email protected]>
date: Sun Jul 12 12:47:12 EDT 2009

Fix compile with libsamplerate.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1620

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -63,8 +63,6 @@
 
 int use_libsamplerate = 0;
 
-extern int mb_used;
-
 // When a sound stops, check if it is still playing.  If it is not, 
 // we can mark the sound data as CACHE to be freed back for other
 // means.
@@ -364,10 +362,13 @@
     uint32_t resampled_sound_length[NUMSFX];
     float norm_factor;
     float max_amp = 0;
+    unsigned int zone_size;
 
     assert(use_libsamplerate);
 
-    if (mb_used < 32)
+    zone_size = Z_ZoneSize();
+
+    if (zone_size < 32 * 1024 * 1024)
     {
         fprintf(stderr,
                 "WARNING: low memory.  Heap size is only %d MiB.\n"
@@ -374,7 +375,7 @@
                 "WARNING: use_libsamplerate needs more heap!\n"
                 "WARNING: put -mb 64 on the command line to avoid "
                 "\"Error: Z_Malloc: failed on allocation of X bytes\" !\n",
-                mb_used);
+                zone_size / (1024 * 1024));
     }
 
     printf("I_PrecacheSounds_SRC: Precaching all sound effects..");
--- a/src/z_native.c
+++ b/src/z_native.c
@@ -483,3 +483,8 @@
     return -1;
 }
 
+unsigned int Z_ZoneSize(void)
+{
+    return 0;
+}
+
--- a/src/z_zone.c
+++ b/src/z_zone.c
@@ -473,3 +473,8 @@
     return free;
 }
 
+unsigned int Z_ZoneSize(void)
+{
+    return mainzone->size;
+}
+
--- a/src/z_zone.h
+++ b/src/z_zone.h
@@ -67,7 +67,7 @@
 void    Z_CheckHeap (void);
 void    Z_ChangeTag2 (void *ptr, int tag, char *file, int line);
 int     Z_FreeMemory (void);
-
+unsigned int Z_ZoneSize(void);
 
 //
 // This is used to get the local FILE:LINE info from CPP