Skip to content

AudioRouter

Manages audio buffer queues and header cache wiring for the pipeline.

Defined in: src/core/collaborators/AudioRouter.ts:41

Manages audio buffer queues and header cache wiring for the pipeline.

Remarks

Creates and owns the input queue, output queue, and header cache. Provides methods for wiring providers to queues, starting/stopping drains, and cleanup.

Constructors

Constructor

new AudioRouter(inputQueueConfig?, outputQueueConfig?): AudioRouter;

Defined in: src/core/collaborators/AudioRouter.ts:46

Parameters

ParameterType
inputQueueConfig?Partial<AudioBufferQueueConfig>
outputQueueConfig?Partial<AudioBufferQueueConfig>

Returns

AudioRouter

Properties

PropertyModifierTypeDefined in
headerCachereadonlyAudioHeaderCachesrc/core/collaborators/AudioRouter.ts:44
inputQueuereadonlyAudioBufferQueuesrc/core/collaborators/AudioRouter.ts:42
outputQueuereadonlyAudioBufferQueuesrc/core/collaborators/AudioRouter.ts:43

Methods

clearQueues()

clearQueues(): void;

Defined in: src/core/collaborators/AudioRouter.ts:169

Clear both queues without stopping drains.

Returns

void


connectAndDrainInput()

connectAndDrainInput(stt, input): Promise<void>;

Defined in: src/core/collaborators/AudioRouter.ts:104

Configure STT from input metadata, connect STT, and start draining the input queue into the STT provider.

Parameters

ParameterTypeDescription
sttSTTProviderThe STT provider.
inputAudioInputProviderThe audio input provider (for metadata).

Returns

Promise<void>

Remarks

This implements the race condition fix: audio is buffered in the input queue while the STT WebSocket handshake completes, then flushed in order when draining starts.


getStats()

getStats(): {
  input: QueueStats;
  output: QueueStats;
};

Defined in: src/core/collaborators/AudioRouter.ts:152

Get stats for both queues.

Returns

{
  input: QueueStats;
  output: QueueStats;
}
NameTypeDefined in
inputQueueStatssrc/core/collaborators/AudioRouter.ts:152
outputQueueStatssrc/core/collaborators/AudioRouter.ts:152

onOverflow()

onOverflow(inputOverflow, outputOverflow): void;

Defined in: src/core/collaborators/AudioRouter.ts:71

Register overflow callbacks for both queues.

Parameters

ParameterTypeDescription
inputOverflowOverflowCallbackCallback for input queue overflow.
outputOverflowOverflowCallbackCallback for output queue overflow.

Returns

void


resetHeaderCache()

resetHeaderCache(): void;

Defined in: src/core/collaborators/AudioRouter.ts:162

Reset the header cache.

Returns

void


startOutputDrain()

startOutputDrain(output): void;

Defined in: src/core/collaborators/AudioRouter.ts:126

Start draining the output queue to the output provider.

Parameters

ParameterTypeDescription
outputAudioOutputProviderThe audio output provider.

Returns

void


stopAndClear()

stopAndClear(): void;

Defined in: src/core/collaborators/AudioRouter.ts:135

Stop draining and clear both queues.

Returns

void


stopInput()

stopInput(): void;

Defined in: src/core/collaborators/AudioRouter.ts:144

Stop input draining and clear the input queue.

Returns

void


wireInput()

wireInput(input): void;

Defined in: src/core/collaborators/AudioRouter.ts:85

Wire the input provider to the input queue through the header cache.

Parameters

ParameterTypeDescription
inputAudioInputProviderThe audio input provider.

Returns

void

Remarks

Sets up the onAudio callback on the input provider to feed chunks through the header cache and into the input queue.

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency