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
00142 void setSize(unsigned new_size);
00143
00148 bool empty(void) const { return !is_full && (tail == head); }
00149
00158 bool full(void) const { return is_full; }
00159
00166 unsigned samplesInFifo(bool ignore_prebuf=false) const;
00167
00179 void setOverwrite(bool overwrite) { do_overwrite = overwrite; }
00180
00193 bool overwrite(void) const { return do_overwrite; }
00194
00201 void clear(void);
00202
00208 void setPrebufSamples(unsigned prebuf_samples);
00209
00221 void enableBuffering(bool enable);
00222
00227 bool bufferingEnabled(void) const { return buffering_enabled; }
00228
00240 virtual int writeSamples(const float *samples, int count);
00241
00249 virtual void flushSamples(void);
00250
00258 virtual void resumeOutput(void);
00259
00260
00261 protected:
00269 virtual void allSamplesFlushed(void);
00270
00271
00272 private:
00273 float *fifo;
00274 unsigned fifo_size;
00275 unsigned head, tail;
00276 bool do_overwrite;
00277 bool output_stopped;
00278 unsigned prebuf_samples;
00279 bool prebuf;
00280 bool is_flushing;
00281 bool is_full;
00282 bool buffering_enabled;
00283 bool disable_buffering_when_flushed;
00284 bool is_idle;
00285 bool input_stopped;
00286
00287 void writeSamplesFromFifo(void);
00288
00289 };
00290
00291
00292 }
00293
00294 #endif
00295
00296
00297
00298
00299
00300