Skip to content

Commit

Permalink
engine/controls: Remove superfluous notifySeek implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
xeruf committed Aug 19, 2020
1 parent a90062c commit 5299a8c
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 102 deletions.
5 changes: 0 additions & 5 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,6 @@ void BpmControl::slotUpdateRateSlider(double value) {
m_pRateRatio->set(dRateRatio);
}

void BpmControl::notifySeek(double dNewPlaypos) {
EngineControl::notifySeek(dNewPlaypos);
updateBeatDistance();
}

// called from an engine worker thread
void BpmControl::trackLoaded(TrackPointer pNewTrack) {
mixxx::BeatsPointer pBeats;
Expand Down
1 change: 0 additions & 1 deletion src/engine/controls/bpmcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class BpmControl : public EngineControl {
static double shortestPercentageChange(const double& current_percentage,
const double& target_percentage);
double getRateRatio() const;
void notifySeek(double dNewPlaypos) override;
void trackLoaded(TrackPointer pNewTrack) override;
void trackBeatsUpdated(mixxx::BeatsPointer pBeats) override;

Expand Down
10 changes: 3 additions & 7 deletions src/engine/controls/enginecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void EngineControl::setEngineBuffer(EngineBuffer* pEngineBuffer) {
}

void EngineControl::setCurrentSample(
const double dCurrentSample, const double dTotalSamples, const double dTrackSampleRate) {
const double dCurrentSample,
const double dTotalSamples,
const double dTrackSampleRate) {
SampleOfTrack sot;
sot.current = dCurrentSample;
sot.total = dTotalSamples;
Expand Down Expand Up @@ -89,12 +91,6 @@ void EngineControl::seek(double sample) {
}
}

void EngineControl::notifySeek(double dNewPlaypos) {
SampleOfTrack sot = m_sampleOfTrack.getValue();
sot.current = dNewPlaypos;
m_sampleOfTrack.setValue(sot);
}

EngineBuffer* EngineControl::pickSyncTarget() {
EngineMaster* pMaster = getEngineMaster();
if (!pMaster) {
Expand Down
94 changes: 48 additions & 46 deletions src/engine/controls/enginecontrol.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// enginecontrol.h
// Created 7/5/2009 by RJ Ryan ([email protected])

#ifndef ENGINECONTROL_H
#define ENGINECONTROL_H
#pragma once

#include <gtest/gtest_prod.h>

Expand All @@ -21,54 +17,62 @@ class EngineBuffer;

const int kNoTrigger = -1;

/**
* EngineControl is an abstract base class for objects which implement
* functionality pertaining to EngineBuffer. An EngineControl is meant to be a
* succinct implementation of a given EngineBuffer feature. Previously,
* EngineBuffer was an example of feature creep -- this is the result.
*
* When writing an EngineControl class, the following two properties hold:
*
* EngineControl::process will only be called during an EngineBuffer::process
* callback from the sound engine. This implies that any ControlObject accesses
* made in either of these methods are mutually exclusive, since one is
* exclusively in the call graph of the other.
*/
/// EngineControl is an abstract base class for objects which implement
/// functionality pertaining to EngineBuffer. An EngineControl is meant to be a
/// succinct implementation of a given EngineBuffer feature.
class EngineControl : public QObject {
Q_OBJECT
public:
EngineControl(QString group,
UserSettingsPointer pConfig);
~EngineControl() override;

// Called by EngineBuffer::process every latency period. See the above
// comments for information about guarantees that hold during this call. An
// EngineControl can perform any upkeep operations that are necessary during
// this call.
virtual void process(const double dRate,
const double dCurrentSample,
const int iBufferSize);

// hintReader allows the EngineControl to provide hints to the reader to
// indicate that the given portion of a song is a potential imminent seek
// target.
virtual void hintReader(HintVector* pHintList);
EngineControl(QString group, UserSettingsPointer pConfig);
QString getGroup() const;

virtual void setEngineMaster(EngineMaster* pEngineMaster);
void setEngineBuffer(EngineBuffer* pEngineBuffer);
virtual void setCurrentSample(const double dCurrentSample,
const double dTotalSamples, const double dTrackSampleRate);
QString getGroup() const;

// Called to collect player features for effects processing.
virtual void setCurrentSample(
const double dCurrentSample,
const double dTotalSamples,
const double dTrackSampleRate);

/// Called whenever a seek occurs to allow the EngineControl to respond.
virtual void notifySeek(double dNewPlaypos) {
Q_UNUSED(dNewPlaypos);
};

/// Called by EngineBuffer::process every latency period. An EngineControl
/// can perform any necessary upkeep operations during this call.
///
/// EngineControl::process will only be called during an
/// EngineBuffer::process callback from the sound engine. This implies that
/// any ControlObject accesses made in either of these methods are mutually
/// exclusive, since one is exclusively in the call graph of the other.
virtual void process(
const double dRate,
const double dCurrentSample,
const int iBufferSize) {
Q_UNUSED(dRate);
Q_UNUSED(dCurrentSample);
Q_UNUSED(iBufferSize);
};

/// Called to collect player features for effects processing
virtual void collectFeatureState(GroupFeatureState* pGroupFeatures) const {
Q_UNUSED(pGroupFeatures);
}

// Called whenever a seek occurs to allow the EngineControl to respond.
virtual void notifySeek(double dNewPlaypos);
virtual void trackLoaded(TrackPointer pNewTrack);
virtual void trackBeatsUpdated(mixxx::BeatsPointer pBeats);
virtual void trackLoaded(TrackPointer pNewTrack) {
Q_UNUSED(pNewTrack);
}
virtual void trackBeatsUpdated(mixxx::BeatsPointer pBeats) {
Q_UNUSED(pBeats);
}

/// hintReader allows the EngineControl to provide hints to the reader to
/// indicate that the given portion of a song is a potential imminent seek
/// target.
virtual void hintReader(HintVector* pHintList) {
Q_UNUSED(pHintList);
};

protected:
struct SampleOfTrack {
Expand All @@ -82,9 +86,9 @@ class EngineControl : public QObject {
}
void seek(double fractionalPosition);
void seekAbs(double sample);
// Seek to an exact sample and don't allow quantizing adjustment.
/// Seek to an exact sample and don't allow quantizing adjustment.
void seekExact(double sample);
// Returns an EngineBuffer to target for syncing. Returns nullptr if none found
/// Returns an EngineBuffer to target for syncing. Returns nullptr if none found
EngineBuffer* pickSyncTarget();

UserSettingsPointer getConfig();
Expand All @@ -108,5 +112,3 @@ class EngineControl : public QObject {
FRIEND_TEST(LoopingControlTest, LoopResizeSeek);
FRIEND_TEST(LoopingControlTest, Beatjump_JumpsByBeats);
};

#endif /* ENGINECONTROL_H */
1 change: 0 additions & 1 deletion src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ void LoopingControl::notifySeek(double dNewPlaypos) {
setLoopingEnabled(false);
}
}
EngineControl::notifySeek(dNewPlaypos);
}

void LoopingControl::setLoopingEnabled(bool enabled) {
Expand Down
5 changes: 0 additions & 5 deletions src/engine/controls/quantizecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ void QuantizeControl::setCurrentSample(const double dCurrentSample,
playPosChanged(dCurrentSample);
}

void QuantizeControl::notifySeek(double dNewPlaypos) {
EngineControl::notifySeek(dNewPlaypos);
playPosChanged(dNewPlaypos);
}

void QuantizeControl::playPosChanged(double dNewPlaypos) {
// We only need to update the prev or next if the current sample is
// out of range of the existing beat positions or if we've been forced to
Expand Down
7 changes: 4 additions & 3 deletions src/engine/controls/quantizecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class QuantizeControl : public EngineControl {
QuantizeControl(QString group, UserSettingsPointer pConfig);
~QuantizeControl() override;

void setCurrentSample(const double dCurrentSample,
const double dTotalSamples, const double dTrackSampleRate) override;
void notifySeek(double dNewPlaypos) override;
void setCurrentSample(
const double dCurrentSample,
const double dTotalSamples,
const double dTrackSampleRate) override;
void trackLoaded(TrackPointer pNewTrack) override;
void trackBeatsUpdated(mixxx::BeatsPointer pBeats) override;

Expand Down
5 changes: 0 additions & 5 deletions src/engine/controls/ratecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,6 @@ void RateControl::resetRateTemp(void)
setRateTemp(0.0);
}

void RateControl::notifySeek(double playPos) {
m_pScratchController->notifySeek(playPos);
EngineControl::notifySeek(playPos);
}

bool RateControl::isReverseButtonPressed() {
if (m_pReverseButton) {
return m_pReverseButton->toBool();
Expand Down
1 change: 0 additions & 1 deletion src/engine/controls/ratecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class RateControl : public EngineControl {
// Set Rate Ramp Sensitivity
static void setRateRampSensitivity(int);
static int getRateRampSensitivity();
void notifySeek(double dNewPlaypos) override;
bool isReverseButtonPressed();

public slots:
Expand Down
6 changes: 0 additions & 6 deletions src/engine/positionscratchcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,3 @@ bool PositionScratchController::isEnabled() {
double PositionScratchController::getRate() {
return m_dRate;
}

void PositionScratchController::notifySeek(double currentSample) {
// scratching continues after seek due to calculating the relative distance traveled
// in m_dPositionDeltaSum
m_dLastPlaypos = currentSample;
}
1 change: 0 additions & 1 deletion src/engine/positionscratchcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class PositionScratchController : public QObject {
int iBufferSize, double baserate);
bool isEnabled();
double getRate();
void notifySeek(double currentSample);

private:
const QString m_group;
Expand Down
7 changes: 0 additions & 7 deletions src/engine/sync/synccontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,6 @@ void SyncControl::reportPlayerSpeed(double speed, bool scratching) {
m_pEngineSync->notifyInstantaneousBpmChanged(this, instantaneous_bpm);
}

void SyncControl::notifySeek(double dNewPlaypos) {
// qDebug() << "SyncControl::notifySeek" << dNewPlaypos;
EngineControl::notifySeek(dNewPlaypos);
m_pBpmControl->notifySeek(dNewPlaypos);
updateTargetBeatDistance();
}

double SyncControl::fileBpm() const {
mixxx::BeatsPointer pBeats = m_pBeats;
if (pBeats) {
Expand Down
1 change: 0 additions & 1 deletion src/engine/sync/synccontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class SyncControl : public EngineControl, public Syncable {

void reportTrackPosition(double fractionalPlaypos);
void reportPlayerSpeed(double speed, bool scratching);
void notifySeek(double dNewPlaypos) override;
void trackLoaded(TrackPointer pNewTrack) override;
void trackBeatsUpdated(mixxx::BeatsPointer pBeats) override;

Expand Down
13 changes: 0 additions & 13 deletions src/test/readaheadmanager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ class StubLoopControl : public LoopingControl {
return m_triggerReturnValues.takeFirst();
}

// hintReader has no effect in this stubbed class
void hintReader(HintVector* pHintList) override {
Q_UNUSED(pHintList);
}

void notifySeek(double dNewPlaypos) override {
Q_UNUSED(dNewPlaypos);
}

void trackLoaded(TrackPointer pTrack) override {
Q_UNUSED(pTrack);
}

protected:
QList<double> m_triggerReturnValues;
QList<double> m_targetReturnValues;
Expand Down

0 comments on commit 5299a8c

Please sign in to comment.