Async  0.18.0
AsyncAudioJitterFifo.h
Go to the documentation of this file.
00001 
00030 #ifndef ASYNC_AUDIO_JITTER_FIFO_INCLUDED
00031 #define ASYNC_AUDIO_JITTER_FIFO_INCLUDED
00032 
00033 
00034 /****************************************************************************
00035  *
00036  * System Includes
00037  *
00038  ****************************************************************************/
00039 
00040 
00041 
00042 /****************************************************************************
00043  *
00044  * Project Includes
00045  *
00046  ****************************************************************************/
00047 
00048 #include <AsyncAudioSink.h>
00049 #include <AsyncAudioSource.h>
00050 
00051 
00052 /****************************************************************************
00053  *
00054  * Local Includes
00055  *
00056  ****************************************************************************/
00057 
00058 
00059 
00060 /****************************************************************************
00061  *
00062  * Forward declarations
00063  *
00064  ****************************************************************************/
00065 
00066 
00067 
00068 /****************************************************************************
00069  *
00070  * Namespace
00071  *
00072  ****************************************************************************/
00073 
00074 namespace Async
00075 {
00076 
00077 
00078 /****************************************************************************
00079  *
00080  * Forward declarations of classes inside of the declared namespace
00081  *
00082  ****************************************************************************/
00083 
00084   
00085 
00086 /****************************************************************************
00087  *
00088  * Defines & typedefs
00089  *
00090  ****************************************************************************/
00091 
00092 
00093 
00094 /****************************************************************************
00095  *
00096  * Exported Global Variables
00097  *
00098  ****************************************************************************/
00099 
00100 
00101 
00102 /****************************************************************************
00103  *
00104  * Class definitions
00105  *
00106  ****************************************************************************/
00107 
00120 class AudioJitterFifo : public AudioSink, public AudioSource
00121 {
00122   public:
00128     explicit AudioJitterFifo(unsigned fifo_size);
00129   
00133     virtual ~AudioJitterFifo(void);
00134   
00143     void setSize(unsigned new_size);
00144     
00149     bool empty(void) const { return (tail == head); }
00150     
00155     unsigned samplesInFifo(void) const;
00156     
00163     void clear(void);
00164 
00176     virtual int writeSamples(const float *samples, int count);
00177     
00185     virtual void flushSamples(void);
00186     
00194     virtual void resumeOutput(void);
00195     
00196     
00197   protected:
00205     virtual void allSamplesFlushed(void);
00206     
00207     
00208   private:
00209     float       *fifo;
00210     unsigned    fifo_size;
00211     unsigned    head, tail;
00212     bool        output_stopped;
00213     bool        prebuf;
00214     bool        is_flushing;
00215     
00216     void writeSamplesFromFifo(void);
00217 
00218 };  /* class AudioJitterFifo */
00219 
00220 
00221 } /* namespace */
00222 
00223 #endif /* ASYNC_AUDIO_JITTER_FIFO_INCLUDED */
00224 
00225 
00226 /*
00227  * This file has not been truncated
00228  */
00229