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;
This file contains the base class for an audio sink.
This file contains the base class for an audio source.
The base class for an audio sink.
void sourceAllSamplesFlushed(void)
Tell the source that all samples have been flushed.
void sourceResumeOutput(void)
Tell the source that we are ready to accept more samples.
The base class for an audio source.
void sinkFlushSamples(void)
int sinkWriteSamples(const float *samples, int len)
Implements a "valve" for audio.
bool isOpen(void) const
Check if the valve is open.
bool isIdle(void) const
Check if the valve is idle.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
void resumeOutput(void)
Resume audio output to the sink.
void setOpen(bool do_open)
Open or close the valve.
AudioValve(void)
Default constuctor.
void setBlockWhenClosed(bool block_when_closed)
Setup audio stream blocking when valve is closed.
~AudioValve(void)
Destructor.
int writeSamples(const float *samples, int count)
Write samples into the valve.
void flushSamples(void)
Tell the valve to flush the previously written samples.
Namespace for the asynchronous programming classes.