CSL  5.2
NullIO.h
Go to the documentation of this file.
1 //
2 // NullIO.h -- Raw driver IO object and StandardIO
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 //
5 
6 #ifndef CSL_NULLIO_H
7 #define CSL_NULLIO_H
8 
9 #include "CSL_Core.h"
10 
11 #include "ThreadUtilities.h" // Thread util classes (used only by NullIO)
12 
13 //#include "ThreadedFrameStream.h"
14 
15 namespace csl {
16 
17 ///
18 /// NullIO is an IO that uses a thread and a timer to call its graph's nextBuffer(); it doesn't do
19 /// anything with the resulting buffer, but assumes that other objects (observers of the graph)
20 /// will handle some actual IO.
21 ///
22 
23 class NullIO : public IO, public ThreadPthread {
24 public:
25  NullIO(); ///< Constructor
26  NullIO(unsigned s_rate, unsigned b_size,
27  int in_device = 0, int out_device = 0,
28  unsigned in_chans = 0, unsigned out_chans = 2);
29  virtual ~NullIO();
30 
31  virtual void start() throw(CException); ///< start my timer thread
32  virtual void stop() throw(CException); ///< stop the timer thread
33  virtual Buffer & getInput() throw(CException) { return mInputBuffer; };
34  virtual Buffer & getInput(unsigned numFrames, unsigned numChannels) throw(CException) { return mInputBuffer; };
35 
36 protected:
37  bool mRunning; /// whether or not I'm running
38  juce::Thread * mThread; ///< my timer thread
39  Synch * mSynch; ///< the sync I wait on
40  static void * FeederFunction(void * arg); ///< shared init function
41 // Buffer mEmptyBuffer;
42 };
43 
44 
45 ///
46 /// StdIO reads/write the UNIX Standard IO pipes
47 ///
48 
49 class StdIO : public NullIO {
50 public:
51  StdIO(); ///< Constructor
52  StdIO(unsigned s_rate, unsigned b_size,
53  int in_device = 0, int out_device = 0,
54  unsigned in_chans = 0, unsigned out_chans = 2);
55  virtual ~StdIO();
56 
57  void start() throw(CException); ///< start my timer thread
58  void stop() throw(CException); ///< stop the timer thread
59 protected:
60  static void * FeederFunction(void * arg); ///< shared init function
61 
62 };
63 
64 } // end of namespace
65 
66 #endif CSL_NULLIO_H
67