Skip to content

Autosave the project during recording - #12539

Merged
kryksyh merged 3 commits into
audacity:masterfrom
kryksyh:autosave-during-recording
Oct 23, 2026
Merged

kryksyh merged 3 commits into
audacity:masterfrom
kryksyh:autosave-during-recording

Conversation

@kryksyh

@kryksyh kryksyh commented Oct 20, 2026

Copy link
Copy Markdown
Member

Resolves: #12377

Two issues involved:

  • During recording Audacity 4 never called for autosave
  • During recording autosave there is a possible data race if the sequences being serialized are modified on the audio thread. This issue is also present in Audacity 3, to be backported.
  • I signed CLA
  • This PR includes AI assistance
  • If the PR is AI-assisted, I have read, understood and complied with the guidelines for AI-assisted contributions
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

The change adds a recordingNewBlocks notification and uses it to trigger project autosaves when recording data exists. Project serialization locks a shared mutex, and audio buffer draining skips a processing turn when it cannot acquire that mutex. WriteXML and AutoSave no longer accept a recording flag. Overlong-block warnings are logged without a message box or truncation attempt.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Au3AudioIOListener
  participant Au3AudioEngine
  participant Au3Record
  participant ProjectFileIO
  participant Sequence
  Au3AudioIOListener->>Au3AudioEngine: Publish recordingNewBlocks notification
  Au3AudioEngine->>Au3Record: Forward recordingNewBlocks notification
  Au3Record->>ProjectFileIO: Call AutoSave when recording data exists
  ProjectFileIO->>Sequence: Lock RecordingMutex during XML serialization
Loading
Merge Risk: 🟠 High · up to 5cb17

This change is meant to let crash recovery restore audio recorded before an interruption. However, autosaves taken during recording still leave out newly created recording tracks and audio being appended to existing tracks. A project recovered after a crash can therefore be empty or missing the recorded audio, which defeats the purpose of the change. Fix this before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: enabling project autosave during recording.
Description check Passed The description identifies the resolved issue, explains both motivations, and completes the required checklist items.
Linked Issues check Passed Issue #12377 requires recovery of recorded project data after a crash during recording. Au3AudioIOListener records new audio blocks from the audio thread and publishes recordingNewBlocks from its …
Out of Scope Changes check Passed The changed files support issue #12377. They add the recording-block notification, connect it to autosave, link the required project-file library, remove obsolete pending-track autosave handling, and …
Full details: Linked Issues check

Explanation

Issue #12377 requires recovery of recorded project data after a crash during recording. Au3AudioIOListener records new audio blocks from the audio thread and publishes recordingNewBlocks from its timer. Au3Record invokes ProjectFileIO::AutoSave() for each notification while recording data exists. ProjectFileIO::WriteXML holds Sequence::RecordingMutex() while it serializes tracks, and AudioIO.cpp skips conflicting buffer processing when the mutex is busy. This implements autosave during recording and protects sequence serialization from concurrent recording updates.

Full details: Out of Scope Changes check

Explanation

The changed files support issue #12377. They add the recording-block notification, connect it to autosave, link the required project-file library, remove obsolete pending-track autosave handling, and synchronize recording with serialization. The Sequence::WriteXML warning change prevents a modal truncation dialog during autosave and supports safe serialization. No unrelated change is established by the reviewed diff.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ca96538-1f3b-4ec6-a79d-55ee1ab36d00
📥 Commits

Reviewing files that changed from the base of the PR and between 3c265f2 and 7c7d509.

📒 Files selected for processing: 11
  • au3/libraries/au3-audio-io/AudioIO.cpp
  • au3/libraries/au3-project-file-io/ProjectFileIO.cpp
  • au3/libraries/au3-wave-track/Sequence.cpp
  • au3/libraries/au3-wave-track/Sequence.h
  • src/au3audio/internal/au3audioengine.cpp
  • src/au3audio/internal/au3audioengine.h
  • src/au3audio/internal/au3audioiolistener.h
  • src/au3audio/tests/mocks/audioenginemock.h
  • src/audio/iaudioengine.h
  • src/record/CMakeLists.txt
  • src/record/internal/au3/au3record.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/record/internal/au3/au3record.cpp Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23606417-470d-4bd0-b2ad-b4e44b70cb16
📥 Commits

Reviewing files that changed from the base of the PR and between 7c7d509 and 5cb17f1.

📒 Files selected for processing: 2
  • au3/libraries/au3-project-file-io/ProjectFileIO.cpp
  • au3/libraries/au3-project-file-io/ProjectFileIO.h

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Assisted-by: Claude Code (claude-opus-5-5)
…g serialized (e.g. on autosaave)

Assisted-by: Claude Code (claude-opus-5-5)
Now recording tracks are real project tracks and the save path is the same during recording
@kryksyh
kryksyh force-pushed the autosave-during-recording branch from 5cb17f1 to 8c14b79 Compare October 23, 2026 11:43
@kryksyh
kryksyh merged commit afd5b77 into audacity:master Oct 23, 2026
3 of 10 checks passed
@kryksyh
kryksyh deleted the autosave-during-recording branch October 23, 2026 11:43
kryksyh added a commit that referenced this pull request Oct 27, 2026
Autosave the project during recording
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.

Project data loss after a crash during recording

2 participants