Async 1.9.1
Async::AudioStreamStateDetector Class Reference

Emit a signal when the state changes for the audio stream. More...

#include <AsyncAudioStreamStateDetector.h>

Inheritance diagram for Async::AudioStreamStateDetector:
Async::AudioPassthrough Async::AudioSink Async::AudioSource

Public Types

enum class  State { IDLE , ACTIVE , FLUSHING }
 An enum representing the stream state. More...

Public Member Functions

 AudioStreamStateDetector (void)
 Default constuctor.
virtual ~AudioStreamStateDetector (void) override
 Destructor.
virtual int writeSamples (const float *samples, int count) override
 Write samples into this audio sink.
virtual void flushSamples (void) override
 Tell the sink to flush the previously written samples.
virtual void allSamplesFlushed (void) override
 The registered sink has flushed all samples.
bool isIdle (void) const
 Check if the steam is idle or not.
bool isActive (void) const
 Check if the steam is active or not.
bool isFlushing (void) const
 Check if the steam is flushing or not.
State state (void) const
 Get the stream state.
Public Member Functions inherited from Async::AudioPassthrough
 AudioPassthrough (void)
 Default constuctor.
virtual ~AudioPassthrough (void)
 Destructor.
virtual void resumeOutput (void)
 Resume audio output to the sink.
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.

Public Attributes

sigc::signal< void(bool, bool)> sigStreamStateChanged
 A signal that is emitted when the stream state changes.
sigc::signal< void(bool)> sigStreamIsActive
 A signal that is emitted when stream activity state changes.
sigc::signal< void(bool)> sigStreamIsIdle
 A signal that is emitted when stream idle state changes.

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

Emit a signal when the state changes for the audio stream.

A class that just passes the audio through and emit signals when the stream state changes. The audio stream may be in three different states. In each of these states two booleans are set up.

State Active Idle IDLE false true ACTIVE true false FLUSHING false false

The stream state start at IDLE. When the audio stream source write a sample the state go to ACTIVE. When the audio stream source flush the stream the state go to FLUSHING. When the audio sink indicate that all samples has been flushed the state go to IDLE again.

Definition at line 125 of file AsyncAudioStreamStateDetector.h.

Member Enumeration Documentation

◆ State

An enum representing the stream state.

Enumerator
IDLE 

There are no samples left in the stream.

ACTIVE 

Samples have been written to the stream.

FLUSHING 

The stream source have requested stream flush.

Definition at line 132 of file AsyncAudioStreamStateDetector.h.

Constructor & Destructor Documentation

◆ AudioStreamStateDetector()

Async::AudioStreamStateDetector::AudioStreamStateDetector ( void )
inline

Default constuctor.

Definition at line 142 of file AsyncAudioStreamStateDetector.h.

◆ ~AudioStreamStateDetector()

virtual Async::AudioStreamStateDetector::~AudioStreamStateDetector ( void )
inlineoverridevirtual

Destructor.

Definition at line 147 of file AsyncAudioStreamStateDetector.h.

Member Function Documentation

◆ allSamplesFlushed()

virtual void Async::AudioStreamStateDetector::allSamplesFlushed ( void )
inlineoverridevirtual

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::AudioPassthrough.

Definition at line 187 of file AsyncAudioStreamStateDetector.h.

References Async::AudioPassthrough::allSamplesFlushed(), and IDLE.

◆ flushSamples()

virtual void Async::AudioStreamStateDetector::flushSamples ( void )
inlineoverridevirtual

Tell the sink to flush the previously written samples.

This function is used to tell the sink to flush previously written samples. When done flushing, the sink should call the sourceAllSamplesFlushed function. This function is normally only called from a connected source object.

Reimplemented from Async::AudioPassthrough.

Definition at line 174 of file AsyncAudioStreamStateDetector.h.

References FLUSHING, and Async::AudioPassthrough::flushSamples().

◆ isActive()

bool Async::AudioStreamStateDetector::isActive ( void ) const
inline

Check if the steam is active or not.

Returns
Returns true if the stream is active or false if it's not

Definition at line 204 of file AsyncAudioStreamStateDetector.h.

References ACTIVE.

◆ isFlushing()

bool Async::AudioStreamStateDetector::isFlushing ( void ) const
inline

Check if the steam is flushing or not.

Returns
Returns true if the stream is flushing or false if it's not

Definition at line 211 of file AsyncAudioStreamStateDetector.h.

References FLUSHING.

◆ isIdle()

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

Check if the steam is idle or not.

Returns
Returns true if the stream is idle or false if it's not

Definition at line 197 of file AsyncAudioStreamStateDetector.h.

References IDLE.

◆ state()

State Async::AudioStreamStateDetector::state ( void ) const
inline

Get the stream state.

Returns
Returns the state of the audio stream

Definition at line 217 of file AsyncAudioStreamStateDetector.h.

◆ writeSamples()

virtual int Async::AudioStreamStateDetector::writeSamples ( const float * samples,
int count )
inlineoverridevirtual

Write samples into this audio sink.

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 this audio sink. 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::AudioPassthrough.

Definition at line 160 of file AsyncAudioStreamStateDetector.h.

References ACTIVE, and Async::AudioPassthrough::writeSamples().

Member Data Documentation

◆ sigStreamIsActive

sigc::signal<void(bool)> Async::AudioStreamStateDetector::sigStreamIsActive

A signal that is emitted when stream activity state changes.

Parameters
is_activeIs true if the stream is active

Definition at line 230 of file AsyncAudioStreamStateDetector.h.

◆ sigStreamIsIdle

sigc::signal<void(bool)> Async::AudioStreamStateDetector::sigStreamIsIdle

A signal that is emitted when stream idle state changes.

Parameters
is_idleIs true if the stream is idle

Definition at line 236 of file AsyncAudioStreamStateDetector.h.

◆ sigStreamStateChanged

sigc::signal<void(bool, bool)> Async::AudioStreamStateDetector::sigStreamStateChanged

A signal that is emitted when the stream state changes.

Parameters
is_activeIs true if the stream is active
is_idleIs true if the stream is idle

Definition at line 224 of file AsyncAudioStreamStateDetector.h.


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