Skip to content

Commit

Permalink
Fix VoiceHandler memory access out of bounds on WebGL (#324)
Browse files Browse the repository at this point in the history
## Description

This should fix issue #323, where for some AudioClip lengths the
GetAmplitude method tried to read data from the clip even if the
remaining samples were 0.

## How to Test

- add VoiceHandler component on an avatar
- set build target to webGL and run the built application
- let the AudioSource referenced by the VoiceHandler reproduce
AudioClips with various lengths

## Checklist

- [ ] Tests written or updated for the changes.
- [ ] Documentation is updated.
- [ ] Changelog is updated.
  • Loading branch information
mennetorelli authored Dec 6, 2024
1 parent 7aabadf commit 6117328
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Runtime/Core/Scripts/Animation/VoiceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private float GetAmplitude()
{
var currentPosition = AudioSource.timeSamples;
var remaining = AudioSource.clip.samples - currentPosition;
if (remaining > 0 && remaining < AUDIO_SAMPLE_LENGTH)
if (remaining >= 0 && remaining < AUDIO_SAMPLE_LENGTH)
{
return 0f;
}
Expand Down

0 comments on commit 6117328

Please sign in to comment.