aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c16
-rw-r--r--OpenAL32/Include/alu.h24
-rw-r--r--OpenAL32/alState.c18
3 files changed, 29 insertions, 29 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 19683653..f54b8e8e 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -952,15 +952,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
int fpuState;
ALuint i, c;
-#if defined(HAVE_FESETROUND)
- fpuState = fegetround();
- fesetround(FE_TOWARDZERO);
-#elif defined(HAVE__CONTROLFP)
- fpuState = _controlfp(0, 0);
- (void)_controlfp(_RC_CHOP, _MCW_RC);
-#else
- (void)fpuState;
-#endif
+ fpuState = SetMixerFPUMode();
while(size > 0)
{
@@ -1098,11 +1090,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
size -= SamplesToDo;
}
-#if defined(HAVE_FESETROUND)
- fesetround(fpuState);
-#elif defined(HAVE__CONTROLFP)
- _controlfp(fpuState, _MCW_RC);
-#endif
+ RestoreFPUMode(fpuState);
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index e8ac64fd..6c09d32f 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -195,6 +195,30 @@ static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat
return a0*mu*mu2 + a1*mu2 + a2*mu + a3;
}
+
+static __inline int SetMixerFPUMode(void)
+{
+ int fpuState = 0;
+#if defined(HAVE_FESETROUND)
+ fpuState = fegetround();
+ fesetround(FE_TOWARDZERO);
+#elif defined(HAVE__CONTROLFP)
+ fpuState = _controlfp(0, 0);
+ (void)_controlfp(_RC_CHOP, _MCW_RC);
+#endif
+ return fpuState;
+}
+
+static __inline void RestoreFPUMode(int state)
+{
+#if defined(HAVE_FESETROUND)
+ fesetround(state);
+#elif defined(HAVE__CONTROLFP)
+ _controlfp(state, _MCW_RC);
+#endif
+}
+
+
ALvoid aluInitPanning(ALCdevice *Device);
ALint aluCart2LUTpos(ALfloat re, ALfloat im);
diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c
index 1cb52689..c50df9e6 100644
--- a/OpenAL32/alState.c
+++ b/OpenAL32/alState.c
@@ -587,17 +587,9 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
ALeffectslot **slot, **slot_end;
int fpuState;
- LockContext(Context);
-#if defined(HAVE_FESETROUND)
- fpuState = fegetround();
- fesetround(FE_TOWARDZERO);
-#elif defined(HAVE__CONTROLFP)
- fpuState = _controlfp(0, 0);
- (void)_controlfp(_RC_CHOP, _MCW_RC);
-#else
- (void)fpuState;
-#endif
+ fpuState = SetMixerFPUMode();
+ LockContext(Context);
Context->DeferUpdates = AL_TRUE;
/* Make sure all pending updates are performed */
@@ -630,11 +622,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
}
UnlockContext(Context);
-#if defined(HAVE_FESETROUND)
- fesetround(fpuState);
-#elif defined(HAVE__CONTROLFP)
- _controlfp(fpuState, _MCW_RC);
-#endif
+ RestoreFPUMode(fpuState);
}
ALCcontext_DecRef(Context);