Async
0.18.0
|
00001 00028 #ifndef ASYNC_AUDIO_SINK_INCLUDED 00029 #define ASYNC_AUDIO_SINK_INCLUDED 00030 00031 00032 /**************************************************************************** 00033 * 00034 * System Includes 00035 * 00036 ****************************************************************************/ 00037 00038 00039 #include <cassert> 00040 00041 00042 /**************************************************************************** 00043 * 00044 * Project Includes 00045 * 00046 ****************************************************************************/ 00047 00048 00049 00050 /**************************************************************************** 00051 * 00052 * Local Includes 00053 * 00054 ****************************************************************************/ 00055 00056 00057 00058 /**************************************************************************** 00059 * 00060 * Forward declarations 00061 * 00062 ****************************************************************************/ 00063 00064 00065 00066 /**************************************************************************** 00067 * 00068 * Namespace 00069 * 00070 ****************************************************************************/ 00071 00072 namespace Async 00073 { 00074 00075 00076 /**************************************************************************** 00077 * 00078 * Forward declarations of classes inside of the declared namespace 00079 * 00080 ****************************************************************************/ 00081 00082 class AudioSource; 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 00115 class AudioSink 00116 { 00117 public: 00121 AudioSink(void) : m_source(0), m_handler(0) {} 00122 00126 virtual ~AudioSink(void); 00127 00133 bool registerSource(AudioSource *source); 00134 00138 void unregisterSource(void); 00139 00144 bool isRegistered(void) const { return m_source != 0; } 00145 00151 AudioSource *source(void) const { return m_source; } 00152 00164 virtual int writeSamples(const float *samples, int count) 00165 { 00166 assert(m_handler != 0); 00167 return m_handler->writeSamples(samples, count); 00168 } 00169 00178 virtual void flushSamples(void) 00179 { 00180 assert(m_handler != 0); 00181 m_handler->flushSamples(); 00182 } 00183 00184 00185 protected: 00189 void sourceResumeOutput(void); 00190 00199 void sourceAllSamplesFlushed(void); 00200 00210 bool setHandler(AudioSink *handler); 00211 00215 void clearHandler(void); 00216 00217 /* 00218 * @brief Return the handler 00219 * @return Returns the handler previously set with setHandler or 0 00220 * if none have been set 00221 */ 00222 AudioSink *handler(void) const { return m_handler; } 00223 00224 00225 private: 00226 AudioSource *m_source; 00227 AudioSink *m_handler; 00228 bool m_auto_unreg_sink; 00229 00230 bool registerSourceInternal(AudioSource *source, bool reg_sink); 00231 00232 }; /* class AudioSink */ 00233 00234 00235 } /* namespace */ 00236 00237 #endif /* ASYNC_AUDIO_SINK_INCLUDED */ 00238 00239 00240 00241 /* 00242 * This file has not been truncated 00243 */ 00244