Skip to content

Commit 604b32c

Browse files
Merge pull request #15614 from mixxxdj/sync-branch-2.6-to-main
Merge changes from `2.6` into `main`
2 parents 4531cb0 + 62e3db0 commit 604b32c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/engine/positionscratchcontroller.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "engine/positionscratchcontroller.h"
22

3+
#include "audio/frame.h"
34
#include "control/controlobject.h"
45
#include "control/controlproxy.h"
56
#include "engine/bufferscalers/enginebufferscale.h" // for MIN_SEEK_SPEED
@@ -95,9 +96,7 @@ PositionScratchController::PositionScratchController(const QString& group)
9596
m_isScratching(false),
9697
m_inertiaEnabled(false),
9798
m_prevSamplePos(0),
98-
// TODO we might as well use FramePos in order to use more convenient
99-
// mixxx::audio::kInvalidFramePos, then convert to sample pos on the fly
100-
m_seekSamplePos(std::numeric_limits<double>::quiet_NaN()),
99+
m_seekFramePos(mixxx::audio::kInvalidFramePos),
101100
m_samplePosDeltaSum(0),
102101
m_scratchTargetDelta(0),
103102
m_scratchStartPos(0),
@@ -314,20 +313,19 @@ void PositionScratchController::process(double currentSamplePos,
314313
// qDebug() << "scratchEnable()" << currentSamplePos;
315314
}
316315

317-
if (!util_isnan(m_seekSamplePos)) {
316+
if (!m_seekFramePos.isValid()) {
318317
// We need to transpose all buffers to compensate the seek
319318
// in a way that the next process call does not even notice anything
320-
currentSamplePos = m_seekSamplePos;
321-
m_seekSamplePos = std::numeric_limits<double>::quiet_NaN();
319+
currentSamplePos = m_seekFramePos.toEngineSamplePos();
320+
m_seekFramePos = mixxx::audio::kInvalidFramePos;
322321
}
323322
m_prevSamplePos = currentSamplePos;
324323
}
325324

326325
void PositionScratchController::notifySeek(mixxx::audio::FramePos position) {
327-
const double newPos = position.toEngineSamplePos();
328326
// Scratching continues after seek due to calculating the relative
329327
// distance traveled in m_samplePosDeltaSum
330-
m_seekSamplePos = newPos;
328+
m_seekFramePos = position;
331329
}
332330

333331
void PositionScratchController::reset() {

src/engine/positionscratchcontroller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PositionScratchController : public QObject {
4848
bool m_isScratching;
4949
bool m_inertiaEnabled;
5050
double m_prevSamplePos;
51-
double m_seekSamplePos;
51+
mixxx::audio::FramePos m_seekFramePos;
5252
double m_samplePosDeltaSum;
5353
double m_scratchTargetDelta;
5454
double m_scratchStartPos;

0 commit comments

Comments
 (0)