Skip to content

fix(12905): playback stutter fix - #12911

Open
saintmatthieu wants to merge 2 commits into
audacity:masterfrom
saintmatthieu:12905-playback-stutter-fix
Open

saintmatthieu wants to merge 2 commits into
audacity:masterfrom
saintmatthieu:12905-playback-stutter-fix

Conversation

@saintmatthieu

Copy link
Copy Markdown
Contributor

Resolves: #12905

The rationale behind the fix is in the commit message.

History:

  1. Fix loop toggling off and on during playback #5438 wrote exactly the same fix as today, but for another type of bug, not reproducible now before or after this PR,
  2. 8b2944e moved defaultplaybackpolicy to AU4 and, in the doing, reverted that fix. Accidentally? On purpose? @Eism
  • 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

Assisted-by: Claude Code w/ Opus 5.5

Recommended:

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

QA

audacity#12905: 16 tracks with sample rates different from project rate,
what's more with time-stretched clips.
Without this fix, after a seek, tracks mistakenly get re-positioned
on each worker-thread call.
For tracks with resamplers, this involves re-fetching the track data.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Mixer now provides SetTimes to update time bounds and reposition to the start time. SetTimesAndSpeed uses this method. During a seek, AudioIO assigns playback mixers the seek time and schedule end time with flushing enabled. The playback policy checks loop-region changes only when looping is enabled. Loop-state transitions continue to trigger repositioning.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: Low · up to ef3a7

The change fixes seeking before the play region start. In the unusual case of reverse playback seeking past the region end, mixer output could disagree with the playback position. This is a narrow edge case, so the change is mergeable with that owner awareness.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #12905 reports choppy playback in a project with about 800 clips and a video attachment. The issue has no written acceptance criteria. The only coding requirement is that playback no longer stut… Provide evidence that the reported stutter no longer occurs. Suitable evidence includes a reproduction on the affected project type, or a QA result that covers playback with a large project of similar size. Optionally add an automated test …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "fix(12905): playback stutter fix" names the issue number and the symptom, but not the mechanism. The PR changes seek behavior so seeking before a play region's start no longer clamps to tha…
Description check Passed The description states the issue link (Resolves #12905) and gives history of the fix, with a reference to the commit message for the rationale. It fills in the template checkboxes and includes an AI a…
Out of Scope Changes check Passed All changed code lies in the playback seek and repositioning path. The files are src/au3audio/internal/defaultplaybackpolicy.cpp, au3/libraries/au3-audio-io/AudioIO.cpp, au3/libraries/au3-mixer/Mix.cp…
Full details: Title check

Explanation

The title "fix(12905): playback stutter fix" names the issue number and the symptom, but not the mechanism. The PR changes seek behavior so seeking before a play region's start no longer clamps to that region. The title is partially related: it refers to the real goal (stutter fix for issue #12905) without stating the seek change. It is not off-topic and not vague.

Full details: Description check

Explanation

The description states the issue link (Resolves #12905) and gives history of the fix, with a reference to the commit message for the rationale. It fills in the template checkboxes and includes an AI assistance attribution. Gaps: the description does not explain the change itself in the body, relying on the commit message. The QA items are unchecked, and the note on the loop-region change is not explained in the description. The template's required short description of the changes and motivation is only partly present.

Full details: Out of Scope Changes check

Explanation

All changed code lies in the playback seek and repositioning path. The files are src/au3audio/internal/defaultplaybackpolicy.cpp, au3/libraries/au3-audio-io/AudioIO.cpp, au3/libraries/au3-mixer/Mix.cpp, and au3/libraries/au3-mixer/Mix.h. The Mixer::SetTimes declaration supports the seek change. The Mixer::SetTimesAndSpeed change keeps the finite-speed assertion and delegates to the same method. The DefaultPlaybackPolicy change limits loop-bound comparison to looping mode. This change affects loop-region updates during playback. It is the behavior that the QA item on moving the loop region checks. No unrelated feature or refactor was found in the summary.

Full details: Linked Issues check

Explanation

Issue #12905 reports choppy playback in a project with about 800 clips and a video attachment. The issue has no written acceptance criteria. The only coding requirement is that playback no longer stutters. The PR changes seek handling: AudioIoCallback::CallbackDoSeek calls Mixer::SetTimes(time, mPlaybackSchedule.mT1, true) instead of Mixer::Reposition(time, true). Mixer::SetTimesAndSpeed delegates to SetTimes, and DefaultPlaybackPolicy::RepositionPlayback compares loop bounds only when looping is enabled. The changes are plausibly related to the reported stutter, because the author attributes it to seek clamping. The PR adds no automated test. The QA items in the PR description are unchecked. The attachment could not be read. No reproduction evidence shows that the stutter is resolved.

Resolution

Provide evidence that the reported stutter no longer occurs. Suitable evidence includes a reproduction on the affected project type, or a QA result that covers playback with a large project of similar size. Optionally add an automated test for seek behavior before a play region start. Complete the unchecked QA items, including the re-test of #5422.

  • 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

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7ddbc9e-b836-4abb-9d46-1ed964d3283c
Commits

Reviewing files that changed from the base of the PR and between dc80361 and ef3a765.

Files selected for processing: 3

  • au3/libraries/au3-audio-io/AudioIO.cpp
  • au3/libraries/au3-mixer/Mix.cpp
  • au3/libraries/au3-mixer/Mix.h

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 on lines +3531 to +3533
// Reset mixer bounds and positions, and flush buffers, for all sequences.
for (auto& mixer : mPlaybackMixers) {
mixer->Reposition(time, true);
mixer->SetTimes(time, mPlaybackSchedule.mT1, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Reverse seeks below the region end give the mixer forward bounds.

When loop playback is disabled, DefaultPlaybackPolicy::OffsetSequenceTime does not clamp the seek result. AllowSeek is not overridden for this policy, so the seek is accepted. For a reverse schedule from 20 to 10, a seek to 5 yields time 5. CallbackDoSeek then calls SetTimes(5, 10, true). A mixer orders its bounds by direction, so this call makes the mixer forward while the schedule stays reverse. The mixer output can then disagree with the schedule time.

Define the mixer bounds for a reverse schedule. Keep the mixer direction equal to the schedule direction after every seek. Choose explicitly whether the seek time is clamped to the reverse region or the mixer bounds follow the seek time in reverse order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverse play isn't something we'll be supporting in AudioIO.cpp. The audio engine refactoring won't be reusing this code either, so there isn't really a need to address this now. I can be convinced otherwise, though, @kryksyh @luapmartin

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.

Choppy playback in a large project (~800 clips)

2 participants