CSL
5.2
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
12
NullIO::NullIO
() :
IO
() {
13
mSynch
=
Synch::MakeSynch
();
14
mThread
=
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
}
23
24
NullIO::~NullIO
() { }
25
26
// Loop function for thread
27
28
void
*
NullIO::FeederFunction
(
void
* arg) {
29
NullIO
* me = (
NullIO
*) arg;
30
me->
pullInput
(me->
mOutputBuffer
);
31
while
(me->
mRunning
) {
32
Synch
* synch = me->
mSynch
;
// get my sync object
33
synch->
lock
();
// lock to let people know I want the resource
34
synch->
condWait
();
// wait to be told I should fill the buffer
35
me->
pullInput
(me->
mOutputBuffer
);
36
synch->
unlock
();
37
}
38
return
NULL;
39
}
40
41
void
NullIO::start
() throw(
CException
) {
///< start my timer thread
42
mRunning
=
true
;
/// whether or not I'm running
43
mThread
->createRealtimeThread(
FeederFunction
,
this
);
44
}
45
46
void
NullIO::stop
() throw(
CException
) {
///< stop the timer thread
47
mSynch
->
condSignal
();
48
mRunning
=
false
;
49
}
50
51
/////////////// StdIO
52
53
StdIO::StdIO
() :
NullIO
() {
54
mSynch
=
Synch::MakeSynch
();
55
mThread
=
Thread::MakeThread
();
56
}
57
58
StdIO::~StdIO
() { }
59
60
void
*
StdIO::FeederFunction
(
void
* arg) {
61
StdIO
* me = (
StdIO
*) arg;
62
while
(me->
mRunning
) {
63
Synch
* synch = me->
mSynch
;
// get my sync object
64
synch->
lock
();
// lock to let people know I want the resource
65
synch->
condWait
();
// wait to be told I should fill the buffer
66
me->
pullInput
(me->
mOutputBuffer
);
67
synch->
unlock
();
68
}
69
return
NULL;
70
}
71
72
void
StdIO::start
() throw(
CException
) {
///< start my timer thread
73
}
74
75
void
StdIO::stop
() throw(
CException
) {
///< stop the timer thread
76
}
CSL
IO
NullIO.cpp
Generated on Thu Nov 15 2012 22:01:09 for CSL by
1.8.1.1