Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Allow builds that reduce or eliminate the converters/resamplers.
Browse files Browse the repository at this point in the history
We should probably give options to drop resamplers by channels, too, for
 developers that know they'll never need more than stereo, etc.
  • Loading branch information
icculus committed Jan 11, 2009
1 parent 4053aed commit bff95d7
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions src/audio/sdlgenaudiocvt.pl
Expand Up @@ -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
Expand Down Expand Up @@ -290,15 +313,18 @@ sub buildCvtFunc {


sub buildTypeConverters {
print "#if !NO_CONVERTERS\n\n";
foreach (@audiotypes) {
my $from = $_;
foreach (@audiotypes) {
my $to = $_;
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) {
Expand All @@ -310,6 +336,7 @@ sub buildTypeConverters {
}
}
}
print "#endif /* !NO_CONVERTERS */\n";

print "};\n\n\n";
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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};
Expand All @@ -680,6 +733,8 @@ sub buildResamplers {
}
}

print "#endif /* !LESS_RESAMPLERS */\n";
print "#endif /* !NO_RESAMPLERS */\n";
print "};\n\n";
}

Expand Down

0 comments on commit bff95d7

Please sign in to comment.