Async 1.8.0
Async::AudioValve Class Reference

Implements a "valve" for audio. More...

#include <AsyncAudioValve.h>

Inheritance diagram for Async::AudioValve:
Async::AudioSink Async::AudioSource

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.
 
- Public Member Functions inherited from Async::AudioSink
 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.
 
AudioSourcesource (void) const
 Get the registered audio source.
 
- Public Member Functions inherited from Async::AudioSource
 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.
 
AudioSinksink (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

- Protected Member Functions inherited from Async::AudioSink
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.
 
AudioSinkhandler (void) const
 
- Protected Member Functions inherited from Async::AudioSource
int sinkWriteSamples (const float *samples, int len)
 
void sinkFlushSamples (void)
 
bool setHandler (AudioSource *handler)
 Setup another source to handle the outgoing audio.
 
AudioSourcehandler (void) const
 
void clearHandler (void)
 Clear a handler that was previously setup with setHandler.
 

Detailed Description

Implements a "valve" for audio.

Author
Tobias Blomberg / SM0SVX
Date
2006-07-08

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.

Constructor & Destructor Documentation

◆ AudioValve()

Async::AudioValve::AudioValve ( void )
inlineexplicit

Default constuctor.

Definition at line 122 of file AsyncAudioValve.h.

◆ ~AudioValve()

Async::AudioValve::~AudioValve ( void )
inline

Destructor.

Definition at line 131 of file AsyncAudioValve.h.

Member Function Documentation

◆ allSamplesFlushed()

virtual void Async::AudioValve::allSamplesFlushed ( void )
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().

◆ flushSamples()

void Async::AudioValve::flushSamples ( void )
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().

◆ isIdle()

bool Async::AudioValve::isIdle ( void ) const
inline

Check if the valve is idle.

Returns
Return true if the valve is idle or else false

Definition at line 217 of file AsyncAudioValve.h.

◆ isOpen()

bool Async::AudioValve::isOpen ( void ) const
inline

Check if the valve is open.

Returns
Return true if the valve is open or else false

Definition at line 208 of file AsyncAudioValve.h.

◆ resumeOutput()

void Async::AudioValve::resumeOutput ( void )
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().

◆ setBlockWhenClosed()

void Async::AudioValve::setBlockWhenClosed ( bool block_when_closed)
inline

Setup audio stream blocking when valve is closed.

Parameters
block_when_closedWhen 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().

◆ setOpen()

void Async::AudioValve::setOpen ( bool do_open)
inline

Open or close the valve.

Parameters
do_openIf 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().

◆ writeSamples()

int Async::AudioValve::writeSamples ( const float * samples,
int count )
inlinevirtual

Write samples into the valve.

Parameters
samplesThe buffer containing the samples
countThe number of samples in the buffer
Returns
Returns the number of samples that has been taken care of

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().


The documentation for this class was generated from the following file: