00001
00030 #ifndef SAMPLE_FIFO_INCLUDED
00031 #define SAMPLE_FIFO_INCLUDED
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <sigc++/signal_system.h>
00041
00042 #include <string>
00043
00044
00045
00046
00047
00048
00049
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
00075 namespace Async
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
00108
00116 class SampleFifo : public SigC::Object
00117 {
00118 public:
00122 explicit SampleFifo(int fifo_size);
00123
00127 ~SampleFifo(void);
00128
00135 int addSamples(short *samples, int count);
00136
00150 void stopOutput(bool stop);
00151
00156 bool empty(void) const { return tail == head; }
00157
00166 bool full(void) const;
00167
00172 unsigned samplesInFifo(void) const;
00173
00188 void writeBufferFull(bool is_full);
00189
00201 void setOverwrite(bool overwrite) { do_overwrite = overwrite; }
00202
00215 bool overwrite(void) const { return do_overwrite; }
00216
00229 int readSamples(short *samples, int count);
00230
00234 void clear(void) { tail = head; allSamplesWritten(); }
00235
00241 void setPrebufSamples(unsigned prebuf_samples);
00242
00246 void flushSamples(void);
00247
00252 void setDebugName(const std::string& name) { debug_name = name; }
00253
00254
00260 SigC::Signal1<void, bool> fifoFull;
00261
00262
00281 SigC::Signal2<int, short *, int> writeSamples;
00282
00293 SigC::Signal0<void> allSamplesWritten;
00294
00295
00296 protected:
00297
00298 private:
00299 short *fifo;
00300 int fifo_size;
00301 int head, tail;
00302 bool is_stopped;
00303 bool do_overwrite;
00304 bool write_buffer_is_full;
00305
00306 unsigned prebuf_samples;
00307 bool prebuf;
00308 bool do_flush;
00309 std::string debug_name;
00310
00311 void writeSamplesFromFifo(void);
00312
00313 };
00314
00315
00316 }
00317
00318 #endif
00319
00320
00321
00322
00323
00324