aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c10
-rw-r--r--Alc/ALu.c7
-rw-r--r--Alc/converter.c10
-rw-r--r--OpenAL32/Include/alMain.h11
-rw-r--r--OpenAL32/alAuxEffectSlot.c7
5 files changed, 24 insertions, 21 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 107d4ef2..e4b57c45 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1741,7 +1741,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
ALCsizei hrtf_id = -1;
ALCcontext *context;
ALCuint oldFreq;
- FPUCtl oldMode;
size_t size;
ALCsizei i;
int val;
@@ -2244,7 +2243,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
* allocated with the appropriate size.
*/
update_failed = AL_FALSE;
- SetMixerFPUMode(&oldMode);
+ START_MIXER_MODE();
context = ATOMIC_LOAD_SEQ(&device->ContextList);
while(context)
{
@@ -2359,7 +2358,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
context = context->next;
}
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
if(update_failed)
return ALC_INVALID_DEVICE;
@@ -3662,11 +3661,10 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
if(ALContext->DefaultSlot)
{
- FPUCtl oldMode;
ALeffectslot *slot = ALContext->DefaultSlot;
ALeffectState *state = slot->Effect.State;
- SetMixerFPUMode(&oldMode);
+ START_MIXER_MODE();
state->OutBuffer = device->Dry.Buffer;
state->OutChannels = device->Dry.NumChannels;
if(V(state,deviceUpdate)(device) != AL_FALSE)
@@ -3676,7 +3674,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
DeinitEffectSlot(ALContext->DefaultSlot);
ALContext->DefaultSlot = NULL;
}
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
}
ALCdevice_IncRef(ALContext->Device);
diff --git a/Alc/ALu.c b/Alc/ALu.c
index e44c6c2c..25626320 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1611,11 +1611,9 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
{
ALsizei SamplesToDo;
ALCcontext *ctx;
- FPUCtl oldMode;
ALsizei i, c;
- SetMixerFPUMode(&oldMode);
-
+ START_MIXER_MODE();
while(size > 0)
{
SamplesToDo = mini(size, BUFFERSIZE);
@@ -1819,8 +1817,7 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
size -= SamplesToDo;
}
-
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
}
diff --git a/Alc/converter.c b/Alc/converter.c
index d9d8ecbf..5cfe7031 100644
--- a/Alc/converter.c
+++ b/Alc/converter.c
@@ -9,7 +9,6 @@
SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType dstType, ALsizei numchans, ALsizei srcRate, ALsizei dstRate)
{
SampleConverter *converter;
- FPUCtl oldMode;
ALsizei step;
if(numchans <= 0 || srcRate <= 0 || dstRate <= 0)
@@ -26,7 +25,7 @@ SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType
converter->mFracOffset = 0;
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
- SetMixerFPUMode(&oldMode);
+ START_MIXER_MODE();
step = fastf2i(minf((ALdouble)srcRate / dstRate, MAX_PITCH)*FRACTIONONE + 0.5f);
converter->mIncrement = maxi(step, 1);
if(converter->mIncrement == FRACTIONONE)
@@ -37,7 +36,7 @@ SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType
BsincPrepare(converter->mIncrement, &converter->mState.bsinc);
converter->mResample = SelectResampler(BSincResampler);
}
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
return converter;
}
@@ -230,9 +229,8 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs
const ALsizei DstFrameSize = converter->mNumChannels * converter->mDstTypeSize;
const ALsizei increment = converter->mIncrement;
ALsizei pos = 0;
- FPUCtl oldMode;
- SetMixerFPUMode(&oldMode);
+ START_MIXER_MODE();
while(pos < dstframes && *srcframes > 0)
{
ALfloat *restrict SrcData = ASSUME_ALIGNED(converter->mSrcSamples, 16);
@@ -344,7 +342,7 @@ ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALs
dst = (ALbyte*)dst + DstFrameSize*DstSize;
pos += DstSize;
}
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
return pos;
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 4081508e..ca97bff0 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -907,6 +907,17 @@ typedef struct {
} FPUCtl;
void SetMixerFPUMode(FPUCtl *ctl);
void RestoreFPUMode(const FPUCtl *ctl);
+#ifdef __GNUC__
+/* Use an alternate macro set with GCC to avoid accidental continue or break
+ * statements within the mixer mode.
+ */
+#define START_MIXER_MODE() __extension__({ FPUCtl _oldMode; SetMixerFPUMode(&_oldMode);
+#define END_MIXER_MODE() RestoreFPUMode(&_oldMode); })
+#else
+#define START_MIXER_MODE() do { FPUCtl _oldMode; SetMixerFPUMode(&_oldMode);
+#define END_MIXER_MODE() RestoreFPUMode(&_oldMode); } while(0)
+#endif
+#define LEAVE_MIXER_MODE() RestoreFPUMode(&_oldMode)
typedef struct ll_ringbuffer ll_ringbuffer_t;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index cd2c1e09..02288a31 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -506,7 +506,6 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
if(newtype != EffectSlot->Effect.Type)
{
ALeffectStateFactory *factory;
- FPUCtl oldMode;
factory = getFactoryByType(newtype);
if(!factory)
@@ -517,19 +516,19 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
State = V0(factory,create)();
if(!State) return AL_OUT_OF_MEMORY;
- SetMixerFPUMode(&oldMode);
+ START_MIXER_MODE();
almtx_lock(&Device->BackendLock);
State->OutBuffer = Device->Dry.Buffer;
State->OutChannels = Device->Dry.NumChannels;
if(V(State,deviceUpdate)(Device) == AL_FALSE)
{
almtx_unlock(&Device->BackendLock);
- RestoreFPUMode(&oldMode);
+ LEAVE_MIXER_MODE();
ALeffectState_DecRef(State);
return AL_OUT_OF_MEMORY;
}
almtx_unlock(&Device->BackendLock);
- RestoreFPUMode(&oldMode);
+ END_MIXER_MODE();
if(!effect)
{