Skip to content

Commit 18f89d2

Browse files
committed
(fix) Avoid engine freeze when loading a new track while scratching with waveform or spinny
1 parent 9410afb commit 18f89d2

5 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/engine/controls/ratecontrol.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,10 @@ void RateControl::notifyWrapAround(mixxx::audio::FramePos triggerPos,
628628
void RateControl::notifySeek(mixxx::audio::FramePos position) {
629629
m_pScratchController->notifySeek(position);
630630
}
631+
632+
void RateControl::resetPositionScratchController() {
633+
// Resets the scratch state to avoid engine freeze due to insanley high rate
634+
// reported on track load while scratching.
635+
// https://github.com/mixxxdj/mixxx/issues/15082
636+
m_pScratchController->reset();
637+
}

src/engine/controls/ratecontrol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class RateControl : public EngineControl {
7777
void notifyWrapAround(mixxx::audio::FramePos triggerPos,
7878
mixxx::audio::FramePos targetPos);
7979
void notifySeek(mixxx::audio::FramePos position) override;
80+
void resetPositionScratchController();
8081

8182
public slots:
8283
void slotRateRangeChanged(double);

src/engine/enginebuffer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,19 @@ void EngineBuffer::ejectTrack() {
627627

628628
if (pOldTrack) {
629629
notifyTrackLoaded(TrackPointer(), pOldTrack);
630+
} else {
631+
// When not invoking notifyTrackLoaded() call this separately
632+
m_pRateControl->resetPositionScratchController();
630633
}
634+
631635
m_iTrackLoading = 0;
632636
m_pChannelToCloneFrom = nullptr;
633637
}
634638

635639
void EngineBuffer::notifyTrackLoaded(
636640
TrackPointer pNewTrack, TrackPointer pOldTrack) {
641+
m_pRateControl->resetPositionScratchController();
642+
637643
if (pOldTrack) {
638644
disconnect(
639645
pOldTrack.get(),

src/engine/positionscratchcontroller.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,13 @@ void PositionScratchController::notifySeek(mixxx::audio::FramePos position) {
329329
// distance traveled in m_samplePosDeltaSum
330330
m_seekSamplePos = newPos;
331331
}
332+
333+
void PositionScratchController::reset() {
334+
// Resets the scratch state to avoid engine freeze due to insanley high rate
335+
// reported on track load while scratching.
336+
// https://github.com/mixxxdj/mixxx/issues/15082
337+
m_pScratchEnable->set(0.0);
338+
m_isScratching = false;
339+
m_inertiaEnabled = false;
340+
m_rate = 0;
341+
}

src/engine/positionscratchcontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class PositionScratchController : public QObject {
3333
return m_rate;
3434
}
3535
void notifySeek(mixxx::audio::FramePos position);
36+
void reset();
3637

3738
private slots:
3839
void slotUpdateFilterParameters(double sampleRate);

0 commit comments

Comments
 (0)