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

fix assertion in Lp1839669 #2235

Merged
merged 7 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 11 additions & 2 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,15 +1196,24 @@ void EngineBuffer::postProcess(const int iBufferSize) {
}

void EngineBuffer::updateIndicators(double speed, int iBufferSize) {
VERIFY_OR_DEBUG_ASSERT(m_trackSampleRateOld && m_tempo_ratio_old) {
// no track loaded, function not called in this case
if (!m_trackSampleRateOld) {
// This happens if Deck Passthrough is active but no track is loaded.
// We skip indicator updates.
return;
}

// Increase samplesCalculated by the buffer size
m_iSamplesSinceLastIndicatorUpdate += iBufferSize;

const double fFractionalPlaypos = fractionalPlayposFromAbsolute(m_filepos_play);

double ratio = m_tempo_ratio_old;
if (ratio == 0.0) {
// In case the track is slowed done to zero we will have INF remaining seconds.
// We jump back to a rate of 1.0 to show a useful time.
ratio = 1.0;
}

const double tempoTrackSeconds = m_trackSamplesOld / kSamplesPerFrame
/ m_trackSampleRateOld / m_tempo_ratio_old;
if(speed > 0 && fFractionalPlaypos == 1.0) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/durationutiltest.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <limits>

#include <gtest/gtest.h>

#include "util/duration.h"
Expand Down Expand Up @@ -112,6 +114,8 @@ TEST_F(DurationUtilTest, formatTime) {
formatTime("24:00:00.000", 24 * 3600);
formatTime("24:00:01.000", 24 * 3600 + 1);
formatTime("25:00:01.000", 25 * 3600 + 1);
formatTime("?", std::numeric_limits<double>::infinity());
formatTime("?", -1);
}

TEST_F(DurationUtilTest, formatSeconds) {
Expand Down
5 changes: 3 additions & 2 deletions src/util/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QTime>

#include "util/assert.h"
#include "util/fpclassify.h"
#include "util/math.h"

namespace mixxx {
Expand All @@ -26,8 +27,8 @@ QChar DurationBase::kDecimalSeparator = QChar(0x002E);

// static
QString DurationBase::formatTime(double dSeconds, Precision precision) {
if (dSeconds < 0.0) {
// negative durations are not supported
if (dSeconds < 0.0 || !isfinite(dSeconds)) {
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
// negative durations and infinity or isNaN values are not supported
return kInvalidDurationString;
}

Expand Down