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

lp1937074: Fix synchronization of main cue point/position #4137

Merged
merged 2 commits into from
Jul 24, 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
25 changes: 17 additions & 8 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,24 @@ void CueControl::loadCuesFromTrack() {
m_pLoadedTrack->setMainCuePosition(mainCuePosition);
} else {
// If no load cue point is stored, read from track
// Note: This is 0:00 for new tracks
// Note: This is mixxx::audio::kStartFramePos for new tracks
// and always a valid position.
mainCuePosition = m_pLoadedTrack->getMainCuePosition();
DEBUG_ASSERT(mainCuePosition == mixxx::audio::kStartFramePos);
// Than add the load cue to the list of cue
CuePointer pCue = m_pLoadedTrack->createAndAddCue(
mixxx::CueType::MainCue,
Cue::kNoHotCue,
mainCuePosition,
mixxx::audio::kInvalidFramePos);
DEBUG_ASSERT(mainCuePosition.isValid());
// A main cue point only needs to be added if the position
// differs from the default position.
if (mainCuePosition != mixxx::audio::kStartFramePos) {
qInfo()
<< "Adding missing main cue point at"
<< mainCuePosition
<< "for track"
<< m_pLoadedTrack->getLocation();
m_pLoadedTrack->createAndAddCue(
mixxx::CueType::MainCue,
Cue::kNoHotCue,
mainCuePosition,
mixxx::audio::kInvalidFramePos);
}
}

DEBUG_ASSERT(mainCuePosition.isValid());
Expand Down
4 changes: 3 additions & 1 deletion src/track/cue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Cue::Cue(
positionMillisToFrames(
cueInfo.getEndPositionMillis(),
sampleRate)),
m_iHotCue(cueInfo.getHotCueIndex() ? *cueInfo.getHotCueIndex() : kNoHotCue),
m_iHotCue(cueInfo.getHotCueIndex().value_or(kNoHotCue)),
m_label(cueInfo.getLabel()),
m_color(cueInfo.getColor().value_or(mixxx::PredefinedColorPalettes::kDefaultCueColor)) {
DEBUG_ASSERT(!m_dbId.isValid());
Expand All @@ -104,6 +104,8 @@ Cue::Cue(
m_endPosition(endPosition),
m_iHotCue(hotCueIndex),
m_color(mixxx::PredefinedColorPalettes::kDefaultCueColor) {
DEBUG_ASSERT(m_iHotCue == kNoHotCue || m_iHotCue >= mixxx::kFirstHotCueIndex);
DEBUG_ASSERT(m_startPosition.isValid() || m_endPosition.isValid());
DEBUG_ASSERT(!m_dbId.isValid());
}

Expand Down
7 changes: 7 additions & 0 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,13 @@ CuePointer Track::createAndAddCue(
int hotCueIndex,
mixxx::audio::FramePos startPosition,
mixxx::audio::FramePos endPosition) {
VERIFY_OR_DEBUG_ASSERT(hotCueIndex == Cue::kNoHotCue ||
hotCueIndex >= mixxx::kFirstHotCueIndex) {
return CuePointer{};
}
VERIFY_OR_DEBUG_ASSERT(startPosition.isValid() || endPosition.isValid()) {
return CuePointer{};
}
CuePointer pCue(new Cue(
type,
hotCueIndex,
Expand Down