void AudioPrefetch::seek(unsigned seekTo) { // printf("seek %d\n", seekTo); #ifdef AUDIOPREFETCH_DEBUG printf("AudioPrefetch::seek to:%u seekCount:%d\n", seekTo, seekCount); #endif // Speedup: More than one seek message pending? // Eat up seek messages until we get to the very LATEST one, // because all the rest which came before it are irrelevant now, // and processing them all was taking extreme time, especially with // resampling enabled. // In particular, when the user 'slides' the play cursor back and forth // there are MANY seek messages in the pipe, and with resampling enabled // it was taking minutes to finish seeking. If the user hit play during that time, // things were messed up (FIFO underruns, choppy intermittent sound etc). // Added by Tim. p3.3.20 if (seekCount > 1) { --seekCount; return; } writePos = seekTo; WaveTrackList* tl = song->waves(); for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) { WaveTrack* track = *it; track->clearPrefetchFifo(); } bool isFirstPrefetch = true; for (unsigned int i = 0; i < (fifoLength) - 1; ++i)//prevent compiler warning: comparison of signed/unsigned { // Indicate do a seek command before read, but only on the first pass. // Changed by Tim. p3.3.17 //prefetch(); prefetch(isFirstPrefetch); isFirstPrefetch = false; // To help speed things up even more, check the count again. Return if more seek messages are pending. // Added by Tim. p3.3.20 if (seekCount > 1) { --seekCount; return; } } seekPos = seekTo; //seekDone = true; --seekCount; }