=== modified file 'mixxx/src/engine/enginebuffer.cpp' --- mixxx/src/engine/enginebuffer.cpp 2012-12-27 23:21:45 +0000 +++ mixxx/src/engine/enginebuffer.cpp 2012-12-27 23:58:34 +0000 @@ -66,6 +66,7 @@ m_pReadAheadManager(NULL), m_pReader(NULL), m_filepos_play(0.), + m_filepos_seek(-1), m_rate_old(0.), m_file_length_old(-1), m_file_srate_old(0), @@ -330,33 +331,36 @@ m_pBpmControl->setEngineMaster(pEngineMaster); } -void EngineBuffer::setNewPlaypos(double newpos) -{ - //qDebug() << "engine new pos " << newpos; - - // Before seeking, read extra buffer for crossfading - CSAMPLE* fadeout = m_pScale->getScaled(m_iLastBufferSize); - m_iCrossFadeSamples = m_pScale->getSamplesRead(); - SampleUtil::copyWithGain(m_pCrossFadeBuffer, fadeout, 1.0, m_iLastBufferSize); - - m_filepos_play = newpos; - - // Ensures that the playpos slider gets updated in next process call - m_iSamplesCalculated = 1000000; - - // The right place to do this? - if (m_pScale) +void EngineBuffer::setNewPlaypos(double newpos) { + m_filepos_seek = newpos; +} + +void EngineBuffer::processSeek() { + if (m_filepos_seek >= 0) { + // Before seeking, read extra buffer for crossfading + CSAMPLE* fadeout = m_pScale->getScaled(m_iLastBufferSize); + m_iCrossFadeSamples = m_pScale->getSamplesRead(); + SampleUtil::copyWithGain(m_pCrossFadeBuffer, fadeout, 1.0, m_iLastBufferSize); + + m_filepos_play = m_filepos_seek; + + // Ensures that the playpos slider gets updated in next process call + m_iSamplesCalculated = 1000000; + + // The right place to do this? m_pScale->clear(); - m_pReadAheadManager->notifySeek(m_filepos_play); + m_pReadAheadManager->setNewPlaypos(m_filepos_play); - // Must hold the engineLock while using m_engineControls - m_engineLock.lock(); - for (QList::iterator it = m_engineControls.begin(); - it != m_engineControls.end(); it++) { - EngineControl *pControl = *it; - pControl->notifySeek(m_filepos_play); + // Must hold the engineLock while using m_engineControls + m_engineLock.lock(); + for (QList::iterator it = m_engineControls.begin(); + it != m_engineControls.end(); it++) { + EngineControl *pControl = *it; + pControl->notifySeek(m_filepos_play); + } + m_engineLock.unlock(); + m_filepos_seek = -1; } - m_engineLock.unlock(); } const char * EngineBuffer::getGroup() @@ -536,6 +540,8 @@ void EngineBuffer::process(const CSAMPLE *, const CSAMPLE * pOut, const int iBufferSize) { + processSeek(); + Q_ASSERT(even(iBufferSize)); m_pReader->process(); // Steps: @@ -724,7 +730,7 @@ // the engine and RAMAN can get out of sync. //setNewPlaypos(filepos_play); - m_pReadAheadManager->notifySeek(m_filepos_play); + m_pReadAheadManager->setNewPlaypos(m_filepos_play); // Notify seek the rate control since it needs to track things // like looping. Hacky, I know, but this helps prevent things // like the scratch controller from flipping out. === modified file 'mixxx/src/engine/enginebuffer.h' --- mixxx/src/engine/enginebuffer.h 2012-11-30 23:58:11 +0000 +++ mixxx/src/engine/enginebuffer.h 2012-12-27 23:49:20 +0000 @@ -164,6 +164,8 @@ double fractionalPlayposFromAbsolute(double absolutePlaypos); + void processSeek(); + // Lock for modifying local engine variables that are not thread safe, such // as m_engineControls and m_hintList QMutex m_engineLock; @@ -175,7 +177,7 @@ /** Pointer to the loop control object */ LoopingControl* m_pLoopingControl; - /** Pointer to the rate control object */ + /** Pointer to the rate control objecprocessSeek()t */ RateControl* m_pRateControl; /** Pointer to the BPM control object */ @@ -195,6 +197,8 @@ /** The current sample to play in the file. */ double m_filepos_play; + /** The current sample to play in the file. */ + double m_filepos_seek; /** Copy of rate_exchange, used to check if rate needs to be updated */ double m_rate_old; /** Copy of length of file */