CSL  6.0
NullIO.cpp
Go to the documentation of this file.
1 //
2 // NullIO.cpp -- Vacuous IO -- i.e., use this for no sound output or for graphs that use dependency for I/O
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 //
5 
6 #include "NullIO.h"
7 
8 using namespace csl;
9 
10 // Constructors
11 
14  mThread = juce::Thread::MakeThread();
15 }
16 
17 NullIO::NullIO(unsigned s_rate, unsigned b_size,
18  int in_device, int out_device,
19  unsigned in_chans, unsigned out_chans)
20  : IO(s_rate, b_size, in_device, out_device, in_chans, out_chans) {
21 }
22 
24 
25 // Loop function for thread
26 
27 void * NullIO::FeederFunction(void * arg) {
28  NullIO * me = (NullIO *) arg;
29  me->pullInput(me->mOutputBuffer);
30  while (me->mRunning) {
31  Synch* synch = me->mSynch; // get my sync object
32  synch->lock(); // lock to let people know I want the resource
33  synch->condWait(); // wait to be told I should fill the buffer
34  me->pullInput(me->mOutputBuffer);
35  synch->unlock();
36  }
37  return NULL;
38 }
39 
40 void NullIO::start() throw(CException) { ///< start my timer thread
41  mRunning = true; /// whether or not I'm running
42  mThread->createRealtimeThread(FeederFunction, this);
43 }
44 
45 void NullIO::stop() throw(CException) { ///< stop the timer thread
46  mSynch->condSignal();
47  mRunning = false;
48 }
49 
50 /////////////// StdIO
51 
54  mThread = Thread::MakeThread();
55 }
56 
58 
59 void * StdIO::FeederFunction(void * arg) {
60  StdIO * me = (StdIO *) arg;
61  while (me->mRunning) {
62  Synch * synch = me->mSynch; // get my sync object
63  synch->lock(); // lock to let people know I want the resource
64  synch->condWait(); // wait to be told I should fill the buffer
65  me->pullInput(me->mOutputBuffer);
66  synch->unlock();
67  }
68  return NULL;
69 }
70 
71 void StdIO::start() throw(CException) { ///< start my timer thread
72 }
73 
74 void StdIO::stop() throw(CException) { ///< stop the timer thread
75 }
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
void pullInput(Buffer &outBuffer, SampleBuffer out=0)
get a buffer from the CSL graph
Definition: CSL_Core.cpp:1425
static Synch * MakeSynch()
Factory method Utilities.
Sync is a cross-thread synchronization object.
virtual int condWait()=0
StdIO()
Constructor.
Definition: NullIO.cpp:52
Synch * mSynch
the sync I wait on
Definition: NullIO.h:39
virtual void start()
start my timer thread
Definition: NullIO.cpp:40
NullIO()
Constructor.
Definition: NullIO.cpp:12
IO – the abstract I/O scheduling class; subclasses interface to specific I/O APIs.
Definition: CSL_Core.h:752
NullIO is an IO that uses a thread and a timer to call its graph's nextBuffer(); it doesn't do anythi...
Definition: NullIO.h:23
juce::Thread * mThread
whether or not I'm running
Definition: NullIO.h:38
bool mRunning
Definition: NullIO.h:34
static void * FeederFunction(void *arg)
shared init function
Definition: NullIO.cpp:27
virtual int unlock()=0
virtual void stop()
stop the timer thread
Definition: NullIO.cpp:45
static void * FeederFunction(void *arg)
shared init function
Definition: NullIO.cpp:59
virtual int lock()=0
Buffer mOutputBuffer
the output buffer I use (passed to nextBuffer calls)
Definition: CSL_Core.h:779
virtual int condSignal()=0
void stop()
stop the timer thread
Definition: NullIO.cpp:74
void start()
start my timer thread
Definition: NullIO.cpp:71
virtual ~NullIO()
Definition: NullIO.cpp:23
virtual ~StdIO()
Definition: NullIO.cpp:57
Base class of CSL exceptions (written upper-case). Has a string message.
StdIO reads/write the UNIX Standard IO pipes.
Definition: NullIO.h:49