Async 1.8.0
|
A threadsafe audio source base class. More...
#include <AsyncAudioThreadSource.h>
Public Member Functions | |
AudioThreadSource (void) | |
Default constructor. | |
AudioThreadSource (const AudioThreadSource &)=delete | |
No copy constructor. | |
virtual | ~AudioThreadSource (void) |
Destructor. | |
AudioThreadSource & | operator= (const AudioThreadSource &)=delete |
![]() | |
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 int | sinkWriteSamples (const float *samples, int count) |
Queue samples for delivery to the connected sink. | |
virtual void | sinkFlushSamples (void) |
Flush samples in the connected sink when the queue is empty. | |
void | waitForAllSamplesFlushed (void) |
Block execution until all samples have been flushed. | |
![]() | |
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 threadsafe audio source base class.
This is a base class for writing threadsafe audio source classes. This is of use when the audio source is running in a separate thread, not in the Async main thread.
Note that all administrative functions like connecting and disconnecting sinks must be executed from the main Async thread. The same goes for destroying an object. It is only the functions sinkWriteSamples and sinkFlushSamples that are threadsafe.
Definition at line 125 of file AsyncAudioThreadSource.h.
|
inline |
Default constructor.
Definition at line 131 of file AsyncAudioThreadSource.h.
|
delete |
No copy constructor.
|
inlinevirtual |
Destructor.
Definition at line 141 of file AsyncAudioThreadSource.h.
References Async::Application::app().
|
delete |
|
inlineprotectedvirtual |
Flush samples in the connected sink when the queue is empty.
This function is used to tell the connected sink to flush previously written samples when the queue is empty. If the writeSamples function is called before the queue is empty, the flush is cancelled.
Definition at line 183 of file AsyncAudioThreadSource.h.
|
inlineprotectedvirtual |
Queue samples for delivery to the connected sink.
samples | The buffer containing the samples |
count | The number of samples in the buffer |
This function is used to queue audio for later delivery to the connected audio sink. If a flush is pending, calling this function will cancel the flush.
Definition at line 161 of file AsyncAudioThreadSource.h.
|
inlineprotected |
Block execution until all samples have been flushed.
This function can be used to wait until the sink has flushed all sampled written to it. Note that calling this function must be preceeded by a call to sinkFlushSamples or it will block forever.
Definition at line 203 of file AsyncAudioThreadSource.h.