Repository navigation
fix(macos-helper): set audio probe frameLength before PCM copy - #3821
jipeng6036-del wants to merge 1 commit into
Conversation
AVAudioPCMBuffer starts with frameLength 0, so mDataByteSize stays 0 and CMSampleBufferCopyPCMDataIntoAudioBufferList returns -12731. Set frameLength first, then copy. Add a regression that feeds a real float PCM sample buffer through add(sampleBuffer:) and asserts a non-silent peak. Fixes callstack#3771
|
This change is not ready to merge yet. At b8e3176 the fix looks right, but nothing shows it works on a real audio capture. The change affects the ScreenCaptureKit audio path in AudioProbe.swift. The PR body says no Swift tests and no live audio probe ran. Without a live run, a silent drop back to -90 dBFS would pass every CI lane. Please run Not blocking, and you can take or leave it: AudioProbeTests.swift builds a mono buffer, but ScreenCaptureKit sends two-channel non-interleaved float32, and the checks are loose enough that a copy filling one channel would still pass. Would a stereo case with a different level per channel and an exact peak check (for example -6 dBFS) make the test stronger? CI shows one check pending and none failing, but I could not confirm it is the macos-helper gate, so a green result may not mean the new test ran. There are no conflicts. Once the macOS test and live run are posted, mark the draft ready. |
Summary
audio-probealways reported -90 dBFS becauseAudioProbeStatusWriter.add(sampleBuffer:)calledCMSampleBufferCopyPCMDataIntoAudioBufferListwhileAVAudioPCMBuffer.frameLengthwas still 0, so every destinationmDataByteSizewas 0 and the copy returned -12731.This sets
frameLengthbefore the copy.AudioProbeStatusWriteris internal so the regression can calladd(sampleBuffer:)under@testable. Two files; no public API change. Fixes #3771.Validation
256aa126(upstreammain). Head:b8e31769.git show --shortstat b8e31769→ 2 files, +131/−2.pnpm test:macos-helper/ live ScreenCaptureKitaudio-probewere not run here. CI'smacos-helpergate should runswift test --package-path apple/macos-helper, includingAudioProbeTests.testAddSampleBufferRecordsANonSilentPeakFromRealPCM(synthetic float PCM →heardand peak > -90). That test fails ifframeLengthis set after the copy.check:affected --run --headnot run locally (no Swift toolchain). Relying on CI to serialize the macos-helper gate on this head.swift teston macOS and a liveaudio-proberun haven't been done yet. I'll mark this ready once they have.