Skip to content

Commit

Permalink
Introduce signal wrapper to fix warning about virtual signals
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 16, 2015
1 parent 4252d7e commit 3e44a00
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 65 deletions.
24 changes: 12 additions & 12 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
if (deck1Playing && deck2Playing) {
qDebug() << "One deck must be stopped before enabling Auto DJ mode";
// Keep the current state.
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
return ADJ_BOTH_DECKS_PLAYING;
}

Expand All @@ -264,7 +264,7 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
if (m_pEnabledAutoDJ->get() != 0.0) {
m_pEnabledAutoDJ->set(0.0);
}
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
return ADJ_QUEUE_EMPTY;
}

Expand Down Expand Up @@ -315,7 +315,7 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
// Load track into the left deck and play. Once it starts playing,
// we will receive a playerPositionChanged update for deck 1 which
// will load a track into the right deck and switch to IDLE mode.
emit(loadTrackToPlayer(nextTrack, leftDeck.group, true));
emitLoadTrackToPlayer(nextTrack, leftDeck.group, true);
} else {
// One of the two decks is playing. Switch into IDLE mode and wait
// until the playing deck crosses posThreshold to start fading.
Expand All @@ -324,15 +324,15 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
// Update fade thresholds for the left deck.
calculateFadeThresholds(&leftDeck);
// Load track into the right deck.
emit(loadTrackToPlayer(nextTrack, rightDeck.group, false));
emitLoadTrackToPlayer(nextTrack, rightDeck.group, false);
} else {
// Update fade thresholds for the right deck.
calculateFadeThresholds(&rightDeck);
// Load track into the left deck.
emit(loadTrackToPlayer(nextTrack, leftDeck.group, false));
emitLoadTrackToPlayer(nextTrack, leftDeck.group, false);
}
}
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
} else { // Disable Auto DJ
if (m_pEnabledAutoDJ->get() != 0.0) {
m_pEnabledAutoDJ->set(0.0);
Expand All @@ -342,7 +342,7 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
leftDeck.disconnect(this);
rightDeck.disconnect(this);
m_pCOCrossfader->set(0);
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
}
return ADJ_OK;
}
Expand Down Expand Up @@ -438,7 +438,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
// Set crossfade thresholds for right deck.
calculateFadeThresholds(&rightDeck);
}
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
}
return;
}
Expand All @@ -460,7 +460,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
m_eState = ADJ_IDLE;
// Load the next track to otherDeck.
loadNextTrackFromQueue(otherDeck);
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
}
return;
}
Expand Down Expand Up @@ -501,7 +501,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,

// Set the state as FADING.
m_eState = thisDeck.isLeft() ? ADJ_P1FADING : ADJ_P2FADING;
emit(autoDJStateChanged(m_eState));
emitAutoDJStateChanged(m_eState);
}

double posFadeEnd = math_min(1.0, thisDeck.posThreshold + thisFadeDuration);
Expand Down Expand Up @@ -572,11 +572,11 @@ bool AutoDJProcessor::loadNextTrackFromQueue(const DeckAttributes& deck, bool pl
toggleAutoDJ(false);

// And eject track (nextTrack is null) as "End of auto DJ warning"
emit(loadTrackToPlayer(nextTrack, deck.group, false));
emitLoadTrackToPlayer(nextTrack, deck.group, false);
return false;
}

emit(loadTrackToPlayer(nextTrack, deck.group, play));
emitLoadTrackToPlayer(nextTrack, deck.group, play);
return true;
}

Expand Down
17 changes: 13 additions & 4 deletions src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,21 @@ class AutoDJProcessor : public QObject {
AutoDJError fadeNow();
AutoDJError toggleAutoDJ(bool enable);

// The following virtual signal wrappers are used for testing
virtual void emitLoadTrackToPlayer(TrackPointer pTrack, QString group,
bool play) {
emit(loadTrackToPlayer(pTrack, group, play));
}
virtual void emitAutoDJStateChanged(AutoDJProcessor::AutoDJState state) {
emit(autoDJStateChanged(state));
}

signals:
virtual void loadTrackToPlayer(TrackPointer pTrack, QString group,
void loadTrackToPlayer(TrackPointer pTrack, QString group,
bool play);
virtual void transitionTimeChanged(int time);
virtual void autoDJStateChanged(AutoDJProcessor::AutoDJState state);
virtual void randomTrackRequested(int);
void autoDJStateChanged(AutoDJProcessor::AutoDJState state);
void transitionTimeChanged(int time);
void randomTrackRequested(int tracksToAdd);

private slots:
void playerPositionChanged(DeckAttributes* pDeck, double position);
Expand Down
Loading

0 comments on commit 3e44a00

Please sign in to comment.