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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <AsyncAudioSink.h>
00049 #include <AsyncAudioSource.h>
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 namespace Async
00075 {
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
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 };
00280
00281
00282 }
00283
00284 #endif
00285
00286
00287
00288
00289
00290