Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(extension): stop microphone playback when tab audio is off
Akshar Patel492276513df0
diff --git a/apps/chrome-extension/src/offscreen/recorder.test.ts b/apps/chrome-extension/src/offscreen/recorder.test.tsindex 97b706470..3f50f3244 100644--- a/apps/chrome-extension/src/offscreen/recorder.test.ts+++ b/apps/chrome-extension/src/offscreen/recorder.test.ts@@ -42,9 +42,11 @@ class Stream {let onMessage: MessageListener;let capturedStream: Stream;+let speakerStreams: Stream[];beforeEach(async () => {vi.resetModules();+ speakerStreams = [];vi.useFakeTimers();const stored: Record<string, unknown> = {};const storage = {@@ -91,8 +93,12 @@ beforeEach(async () => {return { stream: new Stream([new Track("audio")]) };}- createMediaStreamSource() {- return { connect: vi.fn() };+ createMediaStreamSource(stream: Stream) {+ return {+ connect: (destination: object) => {+ if (destination === this.destination) speakerStreams.push(stream);+ },+ };}},);@@ -133,6 +139,7 @@ const send = (message: Record<string, unknown>) =>describe("recording microphone mute", () => {it.each([{ mode: "tab", microphone: true, systemAudio: true },+ { mode: "tab", microphone: true, systemAudio: false },{ mode: "fullscreen", microphone: true, systemAudio: true },{ mode: "camera", microphone: true, systemAudio: false },{ mode: "tab", microphone: false, systemAudio: true },@@ -141,7 +148,7 @@ describe("recording microphone mute", () => {microphone: boolean;systemAudio: boolean;}>)(- "mutes only microphone capture in $mode with microphone=$microphone",+ "mutes only microphone capture in $mode with microphone=$microphone, systemAudio=$systemAudio",async ({ mode, microphone, systemAudio }) => {const mic = new Track("audio");const system = new Track("audio");@@ -179,6 +186,10 @@ describe("recording microphone mute", () => {}),).toMatchObject({ ok: true, status: { phase: "recording" } });+ expect(speakerStreams).toEqual(+ mode === "tab" && systemAudio ? [main] : [],+ );+expect(await send({ type: "toggle-microphone-mute", muted: true }),).toEqual({ ok: true });diff --git a/apps/chrome-extension/src/offscreen/recorder.ts b/apps/chrome-extension/src/offscreen/recorder.tsindex 792186506..edeec2015 100644--- a/apps/chrome-extension/src/offscreen/recorder.ts+++ b/apps/chrome-extension/src/offscreen/recorder.ts@@ -621,10 +621,10 @@ const addAudioTracks = ({const audioContext = new AudioContext();const destination = audioContext.createMediaStreamDestination();- streamsWithAudio.forEach((stream, index) => {+ streamsWithAudio.forEach((stream) => {const source = audioContext.createMediaStreamSource(stream);source.connect(destination);- if (routeFirstStreamToSpeakers && index === 0) {+ if (routeFirstStreamToSpeakers && stream === streams[0]) {source.connect(audioContext.destination);}});