diff options
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 6 | ||||
-rw-r--r-- | OpenAL32/sample_cvt.c | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 04514b5e..3d1f062a 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -314,6 +314,12 @@ typedef ptrdiff_t ALsizeiptrEXT; #define FORCE_ALIGN #endif +#ifdef HAVE_C99_VLA +#define DECL_VLA(T, _name, _size) T _name[(_size)] +#else +#define DECL_VLA(T, _name, _size) T *_name = alloca((_size) * sizeof(T)) +#endif + #ifndef PATH_MAX #ifdef MAX_PATH #define PATH_MAX MAX_PATH diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c index a4c59d9d..903ec8ca 100644 --- a/OpenAL32/sample_cvt.c +++ b/OpenAL32/sample_cvt.c @@ -917,10 +917,9 @@ static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \ ALuint len, ALuint align) \ { \ ALsizei byte_align = ((align-1)/2 + 4) * numchans; \ + DECL_VLA(ALshort, tmp, align*numchans); \ ALuint i, j, k; \ - ALshort *tmp; \ \ - tmp = alloca(align*numchans*sizeof(*tmp)); \ for(i = 0;i < len;i += align) \ { \ DecodeIMA4Block(tmp, src, numchans, align); \ @@ -968,10 +967,9 @@ static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \ ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \ ALint index[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \ ALsizei byte_align = ((align-1)/2 + 4) * numchans; \ + DECL_VLA(ALshort, tmp, align*numchans); \ ALuint i, j, k; \ - ALshort *tmp; \ \ - tmp = alloca(align*numchans*sizeof(*tmp)); \ for(i = 0;i < len;i += align) \ { \ for(j = 0;j < align;j++) \ @@ -1020,10 +1018,9 @@ static void Convert_##T##_ALmsadpcm(T *dst, const ALmsadpcm *src, \ ALuint align) \ { \ ALsizei byte_align = ((align-2)/2 + 7) * numchans; \ + DECL_VLA(ALshort, tmp, align*numchans); \ ALuint i, j, k; \ - ALshort *tmp; \ \ - tmp = alloca(align*numchans*sizeof(*tmp)); \ for(i = 0;i < len;i += align) \ { \ DecodeMSADPCMBlock(tmp, src, numchans, align); \ @@ -1071,10 +1068,9 @@ static void Convert_ALmsadpcm_##T(ALmsadpcm *dst, const T *src, \ { \ ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \ ALsizei byte_align = ((align-2)/2 + 7) * numchans; \ + DECL_VLA(ALshort, tmp, align*numchans); \ ALuint i, j, k; \ - ALshort *tmp; \ \ - tmp = alloca(align*numchans*sizeof(*tmp)); \ for(i = 0;i < len;i += align) \ { \ for(j = 0;j < align;j++) \ |