diff options
-rw-r--r-- | Alc/ALu.c | 12 | ||||
-rw-r--r-- | Alc/mixer.c | 10 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 2 |
3 files changed, 14 insertions, 10 deletions
@@ -34,12 +34,16 @@ #include "alu.h" #include "bs2b.h" #include "hrtf.h" +#include "static_assert.h" #include "mixer_defs.h" #include "midi/base.h" +static_assert((INT_MAX>>FRACTIONBITS)/MAX_PITCH > BUFFERSIZE, + "MAX_PITCH and/or BUFFERSIZE are too large for FRACTIONBITS!"); + struct ChanMap { enum Channel channel; ALfloat angle; @@ -330,8 +334,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) if((ALBuffer=BufferListItem->buffer) != NULL) { Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > 10.0f) - src->Step = 10<<FRACTIONBITS; + if(Pitch > (ALfloat)MAX_PITCH) + src->Step = MAX_PITCH<<FRACTIONBITS; else { src->Step = fastf2i(Pitch*FRACTIONONE); @@ -955,8 +959,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) /* Calculate fixed-point stepping value, based on the pitch, buffer * frequency, and output frequency. */ Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > 10.0f) - src->Step = 10<<FRACTIONBITS; + if(Pitch > (ALfloat)MAX_PITCH) + src->Step = MAX_PITCH<<FRACTIONBITS; else { src->Step = fastf2i(Pitch*FRACTIONONE); diff --git a/Alc/mixer.c b/Alc/mixer.c index ef1517b3..8830a3fe 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -383,12 +383,10 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) } } /* Update positions */ - for(j = 0;j < DstBufferSize;j++) - { - DataPosFrac += increment; - DataPosInt += DataPosFrac>>FRACTIONBITS; - DataPosFrac &= FRACTIONMASK; - } + DataPosFrac += increment*DstBufferSize; + DataPosInt += DataPosFrac>>FRACTIONBITS; + DataPosFrac &= FRACTIONMASK; + OutPos += DstBufferSize; src->Offset += DstBufferSize; src->Direct.Counter = maxu(src->Direct.Counter, DstBufferSize) - DstBufferSize; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 98663c7d..c4b4d674 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -34,6 +34,8 @@ #define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS) #define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1) +#define MAX_PITCH (10) + #ifdef __cplusplus extern "C" { |