feat(audio): add media stream output#426
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b27bdb56-d938-41a9-bafe-1e401290322f
API ChangesAPI Extractor detected public API changes for No removed public API lines were detected; this appears to be additive. API Extractor diffdiff --git a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
index a6130e19..089f7ff3 100644
--- a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md
+++ b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
@@ -470,6 +470,11 @@ export interface AudioEngine {
readonly state: AudioEngineState;
}
+// @public
+export interface AudioEngineMediaStream {
+ readonly stream: MediaStream;
+}
+
// @public
export interface AudioEngineOptions {
audioContext?: BaseAudioContext;
@@ -1155,6 +1160,9 @@ export function createAudioBusAsync(engine: AudioEngine, name: string, options?:
// @public
export function createAudioEngineAsync(options?: AudioEngineOptions): Promise<AudioEngine>;
+// @public
+export function createAudioEngineMediaStream(engine: AudioEngine): AudioEngineMediaStream;
+
// @public
export function createAudioVisualizer(host: AudioGraphHost, canvas: HTMLCanvasElement, options?: AudioVisualizerOptions): AudioVisualizer;
@@ -1898,6 +1906,9 @@ export function disposeAudioBus(bus: AudioBus): void;
// @public
export function disposeAudioEngine(engine: AudioEngine): void;
+// @public
+export function disposeAudioEngineMediaStream(output: AudioEngineMediaStream): void;
+
// @public
export function disposeAudioVisualizer(viz: AudioVisualizer): void; |
Lite Playground - Static SiteBuild 20260719.1 - merge @ 0311fa6 |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in MediaStream “tap” for Babylon Lite’s AudioEngine final (post-master) mix so consumers can record or forward audio (e.g., WebRTC) without changing normal speaker output, with explicit idempotent disposal and engine-owned cleanup.
Changes:
- Introduces
createAudioEngineMediaStream/disposeAudioEngineMediaStreamand theAudioEngineMediaStreamhandle. - Extends the unit WebAudio mock to support
createMediaStreamDestination()and a mock destination node. - Adds unit tests and updates architecture docs + public exports for the new API.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/lite/unit/audio/web-audio-mock.ts | Adds mock createMediaStreamDestination() and MockMediaStreamAudioDestinationNode support for unit testing. |
| tests/lite/unit/audio/media-stream-output.test.ts | New unit tests covering wiring, idempotent disposal, engine-disposal cleanup, and offline-context rejection. |
| packages/babylon-lite/src/index.ts | Re-exports the new media-stream output API at the package root. |
| packages/babylon-lite/src/audio/media-stream-output.ts | Implements the MediaStream output tap and safe, idempotent disposal behavior. |
| packages/babylon-lite/src/audio/index.ts | Re-exports the new API from the audio barrel. |
| docs/lite/architecture/41-audio-engine.md | Documents the new Lite-only media-stream output feature and updates the audio module manifest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Lab - Static SiteBuild 20260719.1 - merge @ 0311fa6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MediaStreamfor recording and WebRTC without changing speaker outputValidation
pnpm run lintpnpm exec vitest run --project unit tests/lite/unit/audio/media-stream-output.test.ts(4 passed)pnpm test(bundle-size gate passed; 427 parity tests passed; only the known unrelated scenes 47, 104, 105, 106, and 265 failed)