BufferingAudioReader::BufferingAudioReader (AudioFormatReader* sourceReader, TimeSliceThread& timeSliceThread, int samplesToBuffer) : AudioFormatReader (nullptr, sourceReader->getFormatName()), source (sourceReader), thread (timeSliceThread), nextReadPosition (0), numBlocks (1 + (samplesToBuffer / samplesPerBlock)) { sampleRate = source->sampleRate; lengthInSamples = source->lengthInSamples; numChannels = source->numChannels; metadataValues = source->metadataValues; bitsPerSample = 32; usesFloatingPointData = true; for (int i = 3; --i >= 0;) readNextBufferChunk(); timeSliceThread.addTimeSliceClient (this); }
int BufferingAudioSource::useTimeSlice() { return readNextBufferChunk() ? 1 : 100; }