Skip to content

Commit

Permalink
Track: Fix debug assertion for missing/invalid bpm
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Jul 12, 2021
1 parent 611a153 commit 1534efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void Track::replaceMetadataFromSource(
// missing or not valid! The BPM value in the metadata might be
// imprecise (normalized or rounded), e.g. ID3v2 only supports
// integer values.
beatsAndBpmModified = trySetBpmWhileLocked(importedBpm.value());
beatsAndBpmModified = trySetBpmWhileLocked(importedBpm);
}
modified |= beatsAndBpmModified;

Expand Down Expand Up @@ -285,7 +285,7 @@ bool Track::replaceRecord(
} else {
// Setting the bpm manually may in turn update the beat grid
bpmUpdatedFlag = trySetBpmWhileLocked(
newRecord.getMetadata().getTrackInfo().getBpm().value());
newRecord.getMetadata().getTrackInfo().getBpm());
}
// The bpm in m_record has already been updated. Read it and copy it into
// the new record to ensure it will be consistent with the new beat grid.
Expand Down Expand Up @@ -334,8 +334,7 @@ mixxx::Bpm Track::getBpmWhileLocked() const {
return m_record.getMetadata().getTrackInfo().getBpm();
}

bool Track::trySetBpmWhileLocked(double bpmValue) {
const auto bpm = mixxx::Bpm(bpmValue);
bool Track::trySetBpmWhileLocked(mixxx::Bpm bpm) {
if (!bpm.isValid()) {
// If the user sets the BPM to an invalid value, we assume
// they want to clear the beatgrid.
Expand Down Expand Up @@ -367,9 +366,9 @@ double Track::getBpm() const {
return bpm.isValid() ? bpm.value() : mixxx::Bpm::kValueUndefined;
}

bool Track::trySetBpm(double bpmValue) {
bool Track::trySetBpm(mixxx::Bpm bpm) {
auto locked = lockMutex(&m_qMutex);
if (!trySetBpmWhileLocked(bpmValue)) {
if (!trySetBpmWhileLocked(bpm)) {
return false;
}
afterBeatsAndBpmUpdated(&locked);
Expand Down
7 changes: 5 additions & 2 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ class Track : public QObject {
}

// Sets the BPM if not locked.
bool trySetBpm(double bpm);
bool trySetBpm(double bpmValue) {
return trySetBpm(mixxx::Bpm(bpmValue));
}
bool trySetBpm(mixxx::Bpm bpm);

// Returns BPM
double getBpm() const;
Expand Down Expand Up @@ -466,7 +469,7 @@ class Track : public QObject {
bool importPendingCueInfosWhileLocked();

mixxx::Bpm getBpmWhileLocked() const;
bool trySetBpmWhileLocked(double bpmValue);
bool trySetBpmWhileLocked(mixxx::Bpm bpm);
bool trySetBeatsWhileLocked(
mixxx::BeatsPointer pBeats,
bool lockBpmAfterSet = false);
Expand Down

0 comments on commit 1534efe

Please sign in to comment.