AsyncAudioStreamStateDetector.h

Go to the documentation of this file.
00001 
00029 #ifndef ASYNC_AUDIO_STREAM_STATE_DETECTOR_INCLUDED
00030 #define ASYNC_AUDIO_STREAM_STATE_DETECTOR_INCLUDED
00031 
00032 
00033 /****************************************************************************
00034  *
00035  * System Includes
00036  *
00037  ****************************************************************************/
00038 
00039 #include <sigc++/sigc++.h>
00040 
00041 
00042 /****************************************************************************
00043  *
00044  * Project Includes
00045  *
00046  ****************************************************************************/
00047 
00048 #include <AsyncAudioPassthrough.h>
00049 
00050 
00051 /****************************************************************************
00052  *
00053  * Local Includes
00054  *
00055  ****************************************************************************/
00056 
00057 
00058 
00059 /****************************************************************************
00060  *
00061  * Forward declarations
00062  *
00063  ****************************************************************************/
00064 
00065 
00066 
00067 /****************************************************************************
00068  *
00069  * Namespace
00070  *
00071  ****************************************************************************/
00072 
00073 namespace Async
00074 {
00075 
00076 
00077 /****************************************************************************
00078  *
00079  * Forward declarations of classes inside of the declared namespace
00080  *
00081  ****************************************************************************/
00082 
00083   
00084 
00085 /****************************************************************************
00086  *
00087  * Defines & typedefs
00088  *
00089  ****************************************************************************/
00090 
00091 
00092 
00093 /****************************************************************************
00094  *
00095  * Exported Global Variables
00096  *
00097  ****************************************************************************/
00098 
00099 
00100 
00101 /****************************************************************************
00102  *
00103  * Class definitions
00104  *
00105  ****************************************************************************/
00106 
00111 class AudioStreamStateDetector : public AudioPassthrough, public SigC::Object
00112 {
00113   public:
00117     AudioStreamStateDetector(void) : stream_state(STREAM_IDLE) {}
00118   
00122     virtual ~AudioStreamStateDetector(void) {}
00123   
00135     virtual int writeSamples(const float *samples, int count)
00136     {
00137       if (stream_state != STREAM_ACTIVE)
00138       {
00139         stream_state = STREAM_ACTIVE;
00140         sigStreamStateChanged(true, false);
00141       }
00142       return AudioPassthrough::writeSamples(samples, count);
00143     }
00144     
00153     virtual void flushSamples(void)
00154     {
00155       if (stream_state != STREAM_FLUSHING)
00156       {
00157         stream_state = STREAM_FLUSHING;
00158         sigStreamStateChanged(false, false);
00159       }
00160       AudioPassthrough::flushSamples();
00161     }
00162     
00170     virtual void allSamplesFlushed(void)
00171     {
00172       if (stream_state != STREAM_IDLE)
00173       {
00174         stream_state = STREAM_IDLE;
00175         sigStreamStateChanged(false, true);
00176       }
00177       AudioPassthrough::allSamplesFlushed();
00178     }
00179 
00184     bool isIdle(void)     const { return (stream_state == STREAM_IDLE); }
00185 
00191     bool isActive(void)   const { return (stream_state == STREAM_ACTIVE); }
00192 
00198     bool isFlushing(void) const { return (stream_state == STREAM_FLUSHING); }
00199     
00205     SigC::Signal2<void, bool, bool> sigStreamStateChanged;
00206     
00207     
00208   private:
00209     AudioStreamStateDetector(const AudioStreamStateDetector&);
00210     AudioStreamStateDetector& operator=(const AudioStreamStateDetector&);
00211 
00212     typedef enum
00213     {
00214       STREAM_IDLE, STREAM_ACTIVE, STREAM_FLUSHING
00215     } StreamState;
00216 
00217     StreamState stream_state;
00218     
00219 }; /* AudioStreamStateDetector */
00220 
00221 
00222 } /* namespace */
00223 
00224 #endif /* ASYNC_AUDIO_STREAM_STATE_DETECTOR_INCLUDED */
00225 
00226 
00227 
00228 /*
00229  * This file has not been truncated
00230  */
00231 
Generated by  doxygen 1.6.2-20100208