Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(recording): measure the audio tap on what it delivered, not on the mix

EtienneLescot51ad6b9a1123
diff --git a/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/AudioTrackMixer.swift b/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/AudioTrackMixer.swift
index 51e2bdbeb..e63fd0d88 100644
--- a/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/AudioTrackMixer.swift
+++ b/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/AudioTrackMixer.swift
@@ -110,11 +110,17 @@ public final class AudioTrackMixer {
private var anchor: CMTime?
/// Absolute frame index of the next chunk to emit.
private var cursor: Int64 = 0
- /// Frames emitted for which a given source contributed nothing. This is the measurement
- /// that answers whether ScreenCaptureKit's system-audio output is silence-gapped the way the
- /// WASAPI loopback tap is: on a take where nothing plays, a gapped tap leaves this equal to
- /// the whole track and a continuously-streaming one leaves it near zero.
- private var uncoveredFrames = [Int64](repeating: 0, count: Source.allCases.count)
+ /// Per source, the absolute frame its most recent delivery reached — nil until it delivers
+ /// anything — and the holes measured between deliveries.
+ ///
+ /// Measured on what each source handed over, never on what came out of the mixer. Reading a
+ /// hole off the mixed output cannot answer the question the numbers exist for, because
+ /// `SourceTimeline.ingest` zero-fills holes up to `maxSilencePadFrames` into the source's own
+ /// buffer: a tap that stops for anything under two seconds would come back fully covered,
+ /// which is precisely the case that would tell us it is gapped.
+ private var deliveredThroughFrame = [Int64?](repeating: nil, count: Source.allCases.count)
+ private var undeliveredFrames = [Int64](repeating: 0, count: Source.allCases.count)
+ private var longestHoleFrames = [Int64](repeating: 0, count: Source.allCases.count)
private var pending: [CMSampleBuffer] = []
private var didWarnAboutBacklog = false
private var didWarnAboutDecode: Set<Int> = []
@@ -172,10 +178,9 @@ public final class AudioTrackMixer {
}
let now = clock()
- sources[source.rawValue].ingest(
- frames,
- atFrame: frameIndex(of: presentationTime, from: anchor)
- )
+ let startFrame = frameIndex(of: presentationTime, from: anchor)
+ noteDelivery(source, from: startFrame, frameCount: Int64(frames.count / MixFormat.channelCount))
+ sources[source.rawValue].ingest(frames, atFrame: startFrame)
// Where the clock stood when this source last said anything — not where its samples
// sit. See `emissionGraceFrames`.
sources[source.rawValue].lastDeliveryFrame = frameIndex(of: now, from: anchor)
@@ -201,6 +206,7 @@ public final class AudioTrackMixer {
// No grace: capture has stopped, so a source that has not covered a chunk by now
// never will, and waiting on it would only truncate the tail.
drain(upTo: end, grace: 0)
+ closeDeliveryHoles()
emitTimelineSummary()
}
flushPending(force: true)
@@ -228,29 +234,83 @@ public final class AudioTrackMixer {
])
}
- /// Reports how much of the finished track each source actually covered.
+ /// Records the hole, if any, between this source's previous delivery and this one.
+ private func noteDelivery(_ source: Source, from startFrame: Int64, frameCount: Int64) {
+ let index = source.rawValue
+ // Audio captured before the session start is trimmed at frame zero, not missing.
+ let start = max(0, startFrame)
+ let previousEnd = deliveredThroughFrame[index] ?? 0
+ if start > previousEnd {
+ let hole = start - previousEnd
+ undeliveredFrames[index] += hole
+ longestHoleFrames[index] = max(longestHoleFrames[index], hole)
+ }
+ deliveredThroughFrame[index] = max(previousEnd, startFrame + frameCount)
+ }
+
+ /// Counts the stretch from each source's last delivery to the end of the take. A source that
+ /// never delivered at all lands here with the whole track, which is the answer that matters.
+ private func closeDeliveryHoles() {
+ for source in Source.allCases where includes(source) {
+ let index = source.rawValue
+ let tail = cursor - (deliveredThroughFrame[index] ?? 0)
+ if tail > 0 {
+ undeliveredFrames[index] += tail
+ longestHoleFrames[index] = max(longestHoleFrames[index], tail)
+ }
+ }
+ }
+
+ /// Reports what each source actually delivered against the finished track.
///
/// Not diagnostics for their own sake: nothing in the tree recorded whether
/// ScreenCaptureKit's system-audio output goes silent-but-delivering or stops delivering
/// altogether while nothing is playing, and the answer decides how much of the timeline the
/// clock is carrying on its own. One take with system audio enabled and nothing playing
- /// settles it — `systemUncoveredSeconds` comes back as the whole track if the tap is gapped
- /// the way WASAPI loopback is, and near zero if it streams silence.
+ /// settles it — `undeliveredSeconds` comes back as the whole track if the tap is gapped the
+ /// way WASAPI loopback is, and near zero if it streams silence. `longestHoleSeconds`
+ /// separates the two shapes a gapped tap can have: one long outage, or a steady stutter.
+ ///
+ /// `droppedSeconds` is the cost side of the same ledger, and it should be zero. It counts
+ /// audio a source delivered describing a span the cursor had already emitted, which cannot
+ /// be placed any more. That happens only when a source went quiet for longer than
+ /// `emissionGraceFrames` and then handed over the period it was quiet for, so anything above
+ /// zero here says the grace is too short for that capture path.
private func emitTimelineSummary() {
var fields: [String: Any] = [
"event": "audio-timeline",
"code": "audio-timeline-summary",
"trackSeconds": seconds(cursor),
]
- if includesSystemAudio {
- fields["systemUncoveredSeconds"] = seconds(uncoveredFrames[Source.system.rawValue])
- }
- if includesMicrophone {
- fields["microphoneUncoveredSeconds"] = seconds(uncoveredFrames[Source.microphone.rawValue])
+ for source in Source.allCases where includes(source) {
+ let report = deliveryReport(for: source)
+ fields[source == .system ? "system" : "microphone"] = [
+ "undeliveredSeconds": report.undeliveredSeconds,
+ "longestHoleSeconds": report.longestHoleSeconds,
+ "droppedSeconds": report.droppedSeconds,
+ ]
}
emit(fields)
}
+ /// What one source handed over across the finished take. The same numbers
+ /// `emitTimelineSummary` reports, reachable without parsing a log line.
+ public struct DeliveryReport {
+ public let trackSeconds: Double
+ public let undeliveredSeconds: Double
+ public let longestHoleSeconds: Double
+ public let droppedSeconds: Double
+ }
+
+ public func deliveryReport(for source: Source) -> DeliveryReport {
+ DeliveryReport(
+ trackSeconds: seconds(cursor),
+ undeliveredSeconds: seconds(undeliveredFrames[source.rawValue]),
+ longestHoleSeconds: seconds(longestHoleFrames[source.rawValue]),
+ droppedSeconds: seconds(sources[source.rawValue].droppedFrames)
+ )
+ }
+
private func seconds(_ frames: Int64) -> Double {
Double(frames) / Double(MixFormat.sampleRate)
}
@@ -325,14 +385,7 @@ public final class AudioTrackMixer {
private func emitChunk() {
var mix = [Float](repeating: 0, count: MixFormat.chunkFrames * MixFormat.channelCount)
for index in sources.indices {
- let contributed = sources[index].drain(
- into: &mix,
- from: cursor,
- frameCount: MixFormat.chunkFrames
- )
- if let source = Source(rawValue: index), includes(source) {
- uncoveredFrames[index] += Int64(MixFormat.chunkFrames - contributed)
- }
+ sources[index].drain(into: &mix, from: cursor, frameCount: MixFormat.chunkFrames)
}
let presentationTime = CMTimeAdd(
@@ -648,6 +701,8 @@ public final class AudioTrackMixer {
/// Where the clock stood at this source's most recent delivery, in absolute frames.
/// The mixer sets it, because only the mixer holds the clock.
var lastDeliveryFrame: Int64 = 0
+ /// Captured audio that arrived too late to be placed. See `discardFrames(before:)`.
+ private(set) var droppedFrames: Int64 = 0
var endFrame: Int64 { startFrame + Int64(samples.count / MixFormat.channelCount) }
@@ -687,23 +742,21 @@ public final class AudioTrackMixer {
samples.append(contentsOf: frames[overlap...])
}
- /// Adds this source's contribution to one chunk and consumes it, returning how many of
- /// the chunk's frames it actually covered. Frames it doesn't cover are simply left
- /// alone — `mix` already holds silence there.
- @discardableResult
- mutating func drain(into mix: inout [Float], from cursor: Int64, frameCount: Int) -> Int {
- dropFrames(before: cursor)
+ /// Adds this source's contribution to one chunk and consumes it. Frames it doesn't cover
+ /// are simply left alone — `mix` already holds silence there.
+ mutating func drain(into mix: inout [Float], from cursor: Int64, frameCount: Int) {
+ discardFrames(before: cursor)
guard !samples.isEmpty else {
- return 0
+ return
}
let lead = Int(startFrame - cursor)
guard lead < frameCount else {
- return 0
+ return
}
let usableFrames = min(frameCount - lead, samples.count / MixFormat.channelCount)
guard usableFrames > 0 else {
- return 0
+ return
}
let base = lead * MixFormat.channelCount
@@ -712,21 +765,26 @@ public final class AudioTrackMixer {
}
samples.removeFirst(usableFrames * MixFormat.channelCount)
startFrame += Int64(usableFrames)
- return usableFrames
}
/// Discards samples the mixer has already emitted past — a buffer that arrived after
/// its chunk went out cannot be placed any more.
- private mutating func dropFrames(before cursor: Int64) {
+ ///
+ /// This is the one path that loses captured audio, so it keeps a count. It costs
+ /// nothing while a source delivers steadily, however far behind the clock it runs; it
+ /// bites only when one went quiet for longer than `emissionGraceFrames`, had silence
+ /// emitted in its place, and then handed over the period it was quiet for.
+ private mutating func discardFrames(before cursor: Int64) {
guard startFrame < cursor else {
return
}
let available = Int64(samples.count / MixFormat.channelCount)
- let dropFrames = Int(min(cursor - startFrame, available))
- if dropFrames > 0 {
- samples.removeFirst(dropFrames * MixFormat.channelCount)
- startFrame += Int64(dropFrames)
+ let discarded = Int(min(cursor - startFrame, available))
+ if discarded > 0 {
+ samples.removeFirst(discarded * MixFormat.channelCount)
+ startFrame += Int64(discarded)
+ droppedFrames += Int64(discarded)
}
if samples.isEmpty {
startFrame = cursor
diff --git a/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/AudioTrackMixerTests.swift b/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/AudioTrackMixerTests.swift
index a3ed536d9..7d3d96985 100644
--- a/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/AudioTrackMixerTests.swift
+++ b/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/AudioTrackMixerTests.swift
@@ -293,6 +293,96 @@ final class AudioTrackMixerTests: XCTestCase {
}
}
+ // MARK: - What the take reports about its sources
+
+ /// The numbers that answer the ScreenCaptureKit gapping question have to measure what the
+ /// source *delivered*, not what came out of the mixer.
+ ///
+ /// `SourceTimeline.ingest` zero-fills a hole up to `maxSilencePadFrames` into the source's
+ /// own buffer, so a hole read off the mixed output comes back as covered — and that is the
+ /// reading that would report "the tap streams silence" about a tap that had stopped for a
+ /// second and a half, which is the one thing this measurement exists to tell apart. Both
+ /// bursts are ingested before the clock moves, so the padding path is the one taken.
+ func testASubTwoSecondDeliveryHoleIsReportedAsUndelivered() {
+ let sink = RecordingSink()
+ let clock = TestClock(.zero)
+ let mixer = makeMixer(sink: sink, clock: clock, includesMicrophone: false)
+ mixer.beginTimeline(at: clock.now)
+
+ mixer.ingest(
+ makeSourceBuffer(burst(seconds: 0.5, left: 0.5, right: 0.5), at: .zero, nonInterleaved: true),
+ from: .system
+ )
+ mixer.ingest(
+ makeSourceBuffer(
+ burst(seconds: 0.5, left: 0.5, right: 0.5),
+ at: CMTime(seconds: 1.5, preferredTimescale: 48_000),
+ nonInterleaved: true
+ ),
+ from: .system
+ )
+
+ clock.advance(seconds: 3)
+ mixer.finish(atSourceTime: clock.now)
+
+ let report = mixer.deliveryReport(for: .system)
+ XCTAssertEqual(report.trackSeconds, 3.0, accuracy: 0.011)
+ // The 1.0 s hole between the bursts plus the 1.0 s tail after the second one. Measured
+ // off the mixed output instead, the padded hole would vanish and this would read 1.0.
+ XCTAssertEqual(report.undeliveredSeconds, 2.0, accuracy: 0.011)
+ XCTAssertEqual(report.longestHoleSeconds, 1.0, accuracy: 0.011)
+ XCTAssertEqual(report.droppedSeconds, 0, accuracy: 0.011)
+ }
+
+ /// A source that never delivers anything reports the whole take as undelivered — the
+ /// reading that would say ScreenCaptureKit gaps its silence outright.
+ func testASourceThatNeverDeliversReportsTheWholeTakeUndelivered() {
+ let sink = RecordingSink()
+ let clock = TestClock(.zero)
+ let mixer = makeMixer(sink: sink, clock: clock, includesMicrophone: false)
+ mixer.beginTimeline(at: clock.now)
+
+ clock.advance(seconds: 2)
+ mixer.finish(atSourceTime: clock.now)
+
+ let report = mixer.deliveryReport(for: .system)
+ XCTAssertEqual(report.undeliveredSeconds, 2.0, accuracy: 0.011)
+ XCTAssertEqual(report.longestHoleSeconds, 2.0, accuracy: 0.011)
+ }
+
+ /// Audio that arrives after the cursor has already emitted its span cannot be placed, and
+ /// that is the one path here that loses captured sound. It is reported rather than silent,
+ /// because anything above zero means the grace is too short for that capture path.
+ func testAudioArrivingAfterItsChunkWentOutIsCountedAsDropped() {
+ let sink = RecordingSink()
+ let clock = TestClock(.zero)
+ let mixer = makeMixer(sink: sink, clock: clock, includesMicrophone: false)
+ mixer.beginTimeline(at: clock.now)
+
+ mixer.ingest(
+ makeSourceBuffer(burst(seconds: 0.5, left: 0.5, right: 0.5), at: .zero, nonInterleaved: true),
+ from: .system
+ )
+ // Long enough past the grace that the source is written off and the cursor runs on.
+ clock.advance(seconds: 2)
+ mixer.tick()
+
+ // …and only now does it hand over the span it went quiet for, which is already behind
+ // the cursor and cannot be placed.
+ mixer.ingest(
+ makeSourceBuffer(
+ burst(seconds: 0.5, left: 0.5, right: 0.5),
+ at: CMTime(seconds: 0.6, preferredTimescale: 48_000),
+ nonInterleaved: true
+ ),
+ from: .system
+ )
+ clock.advance(seconds: 1)
+ mixer.finish(atSourceTime: clock.now)
+
+ XCTAssertEqual(mixer.deliveryReport(for: .system).droppedSeconds, 0.5, accuracy: 0.011)
+ }
+
// MARK: - Pause
/// A pause stops the clock instead of resetting it. `ScreenCaptureRecorder.timelineNow()`
diff --git a/scripts/test-macos-audio-timeline.mjs b/scripts/test-macos-audio-timeline.mjs
index e08af311b..b71605d25 100644
--- a/scripts/test-macos-audio-timeline.mjs
+++ b/scripts/test-macos-audio-timeline.mjs
@@ -226,9 +226,23 @@ function armPlaybackOnce() {
}, PLAY_AT_MS);
}
-function consume(chunk) {
- helperOutput += chunk.toString();
- for (const line of chunk.toString().split("\n")) {
+/**
+ * Reassembles the helper's NDJSON across chunk boundaries.
+ *
+ * A `data` chunk is whatever the pipe had ready, not a whole line, so splitting each chunk on
+ * its own newlines drops any event a read happened to bisect — both halves parse as neither.
+ * Losing `recording-started` that way leaves the tone unarmed and the run hangs until the
+ * 30 s timeout kills the helper, which reads as "the helper never started" rather than as a
+ * framing bug. Only stdout carries events; stderr is diagnostics and is kept as raw text.
+ */
+let stdoutTail = "";
+function consumeStdout(chunk) {
+ const text = chunk.toString();
+ helperOutput += text;
+ stdoutTail += text;
+ const lines = stdoutTail.split("\n");
+ stdoutTail = lines.pop() ?? "";
+ for (const line of lines) {
const trimmed = line.trim();
if (!trimmed.startsWith("{")) continue;
try {
@@ -239,8 +253,10 @@ function consume(chunk) {
}
armPlaybackOnce();
}
-proc.stdout.on("data", consume);
-proc.stderr.on("data", consume);
+proc.stdout.on("data", consumeStdout);
+proc.stderr.on("data", (chunk) => {
+ helperOutput += chunk.toString();
+});
// If the helper never announces itself, nothing would ever stop it.
const startTimeout = setTimeout(() => {
@@ -321,6 +337,15 @@ function firstAudibleSecond() {
proc.on("close", (code, signal) => {
clearTimeout(startTimeout);
+ // The summary is the last thing the helper writes, so a final line without its newline
+ // would otherwise sit in the tail buffer and never be read.
+ if (stdoutTail.trim().startsWith("{")) {
+ try {
+ helperEvents.push(JSON.parse(stdoutTail.trim()));
+ } catch {
+ // Truncated on exit; nothing to recover.
+ }
+ }
const problems = [];
if (!playbackArmed) problems.push("recording never started, so no tone was played");
if (spawnError) problems.push(`could not start the helper: ${spawnError}`);
@@ -352,11 +377,19 @@ proc.on("close", (code, signal) => {
);
}
- // The mixer's own account of how much of the track it filled with silence because no
- // source covered it. On a take where nothing plays, this is the measurement that says
- // whether ScreenCaptureKit's system-audio output is silence-gapped the way the WASAPI
- // loopback tap is, or whether it streams silence continuously.
+ // The mixer's own account of what the system-audio tap actually handed over. On a take
+ // where nothing plays, this is the measurement that says whether ScreenCaptureKit's
+ // system-audio output is silence-gapped the way the WASAPI loopback tap is, or whether it
+ // streams silence continuously — and `droppedSeconds` is the cost side: audio the tap
+ // delivered too late to place, which should be zero.
const summary = helperEvents.findLast((event) => event.event === "audio-timeline");
+ const system = summary?.system;
+ const dropped = Number(system?.droppedSeconds ?? 0);
+ if (dropped > 0) {
+ problems.push(
+ `${dropped.toFixed(2)}s of captured audio arrived too late to be placed — the emission grace is too short for this tap`,
+ );
+ }
fs.rmSync(outputPath, { force: true });
console.log(
@@ -364,12 +397,17 @@ proc.on("close", (code, signal) => {
`video=${video?.toFixed(2) ?? "(none)"}s ` +
`tone at ${toneAt === null ? "(none)" : `${toneAt.toFixed(2)}s`}, played at ${playedAt.toFixed(2)}s`,
);
- if (summary) {
+ if (system) {
+ const track = Number(summary.trackSeconds ?? 0);
+ const undelivered = Number(system.undeliveredSeconds ?? 0);
console.log(
- ` system audio delivered nothing for ${Number(summary.systemUncoveredSeconds ?? 0).toFixed(2)}s ` +
- `of a ${Number(summary.trackSeconds ?? 0).toFixed(2)}s track ` +
- `(near the whole track means ScreenCaptureKit gaps its silence, like WASAPI loopback;\n` +
- ` near zero means it streams silence and only the take's edges needed the clock)`,
+ ` system audio delivered nothing for ${undelivered.toFixed(2)}s of a ${track.toFixed(2)}s ` +
+ `track, longest hole ${Number(system.longestHoleSeconds ?? 0).toFixed(2)}s\n` +
+ ` => ${
+ undelivered > track / 2
+ ? "ScreenCaptureKit GAPS its silence, like WASAPI loopback"
+ : "ScreenCaptureKit STREAMS silence; only the take's edges needed the clock"
+ }`,
);
}
for (const problem of problems) console.log(` -> ${problem}`);
diff --git a/technical-documentation/architecture/recording.md b/technical-documentation/architecture/recording.md
index fa9d81cc8..258924e01 100644
--- a/technical-documentation/architecture/recording.md
+++ b/technical-documentation/architecture/recording.md
@@ -71,7 +71,7 @@ A session writes a screen video and a `.session.json` manifest. Windows normally
The Windows helper mixes system loopback and microphone into one track, and timestamps it from a running count of emitted frames. That count is advanced by a clock rather than by the arrival of samples: a chunk goes out every 10 ms for as long as the recording runs, filled from whichever source has data and with silence where neither does. Advancing it only when a queue held samples is what made a take that began in silence emit nothing at all — WASAPI loopback delivers no packets while nothing is playing — so the first sound landed at timestamp zero and the track came out shorter than the take. A working microphone concealed it by streaming continuously, which is why it appeared as a system-audio desync on a machine whose microphone had failed. `npm run test:wgc-audio-timeline:win` measures where a tone played at a known instant actually lands.
-The macOS helper mixes the same two sources into one AAC track (`AudioTrackMixer`) and runs the same discipline, arrived at from the opposite direction. There the emit cursor is anchored to the writer session start and advanced by a monotonic clock read off `CMClockGetHostTimeClock` — the domain ScreenCaptureKit already timestamps its buffers in — with a 10 ms timer on the sample queue moving it while nothing is arriving to move it. The bug it replaces was the anchor, not the counter: `anchor` was set lazily on the first decoded buffer to `max(firstPresentationTime, sessionStart)`, so audio that first arrived four seconds in made frame zero of the track *be* four seconds in. The trailing half was worse still — `drain()` ran only from `ingest` and `finish`, and the helper never called `writer.endSession(atSourceTime:)` at all, so the file ended at the last sample anything happened to deliver. Both halves and any mid-take gap are now one mechanism: chunks go out for as long as the take runs, from whichever source covers them and from silence where none does, and a source is written off for a chunk only once real time has run 250 ms past it — a decision about when to stop waiting, which shifts nothing, and not a correction, which would. A pause freezes the clock rather than resetting it, so what follows keeps the position it would have had. Whether ScreenCaptureKit's system-audio output is silence-gapped the way WASAPI loopback is has never been recorded anywhere, and it decides how much of a take the clock is carrying alone rather than how the mixer should work; the helper now reports it per take as `audio-timeline`, whose `systemUncoveredSeconds` is the whole track if the tap is gapped and near zero if it streams silence. `swift test` runs the mixer against a collecting sink and a hand-moved clock on every pull request (`swift-macos-helper` in ci.yml, the first Swift job this repository has had); `npm run test:sck-audio-timeline:mac` measures a real tone through a real device, comparing the audio track's length against the video track's in the same file.
+The macOS helper mixes the same two sources into one AAC track (`AudioTrackMixer`) and runs the same discipline, arrived at from the opposite direction. There the emit cursor is anchored to the writer session start and advanced by a monotonic clock read off `CMClockGetHostTimeClock` — the domain ScreenCaptureKit already timestamps its buffers in — with a 10 ms timer on the sample queue moving it while nothing is arriving to move it. The bug it replaces was the anchor, not the counter: `anchor` was set lazily on the first decoded buffer to `max(firstPresentationTime, sessionStart)`, so audio that first arrived four seconds in made frame zero of the track *be* four seconds in. The trailing half was worse still — `drain()` ran only from `ingest` and `finish`, and the helper never called `writer.endSession(atSourceTime:)` at all, so the file ended at the last sample anything happened to deliver. Both halves and any mid-take gap are now one mechanism: chunks go out for as long as the take runs, from whichever source covers them and from silence where none does, and a source is written off for a chunk only once it has gone 250 ms without delivering anything — a decision about when to stop waiting, which shifts nothing, and not a correction, which would. Measured from that source's own last delivery rather than from how far behind the clock its coverage sits, because those differ for a source that is alive but arriving late: a capture path delivering a fixed delay behind the audio it describes would be "behind" forever, so writing it off for that would emit silence and then drop its real samples, every chunk, for the whole take. A pause freezes the clock rather than resetting it, so what follows keeps the position it would have had. Whether ScreenCaptureKit's system-audio output is silence-gapped the way WASAPI loopback is has never been recorded anywhere, and it decides how much of a take the clock is carrying alone rather than how the mixer should work; the helper now reports it per take as `audio-timeline`, whose `undeliveredSeconds` is the whole track if the tap is gapped and near zero if it streams silence. That figure counts what each source handed over rather than what came out of the mixer — holes under two seconds are zero-filled into the source's own buffer, so a hole read off the mixed output would come back covered, which is the exact case it exists to catch — and `droppedSeconds` beside it is the cost side, counting audio that arrived too late to place and reading zero unless the grace is too short for that tap. `swift test` runs the mixer against a collecting sink and a hand-moved clock on every pull request (`swift-macos-helper` in ci.yml, the first Swift job this repository has had); `npm run test:sck-audio-timeline:mac` measures a real tone through a real device, comparing the audio track's length against the video track's in the same file.
Cursor samples are persisted as cursor telemetry rather than baked into editable-overlay recordings. The loader resolves the sidecar at `<videoPath>.cursor.json` or through the recording links; see [cursor.md](cursor.md) for the telemetry format and rendering path.