Skip to content

Commit 297bc5a

Browse files
committed
fix(macos): accept 8-bit integer PCM microphone input
decodeInterleavedStereo's guard allowed bitsPerChannel down to 8 but required bytesPerSample >= 2, so an 8-bit-in-1-byte microphone buffer was rejected even though the decode loop already handles any bytesPerSample generically. Widen the guard to 1...4 and cover it with an 8-bit fixture.
1 parent f47b418 commit 297bc5a

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎electron/native/screencapturekit/Sources/OpenScreenCaptureCore/AudioTrackMixer.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public final class AudioTrackMixer {
505505
sourceFrames > 0,
506506
isFloat
507507
? bitsPerChannel == 32 && bytesPerSample == 4
508-
: (8...32).contains(bitsPerChannel) && (2...4).contains(bytesPerSample)
508+
: (8...32).contains(bitsPerChannel) && (1...4).contains(bytesPerSample)
509509
&& bitsPerChannel <= bytesPerSample * 8
510510
else {
511511
return nil

‎electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/AudioTrackMixerTests.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ final class AudioTrackMixerTests: XCTestCase {
463463
/// level and with the right sign.
464464
func testIntegerMicrophoneFormatsAreHeardAtTheirLevel() {
465465
let layouts: [(bits: Int, bytes: Int, alignedHigh: Bool, signed: Bool, label: String)] = [
466+
(8, 1, false, true, "8-bit"),
466467
(24, 3, false, true, "24-bit packed (the reported format)"),
467468
(24, 4, false, true, "24-bit in 4 bytes, low-aligned"),
468469
(24, 4, true, true, "24-bit in 4 bytes, high-aligned"),

0 commit comments

Comments
 (0)