onStreamUnderrun

open fun onStreamUnderrun(stream: AudioStream, count: Int)

Called when an audio underrun (output) or overrun (input) is detected.

An underrun occurs when the application fails to provide audio data fast enough, causing gaps (glitches) in playback. An overrun occurs when the application fails to consume captured audio data fast enough, causing samples to be dropped.

Frequent underruns indicate that the AudioStreamCallback.onAudioReady implementation is too slow, or that the buffer size is too small. Consider increasing AudioStreamConfig.bufferCapacityInFrames or reducing the amount of work done in the callback.

This is called on a platform thread (not the real-time audio thread).

Parameters

stream

The stream that experienced the underrun or overrun.

count

The cumulative number of underruns (or overruns) detected since the stream was started. This counter resets when the stream is stopped and restarted.