BaseAudioRecordingSession

An abstract base class for AudioRecordingSession that handles the logic for providing a live "hot" flow during recording, and a replayable "cold" flow after the recording is finished.

This implementation solves the problem of the playback session never finishing by swapping the underlying flow implementation from a hot SharedFlow during recording to a cold, completable flow (backed by a List) once the recording is stopped.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

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

A flow that emits audio data chunks as ByteArrays while recording.

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

A flow that emits the current state of the recording.

Functions

Link copied to clipboard
open suspend override fun pause()

Pauses recording while preserving the captured buffer, the live recording job, and the publicly exposed AudioFlow. Calling resume appends further chunks to the same hot flow, so consumers see one continuous stream.

Link copied to clipboard
open override fun reset()
Link copied to clipboard
open suspend override fun resume()

Resumes a recording previously paused. The buffered chunks from before the pause remain in the audio flow; new chunks are appended to the same hot flow.

Link copied to clipboard
open suspend override fun start()

Starts the recording. Sets the state to RECORDING.

Link copied to clipboard
open override fun stop()

Stops the current recording. Sets the state to STOPPED.