Async  1.5.0
AsyncAudioJitterFifo.h
Go to the documentation of this file.
1 
30 #ifndef ASYNC_AUDIO_JITTER_FIFO_INCLUDED
31 #define ASYNC_AUDIO_JITTER_FIFO_INCLUDED
32 
33 
34 /****************************************************************************
35  *
36  * System Includes
37  *
38  ****************************************************************************/
39 
40 
41 
42 /****************************************************************************
43  *
44  * Project Includes
45  *
46  ****************************************************************************/
47 
48 #include <AsyncAudioSink.h>
49 #include <AsyncAudioSource.h>
50 
51 
52 /****************************************************************************
53  *
54  * Local Includes
55  *
56  ****************************************************************************/
57 
58 
59 
60 /****************************************************************************
61  *
62  * Forward declarations
63  *
64  ****************************************************************************/
65 
66 
67 
68 /****************************************************************************
69  *
70  * Namespace
71  *
72  ****************************************************************************/
73 
74 namespace Async
75 {
76 
77 
78 /****************************************************************************
79  *
80  * Forward declarations of classes inside of the declared namespace
81  *
82  ****************************************************************************/
83 
84 
85 
86 /****************************************************************************
87  *
88  * Defines & typedefs
89  *
90  ****************************************************************************/
91 
92 
93 
94 /****************************************************************************
95  *
96  * Exported Global Variables
97  *
98  ****************************************************************************/
99 
100 
101 
102 /****************************************************************************
103  *
104  * Class definitions
105  *
106  ****************************************************************************/
107 
120 class AudioJitterFifo : public AudioSink, public AudioSource
121 {
122  public:
128  explicit AudioJitterFifo(unsigned fifo_size);
129 
133  virtual ~AudioJitterFifo(void);
134 
143  void setSize(unsigned new_size);
144 
149  bool empty(void) const { return (tail == head); }
150 
155  unsigned samplesInFifo(void) const;
156 
163  void clear(void);
164 
176  virtual int writeSamples(const float *samples, int count);
177 
185  virtual void flushSamples(void);
186 
194  virtual void resumeOutput(void);
195 
196 
197  protected:
205  virtual void allSamplesFlushed(void);
206 
207 
208  private:
209  float *fifo;
210  unsigned fifo_size;
211  unsigned head, tail;
212  bool output_stopped;
213  bool prebuf;
214  bool is_flushing;
215 
216  void writeSamplesFromFifo(void);
217 
218 }; /* class AudioJitterFifo */
219 
220 
221 } /* namespace */
222 
223 #endif /* ASYNC_AUDIO_JITTER_FIFO_INCLUDED */
224 
225 
226 /*
227  * This file has not been truncated
228  */
229 
A FIFO class for handling audio samples.
unsigned samplesInFifo(void) const
Find out how many samples there are in the FIFO.
virtual ~AudioJitterFifo(void)
Destructor.
This file contains the base class for an audio source.
virtual void flushSamples(void)
Tell the FIFO to flush the previously written samples.
This file contains the base class for an audio sink.
AudioJitterFifo(unsigned fifo_size)
Constuctor.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
virtual int writeSamples(const float *samples, int count)
Write samples into the FIFO.
The base class for an audio sink.
Namespace for the asynchronous programming classes.
void setSize(unsigned new_size)
Set the size of the FIFO.
void clear(void)
Clear all samples from the FIFO.
The base class for an audio source.
virtual void resumeOutput(void)
Resume audio output to the connected sink.
bool empty(void) const
Check if the FIFO is empty.