From ef59901e7c5b8813214fde6ee090d835c67277fd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 8 Aug 2008 07:32:21 -0700 Subject: Set FPU mode to round toward zero for mixing --- Alc/ALu.c | 17 +++++++++++++++++ CMakeLists.txt | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 404dea66..4454b8d4 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -650,9 +650,20 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma ALuint loop; ALint64 DataSize64,DataPos64; FILTER *Filter; + int fpuState; SuspendContext(ALContext); +#if defined(HAVE_FESETROUND) + fpuState = fegetround(); + fesetround(FE_TOWARDZERO); +#elif defined(HAVE__CONTROLFP) + fpuState = _controlfp(0, 0); + _controlfp(_RC_CHOP, _MCW_RC); +#else + (void)fpuState; +#endif + //Figure output format variables BlockAlign = aluChannelsFromFormat(format); BlockAlign *= aluBytesFromFormat(format); @@ -1206,5 +1217,11 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma size -= SamplesToDo; } +#if defined(HAVE_FESETROUND) + fesetround(fpuState); +#elif defined(HAVE__CONTROLFP) + _controlfp(fpuState, 0xfffff); +#endif + ProcessContext(ALContext); } diff --git a/CMakeLists.txt b/CMakeLists.txt index 870edb0b..4ed1f898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,10 +112,12 @@ ENDIF() CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF) CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF) -IF(HAVE_SQRTF OR HAVE_ACOSF) +CHECK_LIBRARY_EXISTS(m fesetround "" HAVE_FESETROUND) +IF(HAVE_SQRTF OR HAVE_ACOSF OR HAVE_FESETROUND) SET(EXTRA_LIBS m ${EXTRA_LIBS}) ENDIF() CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF) +CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP) CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP) IF(NOT HAVE_STRCASECMP) -- cgit v1.2.3