An AudioSource which takes another source as input, and buffers it using a thread.
More...
#include <juce_BufferingAudioSource.h>
An AudioSource which takes another source as input, and buffers it using a thread.
Create this as a wrapper around another thread, and it will read-ahead with a background thread to smooth out playback. You can either create one of these directly, or use it indirectly using an AudioTransportSource.
- See also
- PositionableAudioSource, AudioTransportSource
◆ BufferingAudioSource()
BufferingAudioSource::BufferingAudioSource |
( |
PositionableAudioSource * |
source, |
|
|
TimeSliceThread & |
backgroundThread, |
|
|
bool |
deleteSourceWhenDeleted, |
|
|
int |
numberOfSamplesToBuffer, |
|
|
int |
numberOfChannels = 2 , |
|
|
bool |
prefillBufferOnPrepareToPlay = true |
|
) |
| |
Creates a BufferingAudioSource.
- Parameters
-
source | the input source to read from |
backgroundThread | a background thread that will be used for the background read-ahead. This object must not be deleted until after any BufferingAudioSources that are using it have been deleted! |
deleteSourceWhenDeleted | if true, then the input source object will be deleted when this object is deleted |
numberOfSamplesToBuffer | the size of buffer to use for reading ahead |
numberOfChannels | the number of channels that will be played |
prefillBufferOnPrepareToPlay | if true, then calling prepareToPlay on this object will block until the buffer has been filled |
◆ ~BufferingAudioSource()
BufferingAudioSource::~BufferingAudioSource |
( |
| ) |
|
Destructor.
The input source may be deleted depending on whether the deleteSourceWhenDeleted flag was set in the constructor.
◆ getNextAudioBlock()
◆ getNextReadPosition()
int64 BufferingAudioSource::getNextReadPosition |
( |
| ) |
const |
|
overridevirtual |
◆ getTotalLength()
int64 BufferingAudioSource::getTotalLength |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ isLooping()
bool BufferingAudioSource::isLooping |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ prepareToPlay()
void BufferingAudioSource::prepareToPlay |
( |
int |
samplesPerBlockExpected, |
|
|
double |
sampleRate |
|
) |
| |
|
overridevirtual |
◆ readBufferSection()
void BufferingAudioSource::readBufferSection |
( |
int64 |
start, |
|
|
int |
length, |
|
|
int |
bufferOffset |
|
) |
| |
|
private |
◆ readNextBufferChunk()
bool BufferingAudioSource::readNextBufferChunk |
( |
| ) |
|
|
private |
◆ releaseResources()
void BufferingAudioSource::releaseResources |
( |
| ) |
|
|
overridevirtual |
◆ setLooping()
virtual void PositionableAudioSource::setLooping |
( |
bool |
shouldLoop | ) |
|
|
inlinevirtualinherited |
◆ setNextReadPosition()
void BufferingAudioSource::setNextReadPosition |
( |
int64 |
newPosition | ) |
|
|
overridevirtual |
◆ useTimeSlice()
int BufferingAudioSource::useTimeSlice |
( |
| ) |
|
|
overrideprivatevirtual |
Called back by a TimeSliceThread.
When you register this class with it, a TimeSliceThread will repeatedly call this method.
The implementation of this method should use its time-slice to do something that's quick - never block for longer than absolutely necessary.
- Returns
- Your method should return the number of milliseconds which it would like to wait before being called again. Returning 0 will make the thread call again as soon as possible (after possibly servicing other busy clients). If you return a value below zero, your client will be removed from the list of clients, and won't be called again. The value you specify isn't a guaranteee, and is only used as a hint by the thread - the actual time before the next callback may be more or less than specified. You can force the TimeSliceThread to wake up and poll again immediately by calling its notify() method.
Implements TimeSliceClient.
◆ waitForNextAudioBlockReady()
A useful function to block until the next the buffer info can be filled.
This is useful for offline rendering.
◆ backgroundThread
◆ buffer
◆ bufferReadyEvent
◆ bufferStartPosLock
◆ bufferValidEnd
int64 volatile BufferingAudioSource::bufferValidEnd |
|
private |
◆ bufferValidStart
int64 volatile BufferingAudioSource::bufferValidStart |
|
private |
◆ isPrepared
bool BufferingAudioSource::isPrepared |
|
private |
◆ nextPlayPos
int64 volatile BufferingAudioSource::nextPlayPos |
|
private |
◆ numberOfChannels
int BufferingAudioSource::numberOfChannels |
|
private |
◆ numberOfSamplesToBuffer
int BufferingAudioSource::numberOfSamplesToBuffer |
|
private |
◆ prefillBuffer
bool BufferingAudioSource::prefillBuffer |
|
private |
◆ sampleRate
double volatile BufferingAudioSource::sampleRate |
|
private |
◆ source
◆ wasSourceLooping
bool BufferingAudioSource::wasSourceLooping |
|
private |
The documentation for this class was generated from the following file: