Fix #32568: Sound glitches with Loop playback enabled#32598
Fix #32568: Sound glitches with Loop playback enabled#32598RomanPudashkin wants to merge 5 commits intomusescore:masterfrom
Conversation
371ed82 to
c689e8c
Compare
📝 WalkthroughWalkthroughIClock's event-specific notification APIs ( 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/framework/audio/engine/iclock.h`:
- Around line 69-70: The header declares OnActionFunc using std::function but
doesn't include <functional>, risking breakage; open iclock.h and add an
`#include` for <functional> near the other includes so the declaration of
OnActionFunc and the pure virtual setOnAction method reliably compile regardless
of include order.
In `@src/framework/audio/engine/internal/sequenceplayer.cpp`:
- Around line 164-166: The SequencePlayer currently assigns m_loopStart before
calling m_clock->setTimeLoop(...), which can leave SequencePlayer and Clock out
of sync if Clock::setTimeLoop rejects the range; change the order in the
setLoop/setTimeLoop call: first call m_clock->setTimeLoop(fromMsec * 1000,
toMsec * 1000) and check its success/return value, and only on success update
m_loopStart (and any other loop boundary members) so SequencePlayer mirrors the
Clock exactly; reference symbols: m_loopStart, m_clock->setTimeLoop(...),
SequencePlayer, Clock::setTimeLoop.
In `@src/framework/audio/engine/internal/sequenceplayer.h`:
- Around line 73-79: m_playbackStatusChanged is default-constructed but is sent
from a realtime clock callback; change its construction to disable waiting on
subscribers to avoid blocking in realtime (same pattern used for
Clock::m_timeChangedInSecs). In sequenceplayer.cpp, initialize the member
async::Channel m_playbackStatusChanged with options that call
disableWaitPendingsOnSend() (or use the Channel factory/constructor overload
that sets that option) so sends from the clock action callback cannot wait on
subscribers; update the constructor/initializer of the SequencePlayer class
where m_playbackStatusChanged is created accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cb625103-dc11-41c5-863b-a317060f8fe3
📒 Files selected for processing (7)
src/framework/audio/engine/iclock.hsrc/framework/audio/engine/internal/clock.cppsrc/framework/audio/engine/internal/clock.hsrc/framework/audio/engine/internal/sequenceplayer.cppsrc/framework/audio/engine/internal/sequenceplayer.hsrc/framework/audio/engine/internal/tracksequence.cppsrc/framework/audio/engine/internal/tracksequence.h
💤 Files with no reviewable changes (1)
- src/framework/audio/engine/internal/tracksequence.h
…back position desync
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/framework/audio/engine/internal/sequenceplayer.cpp (1)
160-170:⚠️ Potential issue | 🔴 CriticalBug:
setTimeLoopcalled with wrong start boundary.Line 164 passes
m_loopStart(the old/initial value, which is0on first call) instead offromMsec * 1000tom_clock->setTimeLoop(). This causes the clock's internal loop boundaries to be incorrect until after the first successful call, and even then the loop start in the clock won't match the requestedfromMsec.Additionally, as noted in a prior review,
m_loopStartshould only be updated aftersetTimeLoopsucceeds.🐛 Proposed fix
Ret SequencePlayer::setLoop(const msecs_t fromMsec, const msecs_t toMsec) { ONLY_AUDIO_ENGINE_THREAD; - Ret ret = m_clock->setTimeLoop(m_loopStart, toMsec * 1000); + msecs_t loopStartMsecs = fromMsec * 1000; + Ret ret = m_clock->setTimeLoop(loopStartMsecs, toMsec * 1000); if (ret) { - m_loopStart = fromMsec * 1000; + m_loopStart = loopStartMsecs; } return ret; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/framework/audio/engine/internal/sequenceplayer.cpp` around lines 160 - 170, In SequencePlayer::setLoop, setTimeLoop is called with the old m_loopStart instead of the requested new start; change the call to m_clock->setTimeLoop(fromMsec * 1000, toMsec * 1000) and only assign m_loopStart = fromMsec * 1000 after setTimeLoop returns success (Ret indicates success), ensuring the clock receives the correct start boundary and m_loopStart is updated only on success.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/framework/audio/engine/internal/sequenceplayer.cpp`:
- Around line 160-170: In SequencePlayer::setLoop, setTimeLoop is called with
the old m_loopStart instead of the requested new start; change the call to
m_clock->setTimeLoop(fromMsec * 1000, toMsec * 1000) and only assign m_loopStart
= fromMsec * 1000 after setTimeLoop returns success (Ret indicates success),
ensuring the clock receives the correct start boundary and m_loopStart is
updated only on success.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8efc18bd-d97a-4c83-96d9-066022c67a46
📒 Files selected for processing (7)
src/framework/audio/engine/iclock.hsrc/framework/audio/engine/internal/clock.cppsrc/framework/audio/engine/internal/clock.hsrc/framework/audio/engine/internal/sequenceplayer.cppsrc/framework/audio/engine/internal/sequenceplayer.hsrc/framework/audio/engine/internal/tracksequence.cppsrc/framework/audio/engine/internal/tracksequence.h
💤 Files with no reviewable changes (1)
- src/framework/audio/engine/internal/tracksequence.h
|
Tested on Win10. There is a regression with metronome in loop mode: bandicam.2026-04-14.00-21-34-357.mp4 |
Resolves: #32568
Ports: #32573