AudioDevice

The default playback device, fed with 32-bit float stereo frames at sampleRate by an AudioRenderer. SDL converts to whatever the hardware wants and follows changes of the default device by itself.

Open one with AudioDevice.open after Sdl.init with Subsystem.AUDIO; it starts playing at once. close it before Sdl.quit.

Threading: the renderer runs on SDL's audio thread. An exception it throws is caught there, kept for failureOrNull, and the device plays silence from then on, so a broken renderer cannot crash the process. Every other function belongs to the thread that opened the device.

Has no sample because it needs an audio device.

Types

Link copied to clipboard
object Companion

Holds the factory that opens the playback device.

Properties

Link copied to clipboard

Returns the largest number of frames the renderer is asked for in one call.

Link copied to clipboard

Returns true while playback is paused by pause, and after close.

Link copied to clipboard

Returns the frame rate the renderer produces at. SDL resamples it to the device's own rate.

Functions

Link copied to clipboard
open override fun close()

Stops playback and releases the device. When it returns, the renderer is no longer running and will not be called again. Calling it again does nothing.

Link copied to clipboard

Returns the first exception the renderer threw on the audio thread, or null when it has thrown none. Once it is set, the device plays silence until it is closed.

Link copied to clipboard
fun pause()

Stops calling the renderer and plays silence until resume. Does nothing when already paused.

Link copied to clipboard
fun resume()

Starts calling the renderer again after pause. Does nothing when already playing.

Link copied to clipboard
open override fun toString(): String

Returns the format as AudioDevice(<rate> Hz, <frames> frames), with closed once closed.