diff options
author | Chris Robinson <[email protected]> | 2008-10-09 01:17:39 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-10-09 01:17:39 -0700 |
commit | 8672008e43001d5522f8eeafba86ac347c143e7e (patch) | |
tree | 693598e5af48aa6ac4f8646f3c0aa594c5d1f872 | |
parent | c8cd1933469a280e113b23347d2f0e80ebd160c4 (diff) |
Skip mixing if the read position is beyond the end of the buffer
-rw-r--r-- | Alc/ALu.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -736,7 +736,13 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma Data = ALBuffer->data; Channels = aluChannelsFromFormat(ALBuffer->format); DataSize = ALBuffer->size; + DataSize /= Channels * aluBytesFromFormat(ALBuffer->format); Frequency = ALBuffer->frequency; + DataPosInt = ALSource->position; + DataPosFrac = ALSource->position_fraction; + + if(DataPosInt >= DataSize) + goto skipmix; CalcSourceParams(ALContext, ALSource, (Channels==1) ? AL_TRUE : AL_FALSE, @@ -744,11 +750,8 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma &DryGainHF, &WetGainHF); Pitch = (Pitch*Frequency) / ALContext->Frequency; - DataSize /= Channels * aluBytesFromFormat(ALBuffer->format); //Get source info - DataPosInt = ALSource->position; - DataPosFrac = ALSource->position_fraction; DryFilter = &ALSource->iirFilter; WetFilter = &ALSource->Send[0].iirFilter; DrySend = ALSource->DryGains; @@ -914,6 +917,8 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma //Update source info ALSource->position = DataPosInt; ALSource->position_fraction = DataPosFrac; + + skipmix: ; } //Handle looping sources |