aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-14 08:51:03 -0800
committerChris Robinson <[email protected]>2018-01-14 08:51:03 -0800
commit0152bc0d10901cc60e579e2f7fa6ebf7786e6106 (patch)
tree6b469cdb2eed1775f79b8ee4d1fc0539920f70f0
parent7e491ef2b2d58e90ce34eabea21056646aace089 (diff)
Remove the SAFE_CONST macro
Seems compilers are now allowing a pointer-to-type-array to implicitly convert to pointer-to-const-type-array.
-rw-r--r--Alc/ALu.c19
-rw-r--r--Alc/bformatdec.c12
-rw-r--r--Alc/mixer.c4
-rw-r--r--OpenAL32/Include/alMain.h42
4 files changed, 15 insertions, 62 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 2fe579b9..c010ecba 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1724,8 +1724,8 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
if(device->AmbiUp)
ambiup_process(device->AmbiUp,
- device->Dry.Buffer, device->Dry.NumChannels,
- SAFE_CONST(ALfloatBUFFERSIZE*,device->FOAOut.Buffer), SamplesToDo
+ device->Dry.Buffer, device->Dry.NumChannels, device->FOAOut.Buffer,
+ SamplesToDo
);
lidx = GetChannelIdxByName(&device->RealOut, FrontLeft);
@@ -1737,8 +1737,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
{
MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
device->Dry.Buffer[c], state->Offset, state->IrSize,
- SAFE_CONST(ALfloat2*,state->Chan[c].Coeffs),
- state->Chan[c].Values, SamplesToDo
+ state->Chan[c].Coeffs, state->Chan[c].Values, SamplesToDo
);
}
state->Offset += SamplesToDo;
@@ -1747,19 +1746,19 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
{
if(device->Dry.Buffer != device->FOAOut.Buffer)
bformatdec_upSample(device->AmbiDecoder,
- device->Dry.Buffer, SAFE_CONST(ALfloatBUFFERSIZE*,device->FOAOut.Buffer),
- device->FOAOut.NumChannels, SamplesToDo
+ device->Dry.Buffer, device->FOAOut.Buffer, device->FOAOut.NumChannels,
+ SamplesToDo
);
bformatdec_process(device->AmbiDecoder,
- device->RealOut.Buffer, device->RealOut.NumChannels,
- SAFE_CONST(ALfloatBUFFERSIZE*,device->Dry.Buffer), SamplesToDo
+ device->RealOut.Buffer, device->RealOut.NumChannels, device->Dry.Buffer,
+ SamplesToDo
);
}
else if(device->AmbiUp)
{
ambiup_process(device->AmbiUp,
- device->RealOut.Buffer, device->RealOut.NumChannels,
- SAFE_CONST(ALfloatBUFFERSIZE*,device->FOAOut.Buffer), SamplesToDo
+ device->RealOut.Buffer, device->RealOut.NumChannels, device->FOAOut.Buffer,
+ SamplesToDo
);
}
else if(device->Uhj_Encoder)
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index 2c5326d4..ae1f7381 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -433,12 +433,10 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU
memset(dec->ChannelMix, 0, SamplesToDo*sizeof(ALfloat));
MixMatrixRow(dec->ChannelMix, dec->Matrix.Dual[chan][FB_HighFreq],
- SAFE_CONST(ALfloatBUFFERSIZE*,dec->SamplesHF), dec->NumChannels, 0,
- SamplesToDo
+ dec->SamplesHF, dec->NumChannels, 0, SamplesToDo
);
MixMatrixRow(dec->ChannelMix, dec->Matrix.Dual[chan][FB_LowFreq],
- SAFE_CONST(ALfloatBUFFERSIZE*,dec->SamplesLF), dec->NumChannels, 0,
- SamplesToDo
+ dec->SamplesLF, dec->NumChannels, 0, SamplesToDo
);
for(i = 0;i < SamplesToDo;i++)
@@ -489,8 +487,7 @@ void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[B
/* Now write each band to the output. */
MixMatrixRow(OutBuffer[i], dec->UpSampler[i].Gains,
- SAFE_CONST(ALfloatBUFFERSIZE*,dec->Samples), FB_Max, 0,
- SamplesToDo
+ dec->Samples, FB_Max, 0, SamplesToDo
);
}
}
@@ -605,8 +602,7 @@ void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[
for(j = 0;j < OutChannels;j++)
MixMatrixRow(OutBuffer[j], ambiup->Gains[i][j],
- SAFE_CONST(ALfloatBUFFERSIZE*,ambiup->Samples), FB_Max, 0,
- SamplesToDo
+ ambiup->Samples, FB_Max, 0, SamplesToDo
);
}
}
diff --git a/Alc/mixer.c b/Alc/mixer.c
index b1d859c6..76e5f759 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -583,7 +583,7 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
*/
gain = lerp(parms->Hrtf.Old.Gain, parms->Hrtf.Target.Gain,
minf(1.0f, (ALfloat)fademix/Counter));
- hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Target.Coeffs);
+ hrtfparams.Coeffs = parms->Hrtf.Target.Coeffs;
hrtfparams.Delay[0] = parms->Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms->Hrtf.Target.Delay[1];
hrtfparams.Gain = 0.0f;
@@ -612,7 +612,7 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
gain = lerp(parms->Hrtf.Old.Gain, gain,
(ALfloat)todo/(Counter-fademix));
- hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Target.Coeffs);
+ hrtfparams.Coeffs = parms->Hrtf.Target.Coeffs;
hrtfparams.Delay[0] = parms->Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms->Hrtf.Target.Delay[1];
hrtfparams.Gain = parms->Hrtf.Old.Gain;
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index e4f5df74..10f9008a 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -146,48 +146,6 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
#ifdef __GNUC__
-/* Because of a long-standing deficiency in C, you're not allowed to implicitly
- * cast a pointer-to-type-array to a pointer-to-const-type-array. For example,
- *
- * int (*ptr)[10];
- * const int (*cptr)[10] = ptr;
- *
- * is not allowed and most compilers will generate noisy warnings about
- * incompatible types, even though it just makes the array elements const.
- * Clang will allow it if you make the array type a typedef, like this:
- *
- * typedef int int10[10];
- * int10 *ptr;
- * const int10 *cptr = ptr;
- *
- * however GCC does not and still issues the incompatible type warning. The
- * "proper" way to fix it is to add an explicit cast for the constified type,
- * but that removes the vast majority of otherwise useful type-checking you'd
- * get, and runs the risk of improper casts if types are later changed. Leaving
- * it non-const can also be an issue if you use it as a function parameter, and
- * happen to have a const type as input (and also reduce the capabilities of
- * the compiler to better optimize the function).
- *
- * So to work around the problem, we use a macro. The macro first assigns the
- * incoming variable to the specified non-const type to ensure it's the correct
- * type, then casts the variable as the desired constified type. Very ugly, but
- * I'd rather not have hundreds of lines of warnings because I want to tell the
- * compiler that some array(s) can't be changed by the code, or have lots of
- * error-prone casts.
- */
-#define SAFE_CONST(T, var) __extension__({ \
- T _tmp = (var); \
- (const T)_tmp; \
-})
-#else
-/* Non-GNU-compatible compilers have to use a straight cast with no extra
- * checks, due to the lack of multi-statement expressions.
- */
-#define SAFE_CONST(T, var) ((const T)(var))
-#endif
-
-
-#ifdef __GNUC__
#define LIKELY(x) __builtin_expect(!!(x), !0)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else