Skip to content

Commit

Permalink
Avoid creation of legacy-invalid frame positions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Oct 24, 2022
1 parent 5e6e63c commit b071d6e
Showing 1 changed file with 9 additions and 1 deletion.
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 - .0001;
}
return engineSamplePos;
}

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

0 comments on commit b071d6e

Please sign in to comment.