Async 1.8.0
|
Implements a "valve" for audio. More...
#include <AsyncAudioValve.h>
Public Member Functions | |
AudioValve (void) | |
Default constuctor. | |
~AudioValve (void) | |
Destructor. | |
void | setOpen (bool do_open) |
Open or close the valve. | |
void | setBlockWhenClosed (bool block_when_closed) |
Setup audio stream blocking when valve is closed. | |
bool | isOpen (void) const |
Check if the valve is open. | |
bool | isIdle (void) const |
Check if the valve is idle. | |
int | writeSamples (const float *samples, int count) |
Write samples into the valve. | |
void | flushSamples (void) |
Tell the valve to flush the previously written samples. | |
void | resumeOutput (void) |
Resume audio output to the sink. | |
virtual void | allSamplesFlushed (void) |
The registered sink has flushed all samples. | |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
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. | |
Implements a "valve" for audio.
This class implements a "valve" for audio. That is, the audio stream can be turned on or off. It's named "valve" since the whole Async audio concept is called audio pipe.
Definition at line 116 of file AsyncAudioValve.h.
|
inlineexplicit |
Default constuctor.
Definition at line 122 of file AsyncAudioValve.h.
|
inline |
Destructor.
Definition at line 131 of file AsyncAudioValve.h.
|
inlinevirtual |
The registered sink has flushed all samples.
This function must be implemented by the inheriting class. This function will be called when all samples have been flushed in the registered sink.
Reimplemented from Async::AudioSource.
Definition at line 305 of file AsyncAudioValve.h.
References Async::AudioSink::sourceAllSamplesFlushed().
|
inlinevirtual |
Tell the valve to flush the previously written samples.
This function is used to tell the valve to flush previously written samples. When done flushing, the valve will call the allSamplesFlushed function in the connected source object. This function is normally only called from a connected source object.
Reimplemented from Async::AudioSink.
Definition at line 263 of file AsyncAudioValve.h.
References Async::AudioSource::sinkFlushSamples(), and Async::AudioSink::sourceAllSamplesFlushed().
|
inline |
Check if the valve is idle.
Definition at line 217 of file AsyncAudioValve.h.
|
inline |
Check if the valve is open.
Definition at line 208 of file AsyncAudioValve.h.
|
inlinevirtual |
Resume audio output to the sink.
This function must be reimplemented by the inheriting class. It 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.
Definition at line 286 of file AsyncAudioValve.h.
References Async::AudioSink::sourceResumeOutput().
|
inline |
Setup audio stream blocking when valve is closed.
block_when_closed | When true, block the incoming audio stream when the valve is closed. When false, incoming audio is thrown away when the valve is closed. |
Use this method to set if the valve should block or drop the incoming audio stream when the valve is closed.
Definition at line 188 of file AsyncAudioValve.h.
References Async::AudioSink::sourceResumeOutput().
|
inline |
Open or close the valve.
do_open | If true the valve is open or else it's closed |
This function is used to open or close the audio valve. When the valve is closed, the connected sink is flushed. What is done with the incoming audio when the valve is closed depends on the block_when_closed parameter to the constructor.
Definition at line 142 of file AsyncAudioValve.h.
References Async::AudioSource::sinkFlushSamples(), Async::AudioSink::sourceAllSamplesFlushed(), and Async::AudioSink::sourceResumeOutput().
|
inlinevirtual |
Write samples into the valve.
samples | The buffer containing the samples |
count | The number of samples in the buffer |
This function is used to write audio into the valve. 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.
Definition at line 233 of file AsyncAudioValve.h.
References Async::AudioSource::sinkWriteSamples().