Skip to content

Commit

Permalink
Add a test that can crash soundtouch
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Apr 8, 2015
1 parent 98bb453 commit 75c4c84
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/test/enginebuffertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ TEST_F(EngineBufferTest, SlowRubberBand) {
ProcessBuffer();
EXPECT_EQ(m_pMockScaleKeylock1, m_pChannel1->getEngineBuffer()->m_pScale);

// With Rubberband, and transport stopped it should be still keylock
// With Rubberband, and transport stopped it should be still keylock
ControlObject::set(ConfigKey("[Master]", "keylock_engine"),
static_cast<double>(EngineBuffer::RUBBERBAND));
ControlObject::set(ConfigKey(m_sGroup1, "rateSearch"), 0.0);
Expand Down Expand Up @@ -187,3 +187,43 @@ TEST_F(EngineBufferTest, ResetPitchAdjustUsesLinear) {
ProcessBuffer();
EXPECT_EQ(m_pMockScaleVinyl1, m_pChannel1->getEngineBuffer()->m_pScale);
}

TEST_F(EngineBufferTest, SoundTouchCrashTest) {
// Soundtouch has a bug where a pitch value of zero causes an infinite loop
// and crash.

// We actually have to load a track to test this.
const QString kGroup4 = "[Channel4]";
EngineDeck* channel4 = new EngineDeck(
m_pEngineMaster->registerChannelGroup(kGroup4),
m_pConfig.data(), m_pEngineMaster, m_pEffectsManager,
EngineChannel::CENTER);
addDeck(channel4);
// This file comes from the autodjprocessor test.
const QString kTrackLocationTest(QDir::currentPath() +
"/src/test/id3-test-data/cover-test.mp3");
TrackPointer pTrack(new TrackInfoObject(kTrackLocationTest));
channel4->getEngineBuffer()->slotLoadTrack(pTrack, true);

// Wait for the track to load.
ProcessBuffer();
for (int i = 0; i < 10 && !channel4->getEngineBuffer()->isTrackLoaded();
++i) {
sleep(1);
}
ASSERT_TRUE(channel4->getEngineBuffer()->isTrackLoaded());

ControlObject::set(ConfigKey("[Master]", "keylock_engine"),
static_cast<double>(EngineBuffer::SOUNDTOUCH));
ControlObject::set(ConfigKey(kGroup4, "pitch"), 1.2);
ControlObject::set(ConfigKey(kGroup4, "rate"), 0.05);
ControlObject::set(ConfigKey(kGroup4, "play"), 1.0);
// Start by playing with soundtouch enabled.
ProcessBuffer();
// Pause the buffer. This causes the pitch to be set to 0.
ControlObject::set(ConfigKey(kGroup4, "play"), 0.0);
ProcessBuffer();
ControlObject::set(ConfigKey(kGroup4, "rateSearch"), -0.05);
// Should not crash
ProcessBuffer();
}

0 comments on commit 75c4c84

Please sign in to comment.