AudioSystem Class
Definition¶
Namespace: Brine2D.Systems.Audio
System that processes audio components with 2D spatial audio support. Tracks component state to properly stop sounds when disabled.
public sealed class AudioSystem : Brine2D.ECS.Systems.UpdateSystemBase, System.IDisposable
Inheritance System.Object → UpdateSystemBase → AudioSystem
Implements System.IDisposable
Remarks¶
Brine2D.Systems.Audio.AudioSystem.Update(Brine2D.ECS.IEntityWorld,Brine2D.Core.GameTime) must be called from a single thread (the game thread). All state (Brine2D.Systems.Audio.AudioSystem._entityTracks, Brine2D.Systems.Audio.AudioSystem._trackEntities, Brine2D.Systems.Audio.AudioSystem._previousEnabledState) is accessed exclusively during Update.
Sound-effect tracks are tracked via Brine2D.Systems.Audio.AudioSystem._entityTracks/Brine2D.Systems.Audio.AudioSystem._trackEntities and cleaned up by polling Brine2D.Audio.IAudioPlayer.IsTrackAlive(System.IntPtr) each frame. A single entity can have multiple concurrent tracks (overlapping sounds). SoundEffectSourceComponent.IsPlaying remains true until the last track completes. Music tracks are not stored here because only one plays at a time — completion is detected by polling IsMusicPlaying in Brine2D.Systems.Audio.AudioSystem.SyncMusicEntityState.
| Methods | |
|---|---|
| PruneDestroyedEntities() | Removes tracking state for entities no longer returned by the audio source query (entity destroyed or component removed). Uses the set of entities visited during the current frame rather than per-entity GetComponent lookups. |
| SyncBusPauseState() | Detects per-bus pause transitions and syncs SoundEffectSourceComponent.IsPaused on tracked sound-effect entities. When a bus is unpaused, individually paused tracks are re-paused at the native layer since ResumeBus(string) resumes every tagged track. |