From b7be7138026fbbbbfc918e41ad3af0f4a8db9866 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Sat, 2 Jul 2022 22:32:38 +0200 Subject: [PATCH] CueControl: dis/reconnect cue controls when passthrough is toggled --- src/engine/controls/cuecontrol.cpp | 51 ++++++++++++++++++++++++++++++ src/engine/controls/cuecontrol.h | 5 +++ 2 files changed, 56 insertions(+) diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 87912cccfbd..ce65c3c5994 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -125,6 +125,11 @@ CueControl::CueControl(const QString& group, m_pCuePoint->set(Cue::kNoPosition); m_pCueMode = new ControlObject(ConfigKey(group, "cue_mode")); + + m_pPassthrough = make_parented(group, "passthrough"); + m_pPassthrough->connectValueChanged(this, + &CueControl::passthroughChanged, + Qt::DirectConnection); } CueControl::~CueControl() { @@ -420,6 +425,52 @@ void CueControl::connectControls() { } } +void CueControl::disconnectControls() { + disconnect(m_pCueSet, nullptr, this, nullptr); + disconnect(m_pCueClear, nullptr, this, nullptr); + disconnect(m_pCueGoto, nullptr, this, nullptr); + disconnect(m_pCueGotoAndPlay, nullptr, this, nullptr); + disconnect(m_pCuePlay, nullptr, this, nullptr); + disconnect(m_pCueGotoAndStop, nullptr, this, nullptr); + disconnect(m_pCuePreview, nullptr, this, nullptr); + disconnect(m_pCueCDJ, nullptr, this, nullptr); + disconnect(m_pCueDefault, nullptr, this, nullptr); + disconnect(m_pPlayStutter, nullptr, this, nullptr); + + disconnect(m_pIntroStartSet, nullptr, this, nullptr); + disconnect(m_pIntroStartClear, nullptr, this, nullptr); + disconnect(m_pIntroStartActivate, nullptr, this, nullptr); + disconnect(m_pIntroEndSet, nullptr, this, nullptr); + disconnect(m_pIntroEndClear, nullptr, this, nullptr); + disconnect(m_pIntroEndActivate, nullptr, this, nullptr); + + disconnect(m_pOutroStartSet, nullptr, this, nullptr); + disconnect(m_pOutroStartClear, nullptr, this, nullptr); + disconnect(m_pOutroStartActivate, nullptr, this, nullptr); + disconnect(m_pOutroEndSet, nullptr, this, nullptr); + disconnect(m_pOutroEndClear, nullptr, this, nullptr); + disconnect(m_pOutroEndActivate, nullptr, this, nullptr); + + disconnect(m_pHotcueFocusColorPrev, nullptr, this, nullptr); + disconnect(m_pHotcueFocusColorNext, nullptr, this, nullptr); + + for (const auto& pControl : qAsConst(m_hotcueControls)) { + disconnect(pControl, nullptr, this, nullptr); + } +} + +void CueControl::passthroughChanged(double enabled) { + if (enabled > 0) { + // If passthrough was enabled seeking and playing is prohibited, and the + // waveform and overview are blocked. + // Disconnect all cue controls to prevent cue changes without UI feedback. + disconnectControls(); + } else { + // Reconnect all controls when deck returns to regular mode. + connectControls(); + } +} + void CueControl::attachCue(const CuePointer& pCue, HotcueControl* pControl) { VERIFY_OR_DEBUG_ASSERT(pControl) { return; diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h index e1076748d64..a8355c20e3c 100644 --- a/src/engine/controls/cuecontrol.h +++ b/src/engine/controls/cuecontrol.h @@ -235,6 +235,8 @@ class CueControl : public EngineControl { void hotcueFocusColorNext(double v); void hotcueFocusColorPrev(double v); + void passthroughChanged(double v); + void cueSet(double v); void cueClear(double v); void cueGoto(double v); @@ -273,6 +275,7 @@ class CueControl : public EngineControl { // These methods are not thread safe, only call them when the lock is held. void createControls(); void connectControls(); + void disconnectControls(); void attachCue(const CuePointer& pCue, HotcueControl* pControl); void detachCue(HotcueControl* pControl); @@ -351,6 +354,8 @@ class CueControl : public EngineControl { ControlObject* m_pHotcueFocusColorNext; ControlObject* m_pHotcueFocusColorPrev; + parented_ptr m_pPassthrough; + QAtomicPointer m_pCurrentSavedLoopControl; // Tells us which controls map to which hotcue