Skip to content

Commit

Permalink
Fix cue points being assigned invalid value of -1.0
Browse files Browse the repository at this point in the history
Also add a note to the db schema that positions should be doubles even though the schema was defined as Integer.
Fixes mixxxdj#10993
  • Loading branch information
ywwg committed Nov 26, 2022
1 parent 9965d55 commit a486dc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions res/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ reapplying those migrations.
id INTEGER PRIMARY KEY AUTOINCREMENT,
track_id INTEGER NOT NULL REFERENCES library(id),
type INTEGER DEFAULT 0 NOT NULL,
<!-- Positions and lengths are actually stored as SQLite REAL (double) frame values.
This allows for bpm-accurate sub-sample accuracy positions and lengths. -->
position INTEGER DEFAULT -1 NOT NULL,
length INTEGER DEFAULT 0 NOT NULL,
hotcue INTEGER DEFAULT -1 NOT NULL,
Expand Down
10 changes: 9 additions & 1 deletion src/audio/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ class FramePos final {
/// values), use `FramePos::toEngineSamplePosMaybeInvalid` instead.
double toEngineSamplePos() const {
DEBUG_ASSERT(isValid());
return value() * mixxx::kEngineChannelCount;
double engineSamplePos = value() * mixxx::kEngineChannelCount;
// In the rare but possible instance that the position is valid but
// the engine sample position is exactly -1.0, we nudge the position
// because otherwise fromEngineSamplePosMaybeInvalid() will think
// the position is invalid.
if (engineSamplePos == kLegacyInvalidEnginePosition) {
return kLegacyInvalidEnginePosition - 0.0001;
}
return engineSamplePos;
}

/// Return a `FramePos` from a given engine sample position. Sample
Expand Down

0 comments on commit a486dc7

Please sign in to comment.