summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-10-27 17:43:24 +0100
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-10-27 17:58:31 +0100
commit27ca8d7c85bb069e666b4f032d3735654aba4228 (patch)
tree7d16ed51f3d652df3cacef767c4dece372098509 /src/engine
parentc3cbb1d14186366f5d1d4c1100488f77df23c9c4 (diff)
Replace implicit casts from double to bool with comparisons
This fixes a lot of -Wfloat-conversion warnings on certain compilers.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/controls/bpmcontrol.cpp24
-rw-r--r--src/engine/controls/cuecontrol.cpp243
-rw-r--r--src/engine/controls/ratecontrol.cpp4
-rw-r--r--src/engine/enginebuffer.cpp6
-rw-r--r--src/engine/enginemaster.cpp10
5 files changed, 154 insertions, 133 deletions
diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp
index 5649309253..274227b135 100644
--- a/src/engine/controls/bpmcontrol.cpp
+++ b/src/engine/controls/bpmcontrol.cpp
@@ -225,8 +225,10 @@ void BpmControl::slotTapFilter(double averageLength, int numSamples) {
pBeats->setBpm(averageBpm);
}
-void BpmControl::slotControlBeatSyncPhase(double v) {
- if (!v) return;
+void BpmControl::slotControlBeatSyncPhase(double value) {
+ if (value == 0) {
+ return;
+ }
if (isSynchronized()) {
m_dUserOffset.setValue(0.0);
@@ -234,13 +236,19 @@ void BpmControl::slotControlBeatSyncPhase(double v) {
getEngineBuffer()->requestSyncPhase();
}
-void BpmControl::slotControlBeatSyncTempo(double v) {
- if (!v) return;
+void BpmControl::slotControlBeatSyncTempo(double value) {
+ if (value == 0) {
+ return;
+ }
+
syncTempo();
}
-void BpmControl::slotControlBeatSync(double v) {
- if (!v) return;
+void BpmControl::slotControlBeatSync(double value) {
+ if (value == 0) {
+ return;
+ }
+
if (!syncTempo()) {
// syncTempo failed, nothing else to do
return;
@@ -250,7 +258,7 @@ void BpmControl::slotControlBeatSync(double v) {
// this is used from controller scripts, where the latching behaviour of
// the sync_enable CO cannot be used
if (m_pPlayButton->toBool() && m_pQuantize->toBool()) {
- slotControlBeatSyncPhase(v);
+ slotControlBeatSyncPhase(value);
}
}
@@ -1036,7 +1044,7 @@ void BpmControl::resetSyncAdjustment() {
void BpmControl::collectFeatures(GroupFeatureState* pGroupFeatures) const {
// Without a beatgrid we don't know any beat details.
SampleOfTrack sot = getSampleOfTrack();
- if (!sot.rate || !m_pBeats) {
+ if (sot.rate == 0 || !m_pBeats) {
return;
}
diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp
index 4f5163b9d1..7dbe1654f8 100644
--- a/src/engine/controls/cuecontrol.cpp
+++ b/src/engine/controls/cuecontrol.cpp
@@ -641,11 +641,12 @@ void CueControl::quantizeChanged(double v) {
}
}
-void CueControl::hotcueSet(HotcueControl* pControl, double v) {
- //qDebug() << "CueControl::hotcueSet" << v;
+void CueControl::hotcueSet(HotcueControl* pControl, double value) {
+ //qDebug() << "CueControl::hotcueSet" << value;
- if (!v)
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack)
@@ -656,7 +657,7 @@ void CueControl::hotcueSet(HotcueControl* pControl, double v) {
// It remains in the database for later use
// TODO: find a rule, that allows us to delete the cue as well
// https://bugs.launchpad.net/mixxx/+bug/1653276
- hotcueClear(pControl, v);
+ hotcueClear(pControl, value);
CuePointer pCue(m_pLoadedTrack->createAndAddCue());
double cuePosition = getQuantizedCurrentPosition();
@@ -691,9 +692,10 @@ void CueControl::hotcueSet(HotcueControl* pControl, double v) {
}
}
-void CueControl::hotcueGoto(HotcueControl* pControl, double v) {
- if (!v)
+void CueControl::hotcueGoto(HotcueControl* pControl, double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack) {
@@ -713,9 +715,10 @@ void CueControl::hotcueGoto(HotcueControl* pControl, double v) {
}
}
-void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double v) {
- if (!v)
+void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack)
@@ -735,9 +738,10 @@ void CueControl::hotcueGotoAndStop(HotcueControl* pControl, double v) {
}
}
-void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double v) {
- if (!v)
+void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack) {
@@ -766,8 +770,8 @@ void CueControl::hotcueGotoAndPlay(HotcueControl* pControl, double v) {
}
}
-void CueControl::hotcueActivate(HotcueControl* pControl, double v) {
- //qDebug() << "CueControl::hotcueActivate" << v;
+void CueControl::hotcueActivate(HotcueControl* pControl, double value) {
+ //qDebug() << "CueControl::hotcueActivate" << value;
QMutexLocker lock(&m_mutex);
@@ -780,46 +784,46 @@ void CueControl::hotcueActivate(HotcueControl* pControl, double v) {
lock.unlock();
if (pCue) {
- if (v) {
+ if (value != 0) {
if (pCue->getPosition() == Cue::kNoPosition) {
- hotcueSet(pControl, v);
+ hotcueSet(pControl, value);
} else {
if (isPlayingByPlayButton()) {
- hotcueGoto(pControl, v);
+ hotcueGoto(pControl, value);
} else {
- hotcueActivatePreview(pControl, v);
+ hotcueActivatePreview(pControl, value);
}
}
} else {
if (pCue->getPosition() != Cue::kNoPosition) {
- hotcueActivatePreview(pControl, v);
+ hotcueActivatePreview(pControl, value);
}
}
} else {
// The cue is non-existent ...
- if (v) {
+ if (value != 0) {
// set it to the current position
- hotcueSet(pControl, v);
+ hotcueSet(pControl, value);
} else if (m_iCurrentlyPreviewingHotcues) {
// yet we got a release for it and are
// currently previewing a hotcue. This is indicative of a corner
// case where the cue was detached while we were pressing it. Let
// hotcueActivatePreview handle it.
- hotcueActivatePreview(pControl, v);
+ hotcueActivatePreview(pControl, value);
}
}
m_pHotcueFocus->set(pControl->getHotcueNumber());
}
-void CueControl::hotcueActivatePreview(HotcueControl* pControl, double v) {
+void CueControl::hotcueActivatePreview(HotcueControl* pControl, double value) {
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack) {
return;
}
CuePointer pCue(pControl->getCue());
- if (v) {
+ if (value != 0) {
if (pCue && pCue->getPosition() != Cue::kNoPosition) {
m_iCurrentlyPreviewingHotcues++;
double position = pCue->getPosition();
@@ -853,9 +857,10 @@ void CueControl::hotcueActivatePreview(HotcueControl* pControl, double v) {
}
}
-void CueControl::hotcueClear(HotcueControl* pControl, double v) {
- if (!v)
+void CueControl::hotcueClear(HotcueControl* pControl, double value) {
+ if (value != 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
if (!m_pLoadedTrack) {
@@ -913,9 +918,10 @@ void CueControl::hintReader(HintVector* pHintList) {
// Moves the cue point to current position or to closest beat in case
// quantize is enabled
-void CueControl::cueSet(double v) {
- if (!v)
+void CueControl::cueSet(double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
@@ -930,8 +936,8 @@ void CueControl::cueSet(double v) {
}
}
-void CueControl::cueClear(double v) {
- if (!v) {
+void CueControl::cueClear(double value) {
+ if (value == 0) {
return;
}
@@ -945,10 +951,10 @@ void CueControl::cueClear(double v) {
}
}
-void CueControl::cueGoto(double v)
-{
- if (!v)
+void CueControl::cueGoto(double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
// Seek to cue point
@@ -960,10 +966,12 @@ void CueControl::cueGoto(double v)
seekAbs(cuePoint);
}
-void CueControl::cueGotoAndPlay(double v)
-{
- if (!v) return;
- cueGoto(v);
+void CueControl::cueGotoAndPlay(double value) {
+ if (value == 0) {
+ return;
+ }
+
+ cueGoto(value);
QMutexLocker lock(&m_mutex);
// Start playing if not already
if (!isPlayingByPlayButton()) {
@@ -976,10 +984,10 @@ void CueControl::cueGotoAndPlay(double v)
}
}
-void CueControl::cueGotoAndStop(double v)
-{
- if (!v)
+void CueControl::cueGotoAndStop(double value) {
+ if (value == 0) {
return;
+ }
QMutexLocker lock(&m_mutex);
m_pPlay->set(0.0);
@@ -991,21 +999,19 @@ void CueControl::cueGotoAndStop(double v)
seekExact(cuePoint);
}
-void CueControl::cuePreview(double v)
-{
+void CueControl::cuePreview(double value) {
QMutexLocker lock(&m_mutex);
- if (v) {
+ if (value != 0) {
m_bPreviewing = true;
m_bypassCueSetByPlay = true;
m_pPlay->set(1.0);
- } else if (!v && m_bPreviewing) {
+ } else if (m_bPreviewing) {
m_bPreviewing = false;
- if (!m_iCurrentlyPreviewingHotcues) {
- m_pPlay->set(0.0);
- } else {
+ if (m_iCurrentlyPreviewingHotcues) {
return;
}
+ m_pPlay->set(0.0);
} else {
return;
}
@@ -1016,7 +1022,7 @@ void CueControl::cuePreview(double v)
seekAbs(m_pCuePoint->get());
}
-void CueControl::cueCDJ(double v) {
+void CueControl::cueCDJ(double value) {
// This is how Pioneer cue buttons work:
// If pressed while freely playing (i.e. playing and platter NOT being touched), stop playback and go to cue.
// If pressed while NOT freely playing (i.e. stopped or playing but platter IS being touched), set new cue point.
@@ -1027,7 +1033,7 @@ void CueControl::cueCDJ(double v) {
const auto freely_playing = m_pPlay->toBool() && !getEngineBuffer()->getScratching();
TrackAt trackAt = getTrackAt();
- if (v) {
+ if (value != 0) {
if (m_iCurrentlyPreviewingHotcues) {
// we are already previewing by hotcues
// just jump to cue point and continue previewing
@@ -1051,7 +1057,7 @@ void CueControl::cueCDJ(double v) {
m_pPlay->set(1.0);
} else {
// Pause not at cue point and not at end position
- cueSet(v);
+ cueSet(value);
// Just in case.
m_bPreviewing = false;
m_pPlay->set(0.0);
@@ -1084,7 +1090,7 @@ void CueControl::cueCDJ(double v) {
}
}
-void CueControl::cueDenon(double v) {
+void CueControl::cueDenon(double value) {
// This is how Denon DN-S 3700 cue buttons work:
// If pressed go to cue and stop.
// If pressed while stopped and at cue, play while pressed.
@@ -1094,7 +1100,7 @@ void CueControl::cueDenon(double v) {
bool playing = (m_pPlay->toBool());
TrackAt trackAt = getTrackAt();
- if (v) {
+ if (value != 0) {
if (m_iCurrentlyPreviewingHotcues) {
// we are already previewing by hotcues
// just jump to cue point and continue previewing
@@ -1128,7 +1134,7 @@ void CueControl::cueDenon(double v) {
}
}
-void CueControl::cuePlay(double v) {
+void CueControl::cuePlay(double value) {
// This is how CUP button works:
// If freely playing (i.e. playing and platter NOT being touched), press to go to cue and stop.
// If not freely playing (i.e. stopped or platter IS being touched), press to go to cue and stop.
@@ -1140,7 +1146,7 @@ void CueControl::cuePlay(double v) {
TrackAt trackAt = getTrackAt();
// pressed
- if (v) {
+ if (value != 0) {
if (freely_playing) {
m_bPreviewing = false;
m_pPlay->set(0.0);
@@ -1151,7 +1157,7 @@ void CueControl::cuePlay(double v) {
seekAbs(m_pCuePoint->get());
} else if (trackAt == TrackAt::ElseWhere) {
// Pause not at cue point and not at end position
- cueSet(v);
+ cueSet(value);
// Just in case.
m_bPreviewing = false;
m_pPlay->set(0.0);
@@ -1163,7 +1169,7 @@ void CueControl::cuePlay(double v) {
seekAbs(m_pCuePoint->get());
}
}
- } else if (trackAt == TrackAt::Cue){
+ } else if (trackAt == TrackAt::Cue) {
m_bPreviewing = false;
m_pPlay->set(1.0);
lock.unlock();
@@ -1205,8 +1211,8 @@ void CueControl::playStutter(double v) {
}
}
-void CueControl::introStartSet(double v) {
- if (!v) {
+void CueControl::introStartSet(double value) {
+ if (value == 0) {
return;
}
@@ -1246,8 +1252,8 @@ void CueControl::introStartSet(double v) {
}
}
-void CueControl::introStartClear(double v) {
- if (!v) {
+void CueControl::introStartClear(double value) {
+ if (value == 0) {
return;
}
@@ -1267,22 +1273,24 @@ void CueControl::introStartClear(double v) {
}
}
-void CueControl::introStartActivate(double v) {
- if (v) {
- QMutexLocker lock(&m_mutex);
- double introStart = m_pIntroStartPosition->get();
- lock.unlock();
+void CueControl::introStartActivate(double value) {
+ if (value == 0) {
+ return;
+ }
- if (introStart == Cue::kNoPosition) {
- introStartSet(1.0);
- } else {
- seekAbs(introStart);
- }
+ QMutexLocker lock(&m_mutex);
+ double introStart = m_pIntroStartPosition->get();
+ lock.unlock();
+
+ if (introStart == Cue::kNoPosition) {
+ introStartSet(1.0);
+ } else {
+ seekAbs(introStart);
}
}
-void CueControl::introEndSet(double v) {
- if (!v) {
+void CueControl::introEndSet(double value) {
+ if (value == 0) {
return;
}
@@ -1322,8 +1330,8 @@ void CueControl::introEndSet(double v) {
}
}
-void CueControl::introEndClear(double v) {
- if (!v) {
+void CueControl::introEndClear(double value) {
+ if (value == 0) {
return;
}
@@ -1343,22 +1351,24 @@ void CueControl::introEndClear(double v) {
}
}
-void CueControl::introEndActivate(double v) {
- if (v) {
- QMutexLocker lock(&m_mutex);
- double introEnd = m_pIntroEndPosition->get();
- lock.unlock();
+void CueControl::introEndActivate(double value) {
+ if (value == 0) {
+ return;
+ }
- if (introEnd == Cue::kNoPosition) {
- introEndSet(1.0);
- } else {
- seekAbs(introEnd);
- }
+ QMutexLocker lock(&m_mutex);
+ double introEnd = m_pIntroEndPosition->get();
+ lock.unlock();
+
+ if (introEnd == Cue::kNoPosition) {
+ introEndSet(1.0);
+ } else {
+ seekAbs(introEnd);
}
}
-void CueControl::outroStartSet(double v) {
- if (!v) {
+void CueControl::outroStartSet(double value) {
+ if (value == 0) {
return;
}
@@ -1398,8 +1408,8 @@ void CueControl::outroStartSet(double v) {
}
}
-void CueControl::outroStartClear(double v) {
- if (!v) {
+void CueControl::outroStartClear(double value) {
+ if (value == 0) {
return;
}
@@ -1419,22 +1429,24 @@ void CueControl::outroStartClear(double v) {
}
}
-void CueControl::outroStartActivate(double v) {
- if (v) {
- QMutexLocker lock(&m_mutex);
- double outroStart = m_pOutroStartPosition->get();
- lock.unlock();
+void CueControl::outroStartActivate(double value) {
+ if (value == 0) {
+ return;
+ }
- if (outroStart == Cue::kNoPosition) {
- outroStartSet(1.0);
- } else {
- seekAbs(outroStart);
- }
+ QMutexLocker lock(&m_mutex);
+ double outroStart = m_pOutroStartPosition->get();
+ lock.unlock();
+
+ if (outroStart == Cue::kNoPosition) {
+ outroStartSet(1.0);
+ } else {
+ seekAbs(outroStart);
}
}
-void CueControl::outroEndSet(double v) {
- if (!v) {
+void CueControl::outroEndSet(double value) {
+ if (value == 0) {
return;
}
@@ -1474,8 +1486,8 @@ void CueControl::outroEndSet(double v) {
}
}
-void CueControl::outroEndClear(double v) {
- if (!v) {
+void CueControl::outroEndClear(double value) {
+ if (value == 0) {
return;
}
@@ -1495,17 +1507,19 @@ void CueControl::outroEndClear(double v) {
}
}
-void CueControl::outroEndActivate(double v) {
- if (v) {
- QMutexLocker lock(&m_mutex);
- double outroEnd = m_pOutroEndPosition->get();
- lock.unlock();
+void CueControl::outroEndActivate(double value) {
+ if (value == 0) {
+ return;
+ }
- if (outroEnd == Cue::kNoPosition) {
- outroEndSet(1.0);
- } else {
- seekAbs(outroEnd);
- }
+ QMutexLocker lock(&m_mutex);
+ double outroEnd = m_pOutroEndPosition->get();
+ lock.unlock();
+
+ if (outroEnd == Cue::kNoPosition) {
+ outroEndSet(1.0);
+ } else {
+ seekAbs(outroEnd);
}
}
@@ -1743,8 +1757,8 @@ SeekOnLoadMode CueControl::getSeekOnLoadPreference() {
return static_cast<SeekOnLoadMode>(configValue);
}
-void CueControl::hotcueFocusColorPrev(double v) {
- if (!v) {
+void CueControl::hotcueFocusColorPrev(double value) {
+ if (value == 0) {
return;
}
@@ -1772,8 +1786,8 @@ void CueControl::hotcueFocusColorPrev(double v) {
pCue->setColor(colorPalette.previousColor(*color));
}
-void CueControl::hotcueFocusColorNext(double v) {
- if (!v) {
+void CueControl::hotcueFocusColorNext(double value) {
+ if (value == 0) {
return;
}
@@ -1801,7 +1815,6 @@ void CueControl::hotcueFocusColorNext(double v) {
pCue->setColor(colorPalette.nextColor(*color));
}
-
ConfigKey HotcueControl::keyForControl(int hotcue, const char* name) {
ConfigKey key;
key.group = m_group;
diff --git a/src/engine/controls/ratecontrol.cpp b/src/engine/controls/ratecontrol.cpp
index ade6b37855..8c22f917ab 100644
--- a/src/engine/controls/ratecontrol.cpp
+++ b/src/engine/controls/ratecontrol.cpp
@@ -393,8 +393,8 @@ double RateControl::calculateSpeed(double baserate, double speed, bool paused,
processTempRate(iSamplesPerBuffer);
double rate;
- double searching = m_pRateSearch->get();
- if (searching) {
+ const double searching = m_pRateSearch->get();
+ if (searching != 0) {
// If searching is in progress, it overrides everything else
rate = searching;
} else {
diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp
index d531d20b31..1087fd505b 100644
--- a/src/engine/enginebuffer.cpp
+++ b/src/engine/enginebuffer.cpp
@@ -577,7 +577,7 @@ void EngineBuffer::ejectTrack() {
}
void EngineBuffer::slotPassthroughChanged(double enabled) {
- if (enabled) {
+ if (enabled != 0) {
// If passthrough was enabled, stop playing the current track.
slotControlStop(1.0);
}
@@ -791,7 +791,7 @@ void EngineBuffer::processTrackLocked(
} else {
// We might have have temporary speed change, so adjust pitch if not locked
// Note: This will not update key and tempo widgets
- if (tempoRatio) {
+ if (tempoRatio != 0) {
pitchRatio *= (speed / tempoRatio);
}
@@ -813,7 +813,7 @@ void EngineBuffer::processTrackLocked(
// Do not switch scaler when we have no transport
enableIndependentPitchTempoScaling(useIndependentPitchAndTempoScaling,
iBufferSize);
- } else if (m_speed_old && !is_scratching) {
+ } else if (m_speed_old != 0 && !is_scratching) {
// we are stopping, collect samples for fade out
readToCrossfadeBuffer(iBufferSize);
// Clear the scaler information
diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp
index 46d2a8e203..ee2e5ebb47 100644
--- a/src/engine/enginemaster.cpp
+++ b/src/engine/enginemaster.cpp
@@ -305,14 +305,14 @@ void EngineMaster::processChannels(int iBufferSize) {
// Check if we need to fade out the master channel
GainCache& gainCache = m_channelMasterGainCache[i];
- if (gainCache.m_gain) {
+ if (gainCache.m_gain != 0) {
gainCache.m_fadeout = true;
m_activeBusChannels[pChannel->getOrientation()].append(pChannelInfo);
- }
+ }
} else {
// Check if we need to fade out the channel
GainCache& gainCache = m_channelTalkoverGainCache[i];
- if (gainCache.m_gain) {
+ if (gainCache.m_gain != 0) {
gainCache.m_fadeout = true;
m_activeTalkoverChannels.append(pChannelInfo);
}
@@ -323,7 +323,7 @@ void EngineMaster::processChannels(int iBufferSize) {
} else {
// Check if we need to fade out the channel
GainCache& gainCache = m_channelMasterGainCache[i];
- if (gainCache.m_gain) {
+ if (gainCache.m_gain != 0) {
gainCache.m_fadeout = true;
m_activeBusChannels[pChannel->getOrientation()].append(pChannelInfo);
}
@@ -337,7 +337,7 @@ void EngineMaster::processChannels(int iBufferSize) {
} else {
// Check if we need to fade out the channel
GainCache& gainCache = m_channelHeadphoneGainCache[i];
- if (gainCache.m_gain) {
+ if (gainCache.m_gain != 0) {
m_channelHeadphoneGainCache[i].m_fadeout = true;
m_activeHeadphoneChannels.append(pChannelInfo);
}