PlatformAPI reference
Class SdlAudioDevice
Namespace: MicroEngine.Sdl
Assembly: MicroEngine.Sdl.dll
Guide: Backends and platforms
SDL3 audio: the engine’s mixer (MixerAudioDevice, the same voices, priorities and music on every backend) playing through SDL’s default playback device. A feeder thread keeps DefaultLatencyMilliseconds of audio queued in an SDL audio stream (48 kHz stereo float), so main-thread stalls and garbage collections shorter than that are not heard. It works without a window, so a host can use it with another platform. In a browser SDL’s own audio is not used: the mixer plays through the page’s AudioWorklet queue, filled once per frame (BrowserAudioSink).
public sealed class SdlAudioDevice : MixerAudioDevice, IAudioDevice, IDisposableInheritance
object ← MixerAudioDevice ← SdlAudioDevice
Implements
Inherited Members
MixerAudioDevice.LoadSound(string, AudioClip), MixerAudioDevice.LoadMusic(string, AudioClip, bool), MixerAudioDevice.LoadMusicStream(string, byte[], string, bool), MixerAudioDevice.Play(SoundHandle, float, float, float), MixerAudioDevice.PlayMusic(MusicHandle, float), MixerAudioDevice.StopMusic(), MixerAudioDevice.SetMusicVolume(float), MixerAudioDevice.PauseMusic(bool), MixerAudioDevice.Update(), MixerAudioDevice.Pump(), MixerAudioDevice.Dispose(), MixerAudioDevice.Engine, MixerAudioDevice.IsAvailable, MixerAudioDevice.MusicFormats, MixerAudioDevice.CurrentMusic, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Fields
DefaultLatencyMilliseconds
Audio kept queued by default, in milliseconds: longer than the longest collection measured on desktop.
public const double DefaultLatencyMilliseconds = 60Field Value
Methods
TryCreate()
Opens the default playback device, or returns a silent device (and says why) when there is none.
public static IAudioDevice TryCreate()Returns
TryCreate(ILog)
Opens the default playback device, or returns a silent device and writes why to log when there is none.
public static IAudioDevice TryCreate(ILog log)Parameters
log ILog
Returns
TryCreate(string)
Opens the default playback device of SDL’s audio driver driver: “dummy” runs SDL’s whole audio
path without any device or sound, for tests; “disk” writes the mixed output to a file (SDL’s
SDL_AUDIO_DISK_OUTPUT_FILE hint). Returns a silent device (and says why) when the driver is unavailable
or SDL’s audio was already started with another driver.
public static IAudioDevice TryCreate(string driver)Parameters
driver string
Returns
TryCreate(string?, double)
Opens the default playback device (of driver, or SDL’s choice when null) keeping
latencyMilliseconds of audio queued: lower plays sounds sooner, higher survives longer pauses.
public static IAudioDevice TryCreate(string? driver, double latencyMilliseconds)Parameters
driver string?
latencyMilliseconds double
Returns
Exceptions
latencyMilliseconds is not between 5 and 1000.