AsyncAudioFifo.h

Go to the documentation of this file.
00001 
00030 #ifndef ASYNC_AUDIO_FIFO_INCLUDED
00031 #define ASYNC_AUDIO_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 
00119 class AudioFifo : public AudioSink, public AudioSource
00120 {
00121   public:
00127     explicit AudioFifo(unsigned fifo_size);
00128   
00132     virtual ~AudioFifo(void);
00133   
00138     bool empty(void) const { return !is_full && (tail == head); }
00139     
00148     bool full(void) const { return is_full; }
00149     
00156     unsigned samplesInFifo(bool ignore_prebuf=false) const;
00157     
00169     void setOverwrite(bool overwrite) { do_overwrite = overwrite; }
00170     
00183     bool overwrite(void) const { return do_overwrite; }
00184     
00191     void clear(void);
00192 
00198     void setPrebufSamples(unsigned prebuf_samples);
00199     
00211     void enableBuffering(bool enable);
00212     
00217     bool bufferingEnabled(void) const { return buffering_enabled; }
00218     
00230     virtual int writeSamples(const float *samples, int count);
00231     
00239     virtual void flushSamples(void);
00240     
00248     virtual void resumeOutput(void);
00249     
00250     
00251   protected:
00259     virtual void allSamplesFlushed(void);
00260     
00261     
00262   private:    
00263     float       *fifo;
00264     unsigned    fifo_size;
00265     unsigned    head, tail;
00266     bool        do_overwrite;
00267     bool        output_stopped;
00268     unsigned    prebuf_samples;
00269     bool        prebuf;
00270     bool        is_flushing;
00271     bool        is_full;
00272     bool        buffering_enabled;
00273     bool        disable_buffering_when_flushed;
00274     bool        is_idle;
00275     bool        input_stopped;
00276     
00277     void writeSamplesFromFifo(void);
00278 
00279 };  /* class AudioFifo */
00280 
00281 
00282 } /* namespace */
00283 
00284 #endif /* ASYNC_AUDIO_FIFO_INCLUDED */
00285 
00286 
00287 /*
00288  * This file has not been truncated
00289  */
00290 
Generated by  doxygen 1.6.2-20100208