BaseAudioPlaybackSession

Shared playback session: prepare → convert once → either legacy playBlocking or ingest ⊥ transport (useTransportPlayback).

seekEpoch (inside TransportController) is independent of the play epoch: seeks abandon in-flight device writes without cancelling an in-flight play() handshake. Stop/dispose still bumps the play epoch and tears transport down.

Play intent is one atomic PlayIntent so "is this generation still current" and "does the user want playback" can never be observed or changed apart. The epoch identifies a play generation (bumped by play/stop/feed restart); pause/resume only flip PlayIntent.wantPlaying, so a paused feed loop parks instead of exiting.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val audioFlow: StateFlow<AudioFlow?>

A flow that emits the current loaded audio data.

Link copied to clipboard
open override val bufferedRange: StateFlow<BufferedRange>

Currently retained seekable window. Empty if nothing buffered. Defaults to a frozen empty range for unmigrated sessions.

Link copied to clipboard
open override val position: StateFlow<Duration>

Transport media time, best-effort while playing. Defaults to a frozen Duration.ZERO for unmigrated sessions.

Link copied to clipboard
open override val state: StateFlow<AudioPlaybackSession.State>

A flow that emits the current state of the playback.

Link copied to clipboard
open override val supportsTransportSeek: Boolean

In-tree platforms that return true from useTransportPlayback publish real bufferedRange / transport seek. External subclassers keep the default.

Functions

Link copied to clipboard
suspend override fun load(audioFlow: AudioFlow)

Loads the given audio data.

Link copied to clipboard
override fun pause()

Pauses the playback.

Link copied to clipboard
suspend override fun play()

Starts playback of the given audio data.

Link copied to clipboard
open suspend fun playBlocking(audioFlow: AudioFlow)

Legacy pull-loop path. All in-tree platforms use transport playback (useTransportPlayback); this remains only for external subclassers until removal in a future minor (cannot override the internal transport hooks).

Link copied to clipboard
abstract suspend fun preparePlayback(format: AudioFormat): AudioFormat
Link copied to clipboard
open override fun release()

Stops playback and cancels scope; the session is unusable afterwards.

Link copied to clipboard
override fun resume()

Resumes paused playback.

Link copied to clipboard
override fun seekTo(position: Duration): SeekResult

Move the transport read cursor.

Link copied to clipboard
override fun stop()

Stops the playback entirely.