change destroyOnFinish behavior to use OnBufferEnd
parent
6edd9ebc94
commit
3568028dc3
|
@ -332,11 +332,14 @@ static inline FAudioGMS_EffectChain *FAudioGMS_INTERNAL_LookupEffectChain(uint32
|
||||||
static void FAudioGMS_INTERNAL_SoundInstance_AddBuffer(FAudioGMS_SoundInstance *instance);
|
static void FAudioGMS_INTERNAL_SoundInstance_AddBuffer(FAudioGMS_SoundInstance *instance);
|
||||||
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance);
|
static void FAudioGMS_INTERNAL_SoundInstance_Play(FAudioGMS_SoundInstance *instance);
|
||||||
static void FAudioGMS_INTERNAL_SoundInstance_Stop(FAudioGMS_SoundInstance *instance);
|
static void FAudioGMS_INTERNAL_SoundInstance_Stop(FAudioGMS_SoundInstance *instance);
|
||||||
|
static void FAudioGMS_INTERNAL_SoundInstance_Destroy(FAudioGMS_SoundInstance *instance);
|
||||||
|
|
||||||
static void FAudioGMS_INTERNAL_OnBufferEndCallback(
|
static void FAudioGMS_INTERNAL_OnBufferEndCallback(
|
||||||
FAudioVoiceCallback *callback,
|
FAudioVoiceCallback *callback,
|
||||||
FAudioGMS_SoundInstance *instance)
|
FAudioGMS_SoundInstance *instance)
|
||||||
{
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
if (instance->isStatic)
|
if (instance->isStatic)
|
||||||
{
|
{
|
||||||
FAudioGMS_INTERNAL_SoundInstance_Stop(instance);
|
FAudioGMS_INTERNAL_SoundInstance_Stop(instance);
|
||||||
|
@ -360,6 +363,27 @@ static void FAudioGMS_INTERNAL_OnBufferEndCallback(
|
||||||
FAudioGMS_INTERNAL_SoundInstance_Play(instance->queuedSoundInstance);
|
FAudioGMS_INTERNAL_SoundInstance_Play(instance->queuedSoundInstance);
|
||||||
instance->queuedSoundInstance = NULL;
|
instance->queuedSoundInstance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (instance->destroyOnFinish)
|
||||||
|
{
|
||||||
|
/* this is a callback so we don't want to immediately destroy and screw up data */
|
||||||
|
instance->destroyTimerActive = 1;
|
||||||
|
instance->destroyTimer = 0;
|
||||||
|
|
||||||
|
if (instance->voice.effectChainAttached)
|
||||||
|
{
|
||||||
|
/* If we have active reverb we don't want to clean up until the decay time is over
|
||||||
|
*/
|
||||||
|
for (i = 0; i < instance->voice.effectChain->effectCount; i += 1)
|
||||||
|
{
|
||||||
|
if (instance->voice.effectChain->effectTypes[i] == EffectType_Reverb)
|
||||||
|
{
|
||||||
|
instance->destroyTimer += instance->voice.effectChain->effectParameters[i]
|
||||||
|
.reverbParameters.DecayTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,7 +731,7 @@ static FAudioGMS_SoundInstance *FAudioGMS_INTERNAL_SoundInstance_Init(
|
||||||
&instance->format,
|
&instance->format,
|
||||||
FAUDIO_VOICE_USEFILTER,
|
FAUDIO_VOICE_USEFILTER,
|
||||||
FAUDIO_DEFAULT_FREQ_RATIO,
|
FAUDIO_DEFAULT_FREQ_RATIO,
|
||||||
isStatic ? NULL : &device->voiceCallbacks,
|
&device->voiceCallbacks,
|
||||||
&instance->voice.sends,
|
&instance->voice.sends,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -2025,43 +2049,13 @@ void FAudioGMS_Update()
|
||||||
FAudioGMS_INTERNAL_SoundInstance_SetVolume(instance, volume);
|
FAudioGMS_INTERNAL_SoundInstance_SetVolume(instance, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance->destroyOnFinish)
|
if (instance->destroyTimerActive)
|
||||||
{
|
{
|
||||||
FAudioVoiceState state;
|
instance->destroyTimer -= device->timestep;
|
||||||
FAudioSourceVoice_GetState(
|
|
||||||
instance->voice.handle,
|
|
||||||
&state,
|
|
||||||
FAUDIO_VOICE_NOSAMPLESPLAYED);
|
|
||||||
|
|
||||||
if (instance->destroyTimerActive)
|
if (instance->destroyTimer <= 0)
|
||||||
{
|
{
|
||||||
instance->destroyTimer -= device->timestep;
|
FAudioGMS_INTERNAL_SoundInstance_Destroy(instance);
|
||||||
|
|
||||||
if (instance->destroyTimer <= 0)
|
|
||||||
{
|
|
||||||
FAudioGMS_INTERNAL_SoundInstance_Destroy(instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (state.BuffersQueued == 0)
|
|
||||||
{
|
|
||||||
if (instance->voice.effectChainAttached)
|
|
||||||
{
|
|
||||||
/* If we have active reverb we don't want to clean up until the decay time is over */
|
|
||||||
for (j = 0; j < instance->voice.effectChain->effectCount; j += 1)
|
|
||||||
{
|
|
||||||
if (instance->voice.effectChain->effectTypes[j] == EffectType_Reverb)
|
|
||||||
{
|
|
||||||
instance->destroyTimerActive = 1;
|
|
||||||
instance->destroyTimer +=
|
|
||||||
instance->voice.effectChain->effectParameters[j]
|
|
||||||
.reverbParameters.DecayTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FAudioGMS_INTERNAL_SoundInstance_Destroy(instance);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue