Skip to content

fix(recording): keep audio in sync across pauses - #227

Merged
jsattler merged 1 commit into
mainfrom
fix/pause-review-followups
Nov 19, 2026
Merged

jsattler merged 1 commit into
mainfrom
fix/pause-review-followups

Conversation

@jsattler

Copy link
Copy Markdown
Owner

Follow-up to #219.

Audio sync across pauses

AVAssetWriter ignores audio timestamps after the first buffer and writes samples back to back (verified for AAC and PCM). An overlap or gap where a pause is cut out therefore shifted all later audio against the video, by up to one buffer (~21 ms) per pause, adding up across repeated pauses.

The first buffer per audio track after a resume now continues exactly where the track ended: overlaps are trimmed, gaps are filled with silence. audioStaysInSyncAcrossAPause covers overlap and gap for AAC and PCM; it fails without the fix.

Other review follow-ups

  • Extract RecordingClock from RecorderViewModel (paused-time bookkeeping), with unit tests
  • Move RecordingButton to its own file; fix the trailing-closure and file-length SwiftLint warnings
  • Pause button uses Button(_:systemImage:action:) with an icon-only label and a neutral hover instead of red
  • Move pause tests to AssetWriterPauseTests.swift

Still over SwiftLint length limits: RecorderViewModel (330/300) and AssetWriter, as several other files already are.

Testing

  • xcodebuild test: 152 tests pass
  • Pause button appearance not yet checked in the running app

🤖 Generated with Claude Code

The writer ignores audio timestamps after the first buffer, so an
overlap or gap at a pause boundary shifted the rest of the track
against the video. Trim the overlap or fill the gap with silence on
the first buffer after a resume.

Also follow up on the pause review:
- extract RecordingClock from the view model, with tests
- move RecordingButton to its own file and fix SwiftLint warnings
- use a labeled button and a neutral hover for pause
- move pause tests to their own file

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jsattler
jsattler merged commit 945f6a0 into main Nov 19, 2026
3 checks passed
@jsattler
jsattler deleted the fix/pause-review-followups branch November 19, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant