Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track: Fix debug assertion for missing/invalid bpm #4100

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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