diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-12-02 21:11:43 +0100 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-12-02 21:11:43 +0100 |
commit | b207bd38e1574cb75315a2c66e7a598c22fc55ca (patch) | |
tree | 05b3a58ac8261e1f43a944018e48c15171032052 /src/engine | |
parent | 8e18359de7cfc2521045671007ec6115c150dd55 (diff) | |
parent | 532b713e0e570083c8ecd5708942cacb66835838 (diff) |
Merge branch '2.3' of github.com:mixxxdj/mixxx into cleanup-headers
Diffstat (limited to 'src/engine')
53 files changed, 735 insertions, 515 deletions
diff --git a/src/engine/cachingreader/cachingreader.cpp b/src/engine/cachingreader/cachingreader.cpp index d7332eb27c..592371a686 100644 --- a/src/engine/cachingreader/cachingreader.cpp +++ b/src/engine/cachingreader/cachingreader.cpp @@ -40,7 +40,7 @@ const SINT kNumberOfCachedChunksInMemory = 80; } // anonymous namespace -CachingReader::CachingReader(QString group, +CachingReader::CachingReader(const QString& group, UserSettingsPointer config) : m_pConfig(config), // Limit the number of in-flight requests to the worker. This should diff --git a/src/engine/cachingreader/cachingreader.h b/src/engine/cachingreader/cachingreader.h index b46f817877..c5f5a6ee32 100644 --- a/src/engine/cachingreader/cachingreader.h +++ b/src/engine/cachingreader/cachingreader.h @@ -72,8 +72,8 @@ class CachingReader : public QObject { public: // Construct a CachingReader with the given group. - CachingReader(QString group, - UserSettingsPointer _config); + CachingReader(const QString& group, + UserSettingsPointer _config); ~CachingReader() override; void process(); @@ -112,7 +112,7 @@ class CachingReader : public QObject { // Emitted once a new track is loaded and ready to be read from. void trackLoading(); void trackLoaded(TrackPointer pTrack, int iSampleRate, int iNumSamples); - void trackLoadFailed(TrackPointer pTrack, QString reason); + void trackLoadFailed(TrackPointer pTrack, const QString& reason); private: const UserSettingsPointer m_pConfig; diff --git a/src/engine/cachingreader/cachingreaderworker.cpp b/src/engine/cachingreader/cachingreaderworker.cpp index ae5b9d8256..aefd482d04 100644 --- a/src/engine/cachingreader/cachingreaderworker.cpp +++ b/src/engine/cachingreader/cachingreaderworker.cpp @@ -18,7 +18,7 @@ mixxx::Logger kLogger("CachingReaderWorker"); } // anonymous namespace CachingReaderWorker::CachingReaderWorker( - QString group, + const QString& group, FIFO<CachingReaderChunkReadRequest>* pChunkReadRequestFIFO, FIFO<ReaderStatusUpdate>* pReaderStatusFIFO) : m_group(group), diff --git a/src/engine/cachingreader/cachingreaderworker.h b/src/engine/cachingreader/cachingreaderworker.h index 78b36dd396..09801eebb8 100644 --- a/src/engine/cachingreader/cachingreaderworker.h +++ b/src/engine/cachingreader/cachingreaderworker.h @@ -96,7 +96,7 @@ class CachingReaderWorker : public EngineWorker { public: // Construct a CachingReader with the given group. - CachingReaderWorker(QString group, + CachingReaderWorker(const QString& group, FIFO<CachingReaderChunkReadRequest>* pChunkReadRequestFIFO, FIFO<ReaderStatusUpdate>* pReaderStatusFIFO); ~CachingReaderWorker() override = default; @@ -114,7 +114,7 @@ class CachingReaderWorker : public EngineWorker { // Emitted once a new track is loaded and ready to be read from. void trackLoading(); void trackLoaded(TrackPointer pTrack, int iSampleRate, int iNumSamples); - void trackLoadFailed(TrackPointer pTrack, QString reason); + void trackLoadFailed(TrackPointer pTrack, const QString& reason); private: const QString m_group; diff --git a/src/engine/channels/engineaux.cpp b/src/engine/channels/engineaux.cpp index 08748e71a7..ecba74bc13 100644 --- a/src/engine/channels/engineaux.cpp +++ b/src/engine/channels/engineaux.cpp @@ -42,7 +42,7 @@ bool EngineAux::isActive() { return m_wasActive; } -void EngineAux::onInputConfigured(AudioInput input) { +void EngineAux::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::AUXILIARY) { // This is an error! qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!"; @@ -52,7 +52,7 @@ void EngineAux::onInputConfigured(AudioInput input) { m_pInputConfigured->forceSet(1.0); } -void EngineAux::onInputUnconfigured(AudioInput input) { +void EngineAux::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::AUXILIARY) { // This is an error! qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!"; @@ -62,8 +62,8 @@ void EngineAux::onInputUnconfigured(AudioInput input) { m_pInputConfigured->forceSet(0.0); } -void EngineAux::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames) { +void EngineAux::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); m_sampleBuffer = pBuffer; diff --git a/src/engine/channels/engineaux.h b/src/engine/channels/engineaux.h index 296055e1f3..2362c32c0d 100644 --- a/src/engine/channels/engineaux.h +++ b/src/engine/channels/engineaux.h @@ -30,16 +30,17 @@ class EngineAux : public EngineChannel, public AudioDestination { /// the soundcard this AudioDestination was registered for! Beware, in the /// case of multiple soundcards, this method is not re-entrant but it may be /// concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int nFrames); /// Called by SoundManager whenever the aux input is connected to a /// soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); /// Called by SoundManager whenever the aux input is disconnected from /// a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); private: QScopedPointer<ControlObject> m_pInputConfigured; diff --git a/src/engine/channels/enginedeck.cpp b/src/engine/channels/enginedeck.cpp index 27431078c6..8eeb3d1bad 100644 --- a/src/engine/channels/enginedeck.cpp +++ b/src/engine/channels/enginedeck.cpp @@ -131,7 +131,8 @@ bool EngineDeck::isActive() { return active; } -void EngineDeck::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, unsigned int nFrames) { +void EngineDeck::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); // Skip receiving audio input if passthrough is not active @@ -143,7 +144,7 @@ void EngineDeck::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, unsigne } } -void EngineDeck::onInputConfigured(AudioInput input) { +void EngineDeck::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::VINYLCONTROL) { // This is an error! qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!"; @@ -153,7 +154,7 @@ void EngineDeck::onInputConfigured(AudioInput input) { m_sampleBuffer = NULL; } -void EngineDeck::onInputUnconfigured(AudioInput input) { +void EngineDeck::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::VINYLCONTROL) { // This is an error! qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!"; diff --git a/src/engine/channels/enginedeck.h b/src/engine/channels/enginedeck.h index f571dadb38..cc0006c9c7 100644 --- a/src/engine/channels/enginedeck.h +++ b/src/engine/channels/enginedeck.h @@ -62,16 +62,17 @@ class EngineDeck : public EngineChannel, public AudioDestination { // the soundcard this AudioDestination was registered for! Beware, in the // case of multiple soundcards, this method is not re-entrant but it may be // concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int nFrames); // Called by SoundManager whenever the passthrough input is connected to a // soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); // Called by SoundManager whenever the passthrough input is disconnected // from a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); // Return whether or not passthrough is active bool isPassthroughActive() const; diff --git a/src/engine/channels/enginemicrophone.cpp b/src/engine/channels/enginemicrophone.cpp index 0e22b88d7d..884c5633d1 100644 --- a/src/engine/channels/enginemicrophone.cpp +++ b/src/engine/channels/enginemicrophone.cpp @@ -40,7 +40,7 @@ bool EngineMicrophone::isActive() { return m_wasActive; } -void EngineMicrophone::onInputConfigured(AudioInput input) { +void EngineMicrophone::onInputConfigured(const AudioInput& input) { if (input.getType() != AudioPath::MICROPHONE) { // This is an error! qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!"; @@ -50,7 +50,7 @@ void EngineMicrophone::onInputConfigured(AudioInput input) { m_pInputConfigured->forceSet(1.0); } -void EngineMicrophone::onInputUnconfigured(AudioInput input) { +void EngineMicrophone::onInputUnconfigured(const AudioInput& input) { if (input.getType() != AudioPath::MICROPHONE) { // This is an error! qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!"; @@ -60,8 +60,8 @@ void EngineMicrophone::onInputUnconfigured(AudioInput input) { m_pInputConfigured->forceSet(0.0); } -void EngineMicrophone::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int nFrames) { +void EngineMicrophone::receiveBuffer( + const AudioInput& input, const CSAMPLE* pBuffer, unsigned int nFrames) { Q_UNUSED(input); Q_UNUSED(nFrames); m_sampleBuffer = pBuffer; diff --git a/src/engine/channels/enginemicrophone.h b/src/engine/channels/enginemicrophone.h index e5190dc72f..b9611e7cb8 100644 --- a/src/engine/channels/enginemicrophone.h +++ b/src/engine/channels/enginemicrophone.h @@ -34,16 +34,17 @@ class EngineMicrophone : public EngineChannel, public AudioDestination { // the soundcard this AudioDestination was registered for! Beware, in the // case of multiple soundcards, this method is not re-entrant but it may be // concurrent with EngineMaster processing. - virtual void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer, - unsigned int iNumSamples); + virtual void receiveBuffer(const AudioInput& input, + const CSAMPLE* pBuffer, + unsigned int iNumSamples); // Called by SoundManager whenever the microphone input is connected to a // soundcard input. - virtual void onInputConfigured(AudioInput input); + virtual void onInputConfigured(const AudioInput& input); // Called by SoundManager whenever the microphone input is disconnected from // a soundcard input. - virtual void onInputUnconfigured(AudioInput input); + virtual void onInputUnconfigured(const AudioInput& input); bool isSolo(); double getSoloDamping(); diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index 20285ca89f..52370da16d 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -40,7 +40,7 @@ constexpr int kLocalBpmSpan = 4; constexpr SINT kSamplesPerFrame = 2; } -BpmControl::BpmControl(QString group, +BpmControl::BpmControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_tapFilter(this, kBpmTapFilterLength, kBpmTapMaxInterval), diff --git a/src/engine/controls/bpmcontrol.h b/src/engine/controls/bpmcontrol.h index 4257595dc5..156fdca700 100644 --- a/src/engine/controls/bpmcontrol.h +++ b/src/engine/controls/bpmcontrol.h @@ -22,7 +22,7 @@ class BpmControl : public EngineControl { Q_OBJECT public: - BpmControl(QString group, UserSettingsPointer pConfig); + BpmControl(const QString& group, UserSettingsPointer pConfig); ~BpmControl() override; double getBpm() const; diff --git a/src/engine/controls/clockcontrol.cpp b/src/engine/controls/clockcontrol.cpp index 2a374aa1b4..f48660bb4c 100644 --- a/src/engine/controls/clockcontrol.cpp +++ b/src/engine/controls/clockcontrol.cpp @@ -6,7 +6,7 @@ #include "preferences/usersettings.h" #include "track/track.h" -ClockControl::ClockControl(QString group, UserSettingsPointer pConfig) +ClockControl::ClockControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig) { m_pCOBeatActive = new ControlObject(ConfigKey(group, "beat_active")); m_pCOBeatActive->set(0.0); diff --git a/src/engine/controls/clockcontrol.h b/src/engine/controls/clockcontrol.h index 1a26d30d8c..87667db443 100644 --- a/src/engine/controls/clockcontrol.h +++ b/src/engine/controls/clockcontrol.h @@ -11,8 +11,8 @@ class ControlObject; class ClockControl: public EngineControl { Q_OBJECT public: - ClockControl(QString group, - UserSettingsPointer pConfig); + ClockControl(const QString& group, + UserSettingsPointer pConfig); ~ClockControl() override; diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 3a92609105..f8ac0c8e20 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -26,6 +26,7 @@ constexpr double CUE_MODE_CUP = 5.0; /// This is the position of a fresh loaded tack without any seek constexpr double kDefaultLoadPosition = 0.0; +constexpr int kNoHotCueNumber = 0; // Helper function to convert control values (i.e. doubles) into RgbColor // instances (or nullopt if value < 0). This happens by using the integer @@ -41,9 +42,37 @@ inline mixxx::RgbColor::optional_t doubleToRgbColor(double value) { return mixxx::RgbColor::optional(colorCode); } +/// Convert hot cue index to 1-based number +/// +/// Works independent of if the hot cue index is either 0-based +/// or 1..n-based. +inline int hotcueIndexToHotcueNumber(int hotcueIndex) { + if (hotcueIndex >= Cue::kFirstHotCue) { + DEBUG_ASSERT(hotcueIndex != Cue::kNoHotCue); + return (hotcueIndex - Cue::kFirstHotCue) + 1; // to 1-based numbering + } else { + DEBUG_ASSERT(hotcueIndex == Cue::kNoHotCue); + return kNoHotCueNumber; + } +} + +/// Convert 1-based hot cue number to hot cue index. +/// +/// Works independent of if the hot cue index is either 0-based +/// or 1..n-based. +inline int hotcueNumberToHotcueIndex(int hotcueNumber) { + if (hotcueNumber >= 1) { + DEBUG_ASSERT(hotcueNumber != kNoHotCueNumber); + return Cue::kFirstHotCue + (hotcueNumber - 1); // from 1-based numbering + } else { + DEBUG_ASSERT(hotcueNumber == kNoHotCueNumber); + return Cue::kNoHotCue; + } +} + } // namespace -CueControl::CueControl(QString group, +CueControl::CueControl(const QString& group, UserSettingsPointer pConfig) : EngineControl(group, pConfig), m_pConfig(pConfig), @@ -132,6 +161,9 @@ CueControl::CueControl(QString group, m_pCueIndicator = new ControlIndicator(ConfigKey(group, "cue_indicator")); m_pPlayIndicator = new ControlIndicator(ConfigKey(group, "play_indicator")); + m_pPlayLatched = new ControlObject(ConfigKey(group, "play_latched")); + m_pPlayLatched->setReadOnly(); + m_pIntroStartPosition = new ControlObject(ConfigKey(group, "intro_start_position")); m_pIntroStartPosition->set(Cue::kNoPosition); @@ -220,7 +252,7 @@ CueControl::CueControl(QString group, m_pVinylControlMode = new ControlProxy(group, "vinylcontrol_mode"); m_pHotcueFocus = new ControlObject(ConfigKey(group, "hotcue_focus")); - m_pHotcueFocus->set(Cue::kNoHotCue); + setHotcueFocusIndex(Cue::kNoHotCue); m_pHotcueFocusColorPrev = new ControlObject(ConfigKey(group, "hotcue_focus_color_prev")); connect(m_pHotcueFocusColorPrev, @@ -252,6 +284,7 @@ CueControl::~CueControl() { delete m_pPlayStutter; delete m_pCueIndicator; delete m_pPlayIndicator; + delete m_pPlayLatched; delete m_pIntroStartPosition; delete m_pIntroStartEnabled; delete m_pIntroStartSet; @@ -313,7 +346,7 @@ void CueControl::createControls() { } } -void CueControl::attachCue(CuePointer pCue, HotcueControl* pControl) { +void CueControl::attachCue(const CuePointer& pCue, HotcueControl* pControl) { VERIFY_OR_DEBUG_ASSERT(pControl) { return; } @@ -355,7 +388,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) { m_pOutroStartEnabled->forceSet(0.0); m_pOutroEndPosition->set(Cue::kNoPosition); m_pOutroEndEnabled->forceSet(0.0); - m_pHotcueFocus->set(Cue::kNoHotCue); + setHotcueFocusIndex(Cue::kNoHotCue); m_pLoadedTrack.reset(); m_usedSeekOnLoadPosition.setValue(kDefaultLoadPosition); } @@ -644,15 +677,16 @@ void CueControl::quantizeChanged(double v) { void CueControl::hotcueSet(HotcueControl* pControl, double value) { //qDebug() << "CueControl::hotcueSet" << value; - if (value == 0) { + if (value <= 0) { return; } QMutexLocker lock(&m_mutex); - if (!m_pLoadedTrack) + if (!m_pLoadedTrack) { return; + } - int hotcue = pControl->getHotcueNumber(); + int hotcueIndex = pControl->getHotcueIndex(); // Note: the cue is just detached from the hotcue control // It remains in the database for later use // TODO: find a rule, that allows us to delete the cue as well @@ -662,14 +696,14 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) { CuePointer pCue(m_pLoadedTrack->createAndAddCue()); double cuePosition = getQuantizedCurrentPosition(); pCue->setStartPosition(cuePosition); - pCue->setHotCue(hotcue); + pCue->setHotCue(hotcueIndex); pCue->setLabel(); pCue->setType(mixxx::CueType::HotCue); const ColorPalette hotcueColorPalette = m_colorPaletteSettings.getHotcueColorPalette(); if (getConfig()->getValue(ConfigKey("[Controls]", "auto_hotcue_colors"), false)) { - pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcue)); + pCue->setColor(hotcueColorPalette.colorForHotcueIndex(hotcueIndex)); } else { int hotcueDefaultColorIndex = m_pConfig->getValue(ConfigKey("[Controls]", "HotcueDefaultColorIndex"), -1); if (hotcueDefaultColorIndex < 0 || hotcueDefaultColorIndex >= hotcueColorPalette.size()) { @@ -693,7 +727,7 @@ void CueControl::hotcueSet(HotcueControl* pControl, double value) { } void CueControl::hotcueGoto(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -716,7 +750,7 @@ void CueControl::hotcueGoto(HotcueControl* pControl, double value) { } void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -732,14 +766,19 @@ void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) { if (pCue) { double position = pCue->getPosition(); if (position != Cue::kNoPosition) { - m_pPlay->set(0.0); - seekExact(position); + if (!m_iCurrentlyPreviewingHotcues && !m_bPreviewing) { + m_pPlay->set(0.0); + seekExact(position); + } else { + // this becomes a play latch command if we are previewing + m_pPlay->set(0.0); + } } } } void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double value) { - if (value == 0) { + if (value <= 0) { return; } @@ -784,7 +823,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { lock.unlock(); if (pCue) { - if (value != 0) { + if (value > 0) { if (pCue->getPosition() == Cue::kNoPosition) { hotcueSet(pControl, value); } else { @@ -801,7 +840,7 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double value) { }< |