28 #ifndef ASYNC_AUDIO_VALVE_INCLUDED 29 #define ASYNC_AUDIO_VALVE_INCLUDED 123 : block_when_closed(false), is_open(true),
124 is_idle(true), is_flushing(false), input_stopped(false)
144 if (is_open == do_open)
155 input_stopped =
false;
161 if (!is_idle && !is_flushing)
165 if (!block_when_closed && input_stopped)
167 input_stopped =
false;
190 if (block_when_closed == this->block_when_closed)
195 this->block_when_closed = block_when_closed;
197 if (!block_when_closed && input_stopped)
199 input_stopped =
false;
244 ret = (block_when_closed ? 0 : count);
249 input_stopped =
true;
292 input_stopped =
false;
307 bool was_flushing = is_flushing;
310 if (is_open && was_flushing)
323 bool block_when_closed;
void flushSamples(void)
Tell the valve to flush the previously written samples.
void sinkFlushSamples(void)
AudioValve(void)
Default constuctor.
void setBlockWhenClosed(bool block_when_closed)
Setup audio stream blocking when valve is closed.
void resumeOutput(void)
Resume audio output to the sink.
This file contains the base class for an audio source.
This file contains the base class for an audio sink.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
void setOpen(bool do_open)
Open or close the valve.
int writeSamples(const float *samples, int count)
Write samples into the valve.
~AudioValve(void)
Destructor.
int sinkWriteSamples(const float *samples, int len)
bool isOpen(void) const
Check if the valve is open.
The base class for an audio sink.
Namespace for the asynchronous programming classes.
bool isIdle(void) const
Check if the valve is idle.
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.
The base class for an audio source.
Implements a "valve" for audio.