Async 1.8.0
|
A FIFO class for handling audio samples. More...
#include <AsyncAudioJitterFifo.h>
Public Member Functions | |
AudioJitterFifo (unsigned fifo_size) | |
Constuctor. | |
virtual | ~AudioJitterFifo (void) |
Destructor. | |
void | setSize (unsigned new_size) |
Set the size of the FIFO. | |
bool | empty (void) const |
Check if the FIFO is empty. | |
unsigned | samplesInFifo (void) const |
Find out how many samples there are in the FIFO. | |
void | clear (void) |
Clear all samples from the FIFO. | |
virtual int | writeSamples (const float *samples, int count) |
Write samples into the FIFO. | |
virtual void | flushSamples (void) |
Tell the FIFO to flush the previously written samples. | |
virtual void | resumeOutput (void) |
Resume audio output to the connected sink. | |
![]() | |
AudioSink (void) | |
Default constuctor. | |
virtual | ~AudioSink (void) |
Destructor. | |
bool | registerSource (AudioSource *source) |
Register an audio source to provide samples to this sink. | |
void | unregisterSource (void) |
Unregister the previously registered audio source. | |
bool | isRegistered (void) const |
Check if an audio source has been registered. | |
AudioSource * | source (void) const |
Get the registered audio source. | |
![]() | |
AudioSource (void) | |
Default constuctor. | |
virtual | ~AudioSource (void) |
Destructor. | |
bool | registerSink (AudioSink *sink, bool managed=false) |
Register an audio sink to provide samples to. | |
void | unregisterSink (void) |
Unregister the previously registered audio sink. | |
bool | isRegistered (void) const |
Check if an audio sink has been registered. | |
AudioSink * | sink (void) const |
Get the registered audio sink. | |
bool | sinkManaged (void) const |
Check if the sink is managed or not. | |
void | handleAllSamplesFlushed (void) |
The registered sink has flushed all samples. | |
Protected Member Functions | |
virtual void | allSamplesFlushed (void) |
The registered sink has flushed all samples. | |
![]() | |
void | sourceResumeOutput (void) |
Tell the source that we are ready to accept more samples. | |
void | sourceAllSamplesFlushed (void) |
Tell the source that all samples have been flushed. | |
bool | setHandler (AudioSink *handler) |
Setup another sink to handle the incoming audio. | |
void | clearHandler (void) |
Clear a handler that was previously setup with setHandler. | |
AudioSink * | handler (void) const |
![]() | |
int | sinkWriteSamples (const float *samples, int len) |
void | sinkFlushSamples (void) |
bool | setHandler (AudioSource *handler) |
Setup another source to handle the outgoing audio. | |
AudioSource * | handler (void) const |
void | clearHandler (void) |
Clear a handler that was previously setup with setHandler. | |
A FIFO class for handling audio samples.
This class implements a jitter-tolerant FIFO for handling audio samples. The FIFO is intended to buffer samples that arrive with a certain amount of sample rate or packet jitter. Under normal operation, the FIFO is kept half full. Varying sample rates or packet rates slowly move the amount of samples out of center. When the FIFO reaches a full or empty state, it is automatically reset to the half-full state.
Definition at line 120 of file AsyncAudioJitterFifo.h.
|
explicit |
Constuctor.
fifo_size | This is the size of the fifo expressed in number of samples. |
|
virtual |
Destructor.
|
protectedvirtual |
The registered sink has flushed all samples.
This function will be called when all samples have been flushed in the registered sink. This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
void Async::AudioJitterFifo::clear | ( | void | ) |
Clear all samples from the FIFO.
This will immediately reset the FIFO and discard all samples. The source will be told that all samples have been flushed.
|
inline |
Check if the FIFO is empty.
Definition at line 149 of file AsyncAudioJitterFifo.h.
|
virtual |
Tell the FIFO to flush the previously written samples.
This function is used to tell the FIFO to flush previously written samples. This function is normally only called from a connected source object.
Reimplemented from Async::AudioSink.
|
virtual |
Resume audio output to the connected sink.
This function will be called when the registered audio sink is ready to accept more samples. This function is normally only called from a connected sink object.
Reimplemented from Async::AudioSource.
unsigned Async::AudioJitterFifo::samplesInFifo | ( | void | ) | const |
Find out how many samples there are in the FIFO.
void Async::AudioJitterFifo::setSize | ( | unsigned | new_size | ) |
Set the size of the FIFO.
new_size | This is the size of the fifo expressed in number of samples. |
Use this function to set the size of the FIFO. In doing this, the FIFO will also be cleared.
|
virtual |
Write samples into the FIFO.
samples | The buffer containing the samples |
count | The number of samples in the buffer |
This function is used to write audio into the FIFO. If it returns 0, no more samples should be written until the resumeOutput function in the source have been called. This function is normally only called from a connected source object.
Reimplemented from Async::AudioSink.