[SDL] Patch: SDL.vcproj

Hiroyuki Iwatsuki don at na.rim.or.jp
Sun Nov 12 23:47:22 PST 2006


Hi,

On 11/13/06, andreas <anpa502 at telia.com> wrote:
> > I used "/ 2" instead of ">> 1".
> >
> Very nice!

Thank you :-)

> I have found that there exist a shift in "SDL_stdlib.c" named "_aullshr", but I am not sure this one is the one intended as "replacement" for the standard library helper routines.

Perhaps, the functions in SDL_stdlib.c is used for MSVC.
In addition to them, I want to _allshr function if it is possible.


> Normally one would use math.h's HUGE_VAL-macro, but then we're in for standard libraries again.
> I don't know which value is correct, but changing it to 3.40282346e+38F makes it compile.

I used FLOAT_MIN and FLOAT_MAX.
However, float.h is necessary.

In MSVC++ 2005 EE's float.h,
FLOAT_MAX macro is defined 3.402823466e+38F.
FLOAT_MIN macro is defined 1.175494351e-38F.

To our regret, I don't know whether it is correct to use these.

Thanks,
-- 
IWATSUKI Hiroyuki <URL:mailto:don at na.rim.or.jp>
-------------- next part --------------
Index: src/audio/SDL_mixer.c
===================================================================
--- src/audio/SDL_mixer.c	(revision 2909)
+++ src/audio/SDL_mixer.c	(working copy)
@@ -302,9 +302,6 @@
             float *dst32 = (float *) dst;
             float src1, src2;
             double dst_sample;
-            /* !!! FIXME: are these right? */
-            const double max_audioval = 3.40282347e+38F;
-            const double min_audioval = -3.40282347e+38F;
 
             len /= 4;
             while (len--) {
@@ -313,10 +310,10 @@
                 src32++;
 
                 dst_sample = ((double) src1) + ((double) src2);
-                if (dst_sample > max_audioval) {
-                    dst_sample = max_audioval;
-                } else if (dst_sample < min_audioval) {
-                    dst_sample = min_audioval;
+                if (dst_sample > FLT_MAX) {
+                    dst_sample = FLT_MAX;
+                } else if (dst_sample < FLT_MIN) {
+                    dst_sample = FLT_MIN;
                 }
                 *(dst32++) = SDL_SwapFloatLE((float) dst_sample);
             }
@@ -331,9 +328,6 @@
             float *dst32 = (float *) dst;
             float src1, src2;
             double dst_sample;
-            /* !!! FIXME: are these right? */
-            const double max_audioval = 3.40282347e+38F;
-            const double min_audioval = -3.40282347e+38F;
 
             len /= 4;
             while (len--) {
@@ -342,10 +336,10 @@
                 src32++;
 
                 dst_sample = ((double) src1) + ((double) src2);
-                if (dst_sample > max_audioval) {
-                    dst_sample = max_audioval;
-                } else if (dst_sample < min_audioval) {
-                    dst_sample = min_audioval;
+                if (dst_sample > FLT_MAX) {
+                    dst_sample = FLT_MAX;
+                } else if (dst_sample < FLT_MIN) {
+                    dst_sample = FLT_MIN;
                 }
                 *(dst32++) = SDL_SwapFloatBE((float) dst_sample);
             }


More information about the SDL mailing list