From bff95d72a390ccb010ee6e79f18efc4d4c2d9269 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 11 Jan 2009 04:39:09 +0000 Subject: [PATCH] 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. --- src/audio/sdlgenaudiocvt.pl | 61 +++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/audio/sdlgenaudiocvt.pl b/src/audio/sdlgenaudiocvt.pl index 7af86f9a6..76053ec50 100755 --- a/src/audio/sdlgenaudiocvt.pl +++ b/src/audio/sdlgenaudiocvt.pl @@ -62,6 +62,29 @@ sub outputHeader { #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 buildCvtFunc { sub buildTypeConverters { + print "#if !NO_CONVERTERS\n\n"; foreach (@audiotypes) { my $from = $_; foreach (@audiotypes) { @@ -297,8 +321,10 @@ sub buildTypeConverters { 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 @@ sub buildTypeConverters { } } } + print "#endif /* !NO_CONVERTERS */\n"; print "};\n\n\n"; } @@ -652,6 +679,17 @@ sub buildMultipleResampleFunc { } 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 @@ sub buildResamplers { 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 $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 = 0; $multiple <= 4; $multiple += 2) { + 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 @@ sub buildResamplers { } } + print "#endif /* !LESS_RESAMPLERS */\n"; + print "#endif /* !NO_RESAMPLERS */\n"; print "};\n\n"; }