Skip to content

Commit

Permalink
CueControl: dis/reconnect cue controls when passthrough is toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jul 4, 2022
1 parent 98a4c93 commit b7be713
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControlProxy>(group, "passthrough");
m_pPassthrough->connectValueChanged(this,
&CueControl::passthroughChanged,
Qt::DirectConnection);
}

CueControl::~CueControl() {
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/engine/controls/cuecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -351,6 +354,8 @@ class CueControl : public EngineControl {
ControlObject* m_pHotcueFocusColorNext;
ControlObject* m_pHotcueFocusColorPrev;

parented_ptr<ControlProxy> m_pPassthrough;

QAtomicPointer<HotcueControl> m_pCurrentSavedLoopControl;

// Tells us which controls map to which hotcue
Expand Down

0 comments on commit b7be713

Please sign in to comment.