Clear the echo and delay lines even if the buffer doesn't change size

This commit is contained in:
Chris Robinson
2009-10-21 02:03:33 -07:00
parent 75b65ab2a2
commit d3ecbd75af
2 changed files with 6 additions and 7 deletions
+3 -4
View File
@@ -88,7 +88,7 @@ ALvoid EchoDestroy(ALeffectState *effect)
ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
{
ALechoState *state = (ALechoState*)effect;
ALuint maxlen;
ALuint maxlen, i;
// Use the next power of 2 for the buffer length, so the tap offsets can be
// wrapped using a mask instead of a modulo
@@ -99,7 +99,6 @@ ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
if(maxlen != state->BufferLength)
{
void *temp;
ALuint i;
temp = realloc(state->SampleBuffer, maxlen * sizeof(ALfloat));
if(!temp)
@@ -108,9 +107,9 @@ ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
return AL_FALSE;
}
state->BufferLength = maxlen;
for(i = 0;i < state->BufferLength;i++)
state->SampleBuffer[i] = 0.0f;
}
for(i = 0;i < state->BufferLength;i++)
state->SampleBuffer[i] = 0.0f;
return AL_TRUE;
}
+3 -3
View File
@@ -431,9 +431,6 @@ ALboolean VerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
State->TotalLength = totalLength;
State->SampleBuffer = temp;
for(index = 0; index < totalLength;index++)
State->SampleBuffer[index] = 0.0f;
// All lines share a single sample buffer
State->Delay.Mask = length[0] - 1;
State->Delay.Line = &State->SampleBuffer[0];
@@ -466,6 +463,9 @@ ALboolean VerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
Device->Frequency);
}
for(index = 0;index < State->TotalLength;index++)
State->SampleBuffer[index] = 0.0f;
return AL_TRUE;
}