submitDecoded

suspend fun submitDecoded(pts: Pts?, interleaved: FloatArray, frames: Int, sourceFormat: AudioFormat, abort: () -> Boolean = { false })

Hands decoded audio over, suspending until all of it has been accepted.

The samples arrive in sourceFormat, which is what the decoder said it produced, and run through the whole audio path before they reach the ring: the channel mix, the rate conversion, the tempo stage, the equaliser, the balance and the ReplayGain. This is the one feed, so every setting of this class acts on what arrives here.

Suspending here is the backpressure that paces decoding to playback. The caller does not need to know how full the device is.

The stage is keyed on sourceFormat against the format it was built for, so a decoder that changes format mid-stream gets a new one on the buffer that changed rather than one buffer later. The old one plays out what it still holds first. When sourceFormat already is the negotiated format every stage is a copy and the cost is one pass over the samples.

Parameters

pts

the media timestamp of the first frame, when the decoder gave one. Passing null is normal for buffers that continue from the previous one.

interleaved

channel-interleaved float samples in sourceFormat.

frames

sample frames in interleaved, meaning one value per channel each.

abort

polled while the ring is full. Returning true gives up the rest of the buffer, and the caller is expected to flush, as a seek does.

Throws

carrying PlaybackError.DecoderFailed when sourceFormat has no channels or no rate, or when a stage would need more than 4 Mi float values for this buffer. The refused stage allocates nothing.