fix(recording): default windows mic to browser processing

This commit is contained in:
wiiiii123 committed 2026-05-07 04:51:30 +07:00
1 parent 5bb36ca5fa
commit 45f05e78c4
3 files changed
+40 -1

No files matched your search

@@ -7,6 +7,12 @@ import {
} from "./windowsFallbacks";
describe("shouldUseWindowsBrowserMicrophoneFallback", () => {
it("defaults Windows microphone capture to the browser fallback path", () => {
expect(shouldStartWindowsBrowserMicrophoneFallback({ capturesMicrophone: true }, {})).toBe(
true,
);
});
it("can be forced before native capture starts", () => {
expect(
shouldStartWindowsBrowserMicrophoneFallback(
@@ -16,6 +22,21 @@ describe("shouldUseWindowsBrowserMicrophoneFallback", () => {
).toBe(true);
});
it("allows lab runs to force native WASAPI microphone capture", () => {
expect(
shouldStartWindowsBrowserMicrophoneFallback(
{ capturesMicrophone: true },
{ [WINDOWS_MIC_CAPTURE_MODE_ENV]: "native" },
),
).toBe(false);
expect(
shouldStartWindowsBrowserMicrophoneFallback(
{ capturesMicrophone: true },
{ [WINDOWS_MIC_CAPTURE_MODE_ENV]: "wasapi" },
),
).toBe(false);
});
it("does not force fallback when microphone capture was not requested", () => {
expect(
shouldStartWindowsBrowserMicrophoneFallback(
@@ -43,6 +64,16 @@ describe("shouldUseWindowsBrowserMicrophoneFallback", () => {
).toBe(false);
});
it("returns false for a healthy native mic when lab mode forces native capture", () => {
expect(
shouldUseWindowsBrowserMicrophoneFallback(
"Recording started",
{ capturesMicrophone: true },
{ [WINDOWS_MIC_CAPTURE_MODE_ENV]: "native" },
),
).toBe(false);
});
it("returns true when browser fallback is forced", () => {
expect(
shouldUseWindowsBrowserMicrophoneFallback(
@@ -10,6 +10,14 @@ export function shouldStartWindowsBrowserMicrophoneFallback(
}
const mode = env[WINDOWS_MIC_CAPTURE_MODE_ENV]?.trim().toLowerCase();
if (mode === "native" || mode === "wasapi") {
return false;
}
if (!mode) {
return true;
}
return mode === "browser" || mode === "fallback" || mode === "renderer";
}
+1 -1
View File
@@ -1041,7 +1041,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
// record mic via browser getUserMedia as a sidecar file.
if (nativeResult.microphoneFallbackRequired && microphoneEnabled) {
void logNativeCaptureDiagnostics("start-browser-microphone-fallback");
toast.warning("Using browser microphone fallback for this recording.", {
toast.warning("Using browser microphone processing for this recording.", {
id: MICROPHONE_FALLBACK_TOAST_ID,
duration: 8000,
});