AudioOutputSession
One playback session. Sessions of one service are independent: stopping one does not disturb another.
The normal path is write() for each chunk, then drain(), then stop(); a provider’s
cancel path is stop().
A session ends once: by stop(), or by the system taking the output away (an
interruption, the output stopping), which ends it with Unavailable and details.code
audio_output_interrupted.
Methods
Section titled “Methods”drain()
Section titled “drain()”drain():
Promise<void>
Resolves when everything written has played. After stop(), returns at once without
effect; after the system ended the session, throws its error.
Returns
Section titled “Returns”Promise<void>
firstAudioMs()
Section titled “firstAudioMs()”firstAudioMs():
number|undefined
Milliseconds from the start of open() (the instant it was called, before the output is built
or started) to the first frame the host observed leaving the output; undefined until then.
A provider reports firstAudioMs = (instant before open() was called − receivedAt) +
session.firstAudioMs(), so a slow open is counted once.
Returns
Section titled “Returns”number | undefined
stop()
Section titled “stop()”stop():
void
Ends the session now: discards buffered audio and releases the output. Idempotent, and nothing renders after it.
Returns
Section titled “Returns”void
write()
Section titled “write()”write(
samples):Promise<void>
Hands samples to the host. Resolves once the host has buffered them, so a caller that
awaits each write is paced by the output (backpressure). The first write is the first
possible audible effect. After stop(), returns at once without effect; after the
system ended the session, throws its error.
Parameters
Section titled “Parameters”samples
Section titled “samples”Int16Array
Returns
Section titled “Returns”Promise<void>
IndeRun — open-source AI execution for cross-platform apps. Built and maintained by Independo GmbH (opens in new tab), supported by netidee (opens in new tab).
MIT-licensed SDK · No SDK usage telemetry.
© 2025–2026 Independo GmbH