void AudioPrefetch::prefetch(bool doSeek) { if (writePos == ~0U) { printf("AudioPrefetch::prefetch: invalid write position\n"); return; } if (MusEGlobal::song->loop() && !MusEGlobal::audio->bounce() && !MusEGlobal::extSyncFlag.value()) { const Pos& loop = MusEGlobal::song->rPos(); unsigned n = loop.frame() - writePos; if (n < MusEGlobal::segmentSize) { unsigned lpos = MusEGlobal::song->lPos().frame(); // adjust loop start so we get exact loop len if (n > lpos) n = 0; writePos = lpos - n; } } WaveTrackList* tl = MusEGlobal::song->waves(); for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) { WaveTrack* track = *it; // Save time. Don't bother if track is off. Track On/Off not designed for rapid repeated response (but mute is). (p3.3.29) if(track->off()) continue; int ch = track->channels(); float* bp[ch]; if (track->prefetchFifo()->getWriteBuffer(ch, MusEGlobal::segmentSize, bp, writePos)) continue; track->fetchData(writePos, MusEGlobal::segmentSize, bp, doSeek); } writePos += MusEGlobal::segmentSize; }
void AudioPrefetch::prefetch(bool doSeek) { if (writePos == ~0U) { printf("AudioPrefetch::prefetch: invalid write position\n"); return; } if (song->loop() && !audio->bounce() && !extSyncFlag.value()) { const Pos& loop = song->rPos(); unsigned n = loop.frame() - writePos; if (n < segmentSize) { unsigned lpos = song->lPos().frame(); // adjust loop start so we get exact loop len if (n > lpos) n = 0; // printf("prefetch seek %d\n", writePos); writePos = lpos - n; } } WaveTrackList* tl = song->waves(); for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) { WaveTrack* track = *it; // p3.3.29 // Save time. Don't bother if track is off. Track On/Off not designed for rapid repeated response (but mute is). if (track->off()) continue; int ch = track->channels(); float* bp[ch]; // printf("prefetch %d\n", writePos); if (track->prefetchFifo()->getWriteBuffer(ch, segmentSize, bp, writePos)) { // printf("AudioPrefetch::prefetch No write buffer!\n"); // p3.3.46 Was getting this... continue; } //track->fetchData(writePos, segmentSize, bp); track->fetchData(writePos, segmentSize, bp, doSeek); // p3.3.41 //fprintf(stderr, "AudioPrefetch::prefetch data: segmentSize:%ld %e %e %e %e\n", segmentSize, bp[0][0], bp[0][1], bp[0][2], bp[0][3]); } writePos += segmentSize; }