changeset 3019:dfd23eb79be9

Allow builds that reduce or eliminate the converters/resamplers. We should probably give options to drop resamplers by channels, too, for developers that know they'll never need more than stereo, etc.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 11 Jan 2009 04:39:09 +0000
parents d706d3170d7d
children 70d876a0b90e
files src/audio/sdlgenaudiocvt.pl
diffstat 1 files changed, 58 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/audio/sdlgenaudiocvt.pl	Sun Jan 11 04:29:36 2009 +0000
+++ b/src/audio/sdlgenaudiocvt.pl	Sun Jan 11 04:39:09 2009 +0000
@@ -62,6 +62,29 @@
 #include "SDL_audio.h"
 #include "SDL_audio_c.h"
 
+#ifndef DEBUG_CONVERT
+#define DEBUG_CONVERT 0
+#endif
+
+
+/* If you can guarantee your data and need space, you can eliminate code... */
+
+/* Just build the arbitrary resamplers if you're saving code space. */
+#ifndef LESS_RESAMPLERS
+#define LESS_RESAMPLERS 0
+#endif
+
+/* Don't build any resamplers if you're REALLY saving code space. */
+#ifndef NO_RESAMPLERS
+#define NO_RESAMPLERS 0
+#endif
+
+/* Don't build any type converters if you're saving code space. */
+#ifndef NO_CONVERTERS
+#define NO_CONVERTERS 0
+#endif
+
+
 /* *INDENT-OFF* */
 
 EOF
@@ -290,6 +313,7 @@
 
 
 sub buildTypeConverters {
+    print "#if !NO_CONVERTERS\n\n";
     foreach (@audiotypes) {
         my $from = $_;
         foreach (@audiotypes) {
@@ -297,8 +321,10 @@
             buildCvtFunc($from, $to);
         }
     }
+    print "#endif  /* !NO_CONVERTERS */\n\n\n";
 
     print "const SDL_AudioTypeFilters sdl_audio_type_filters[] =\n{\n";
+    print "#if !NO_CONVERTERS\n";
     foreach (@audiotypes) {
         my $from = $_;
         foreach (@audiotypes) {
@@ -310,6 +336,7 @@
             }
         }
     }
+    print "#endif  /* !NO_CONVERTERS */\n";
 
     print "};\n\n\n";
 }
@@ -652,6 +679,17 @@
 }
 
 sub buildResamplers {
+    print "#if !NO_RESAMPLERS\n\n";
+    foreach (@audiotypes) {
+        my $from = $_;
+        foreach (@channels) {
+            my $channel = $_;
+            buildArbitraryResampleFunc($from, $channel, 1);
+            buildArbitraryResampleFunc($from, $channel, 0);
+        }
+    }
+
+    print "\n#if !LESS_RESAMPLERS\n\n";
     foreach (@audiotypes) {
         my $from = $_;
         foreach (@channels) {
@@ -660,17 +698,32 @@
                 buildMultipleResampleFunc($from, $channel, 1, $multiple);
                 buildMultipleResampleFunc($from, $channel, 0, $multiple);
             }
-            buildArbitraryResampleFunc($from, $channel, 1);
-            buildArbitraryResampleFunc($from, $channel, 0);
         }
     }
 
+    print "#endif  /* !LESS_RESAMPLERS */\n";
+    print "#endif  /* !NO_RESAMPLERS */\n\n\n";
+
     print "const SDL_AudioRateFilters sdl_audio_rate_filters[] =\n{\n";
+    print "#if !NO_RESAMPLERS\n";
     foreach (@audiotypes) {
         my $from = $_;
         foreach (@channels) {
             my $channel = $_;
-            for (my $multiple = 0; $multiple <= 4; $multiple += 2) {
+            for (my $upsample = 0; $upsample <= 1; $upsample++) {
+                my $hashid = getResamplerHashId($from, $channel, $upsample, 0);
+                my $sym = $funcs{$hashid};
+                print("    { AUDIO_$from, $channel, $upsample, 0, $sym },\n");
+            }
+        }
+    }
+
+    print "#if !LESS_RESAMPLERS\n";
+    foreach (@audiotypes) {
+        my $from = $_;
+        foreach (@channels) {
+            my $channel = $_;
+            for (my $multiple = 2; $multiple <= 4; $multiple += 2) {
                 for (my $upsample = 0; $upsample <= 1; $upsample++) {
                     my $hashid = getResamplerHashId($from, $channel, $upsample, $multiple);
                     my $sym = $funcs{$hashid};
@@ -680,6 +733,8 @@
         }
     }
 
+    print "#endif  /* !LESS_RESAMPLERS */\n";
+    print "#endif  /* !NO_RESAMPLERS */\n";
     print "};\n\n";
 }