Writable

class Writable(aqRef: AudioQueueRef, asbd: AudioStreamBasicDescription, stateRef: StableRef<MacosAudioQueue.Writable.State>) : MacosAudioQueue<MacosAudioQueue.Writable.State>

Constructors

Link copied to clipboard
constructor(aqRef: AudioQueueRef, asbd: AudioStreamBasicDescription, stateRef: StableRef<MacosAudioQueue.Writable.State>)

Types

Link copied to clipboard
class State(var running: Boolean, var enqueueEnabled: Boolean = true, val availableBuffers: Channel<AudioQueueBufferRef>)

Callback-visible state.

Properties

Link copied to clipboard

Bytes handed to the queue that it has not finished playing.

Functions

Link copied to clipboard
fun dispose(inImmediate: Boolean = true)

Stops and disposes the aqRef, matching Apple's recording cleanup sequence: clear running → AudioQueueStop(true) → AudioQueueDispose(true).

Link copied to clipboard
fun enqueueBlocking(src: ByteArray, offset: Int, length: Int): Int

Block until length bytes from src are enqueued (or the queue stops).

Link copied to clipboard
fun flush()

Resets the aqRef's decoder state.

Link copied to clipboard
fun pause()

Pauses playing or recording audio.

Link copied to clipboard
fun reset()

Resets the aqRef.

Link copied to clipboard

Seek discard path (plan Phase 2): quiesce enqueue → AudioQueueStop(true) → re-enable. Does not call markNotRunning / close the buffer pool. Prefer this over AudioQueueFlush for seek (Flush is EOS decoder drain).

Link copied to clipboard
fun start()

Begins playing or recordings audio.

Link copied to clipboard
fun stop(inImmediate: Boolean = true)

Stops playing or recording audio.

Link copied to clipboard
suspend fun streamFrom(src: AudioFlow, maxWriteAttempts: Int = 10)
Link copied to clipboard
suspend fun streamFromWithPriming(src: AudioFlow, primingBuffers: Int)

Streams audio with proper priming - fills initial buffers before starting the queue. This is required for output queues to work correctly.

Link copied to clipboard
fun tryPrimeBuffer(src: ByteArray, offset: Int, length: Int): Int

Fill one available buffer from src and enqueue. Soft-fails DuringReset. Returns bytes written into the buffer (0 if no buffer / empty src / disabled).