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
| Parameter | Type |
|---|---|
inputQueueConfig? | Partial<AudioBufferQueueConfig> |
outputQueueConfig? | Partial<AudioBufferQueueConfig> |
Returns
AudioRouter
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
headerCache | readonly | AudioHeaderCache | src/core/collaborators/AudioRouter.ts:44 |
inputQueue | readonly | AudioBufferQueue | src/core/collaborators/AudioRouter.ts:42 |
outputQueue | readonly | AudioBufferQueue | src/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
| Parameter | Type | Description |
|---|---|---|
stt | STTProvider | The STT provider. |
input | AudioInputProvider | The 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;
}
| Name | Type | Defined in |
|---|---|---|
input | QueueStats | src/core/collaborators/AudioRouter.ts:152 |
output | QueueStats | src/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
| Parameter | Type | Description |
|---|---|---|
inputOverflow | OverflowCallback | Callback for input queue overflow. |
outputOverflow | OverflowCallback | Callback 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
| Parameter | Type | Description |
|---|---|---|
output | AudioOutputProvider | The 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
| Parameter | Type | Description |
|---|---|---|
input | AudioInputProvider | The 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.