Allow effect slots to be updated asynchronously

Updates when the slot changes effect type is still sychronous, however, to
ensure a proper state for the Process method call. Fixing this would
essentially require all effects to work from the same state.
This commit is contained in:
Chris Robinson
2011-07-16 02:41:02 -07:00
parent 54b5f35125
commit da2429a1d0
4 changed files with 29 additions and 6 deletions
+3 -2
View File
@@ -1414,6 +1414,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
ALCcontext *context = device->Contexts[i];
ALsizei pos;
context->UpdateSources = AL_FALSE;
for(pos = 0;pos < context->EffectSlotMap.size;pos++)
{
ALeffectslot *slot = context->EffectSlotMap.array[pos].value;
@@ -1425,6 +1426,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Flags &= ~DEVICE_RUNNING;
return ALC_FALSE;
}
slot->NeedsUpdate = AL_FALSE;
ALEffect_Update(slot->EffectState, context, &slot->effect);
}
@@ -1441,10 +1443,9 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
source->Send[s].WetFilter.filter = 0;
s++;
}
ALsource_Update(source, context);
source->NeedsUpdate = AL_FALSE;
ALsource_Update(source, context);
}
context->UpdateSources = AL_FALSE;
}
UnlockDevice(device);
+6
View File
@@ -1031,6 +1031,12 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
ALEffectSlot->PendingClicks[i] = 0.0f;
}
if(ALEffectSlot->NeedsUpdate)
{
ALEffectSlot->NeedsUpdate = AL_FALSE;
ALEffect_Update(ALEffectSlot->EffectState, *ctx, &ALEffectSlot->effect);
}
ALEffect_Process(ALEffectSlot->EffectState, ALEffectSlot,
SamplesToDo, ALEffectSlot->WetBuffer,
device->DryBuffer);
+1
View File
@@ -18,6 +18,7 @@ typedef struct ALeffectslot
ALfloat Gain;
ALboolean AuxSendAuto;
ALboolean NeedsUpdate;
ALeffectState *EffectState;
ALfloat WetBuffer[BUFFERSIZE];
+19 -4
View File
@@ -86,6 +86,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
slot->Gain = 1.0;
slot->AuxSendAuto = AL_TRUE;
slot->NeedsUpdate = AL_FALSE;
for(j = 0;j < BUFFERSIZE;j++)
slot->WetBuffer[j] = 0.0f;
for(j = 0;j < 1;j++)
@@ -495,12 +496,26 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
if(EffectSlot->EffectState)
ALEffect_Destroy(EffectSlot->EffectState);
EffectSlot->EffectState = NewState;
if(!effect)
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
else
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
/* FIXME: This should be done asychronously, but since the EfefctState
* object was changed, it needs an update before its Process method can
* be called (coming changes may not guarantee an update when the
* NeedsUpdate flag is set). */
EffectSlot->NeedsUpdate = AL_FALSE;
ALEffect_Update(EffectSlot->EffectState, Context, &EffectSlot->effect);
}
if(!effect)
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
else
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
ALEffect_Update(EffectSlot->EffectState, Context, &EffectSlot->effect);
{
if(!effect)
memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect));
else
memcpy(&EffectSlot->effect, effect, sizeof(*effect));
EffectSlot->NeedsUpdate = AL_TRUE;
}
}