Vixen
02b45cc4
csharp
public readonly record struct VoiceHandle

A reference to a playing sound that cannot be confused with a later one.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Index plus generation, because a bare index is a use-after-free waiting to happen: a footstep finishes, its slot is reused by an explosion, and the stale handle the footstep code kept now stops the explosion. Every call checks the generation and a stale handle does nothing at all — which is what a caller wants, because "the sound I was holding has already finished" is the normal case rather than an error.

Eight bytes, so it can live in a component, be compared, and be copied without a thought.

Fields and properties (4)

  • public int Index

    Which slot in the pool.

  • public int Generation

    Which use of that slot.

  • public static VoiceHandle None

    The handle that refers to nothing.

  • public bool IsValid

    Whether it refers to a slot at all. Says nothing about whether that slot is still this sound.

Methods (1)

  • public VoiceHandle(int Index, int Generation)

    A reference to a playing sound that cannot be confused with a later one.

Used by (29)

  • PeerVoiceChat
  • AudioEngineVixen.Audio
  • AudioEventVixen.Audio
  • AudioEventSystemTestsVixen.Audio.Tests
  • AudioEventTestsVixen.Audio.Tests
  • AudioMixerTestsVixen.Audio.Tests
  • AudioRoutingTestsVixen.Audio.Tests
  • AudioScattererVixen.Audio
  • AudioSourceVixen.Audio
  • AudioSystemVixen.Audio
  • AudioSystemTestsVixen.Audio.Tests
  • BuiltinParameterTestsVixen.Audio.Tests
  • CaptureTestsVixen.Audio.Tests
  • FadeTestsVixen.Audio.Tests
  • LayeredEventTestsVixen.Audio.Tests
  • LiveSampleProviderTestsVixen.Audio.Tests
  • MusicPlayerVixen.Audio
  • MusicPlayerTestsVixen.Audio.Tests
  • OcclusionTestsVixen.Audio.Tests
  • OpenALBackendTestsVixen.Audio.Backend.OpenAL.Tests
  • PerVoiceSendTestsVixen.Audio.Tests
  • ResamplerTestsVixen.Audio.Tests
  • ScattererTestsVixen.Audio.Tests
  • StreamingTestsVixen.Audio.Tests
  • TypeRegistrationVixen.Audio
  • VirtualVoiceTestsVixen.Audio.Tests
  • Vixen_Audio_Ecs_AudioSourceSerializerVixen.Audio
  • VoiceParameterTestsVixen.Audio.Tests
  • VoiceStealingTestsVixen.Audio.Tests