CSL  6.0
RemoteIO.h
Go to the documentation of this file.
1 //
2 // RemoteIO.h -- CSL I/O Port for sending sample buffers out over UDP or TCP-IP sockets
3 // (in response to request packets sent from a RemoteStream client)
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 //
6 // This is an output driver that receives call-backs from a remote client over a network socket
7 // and calls on its DSP graph to generate a buffer of samples.
8 // See the comment in RemoteStream.h for a description of the packet format
9 //
10 
11 #ifndef INCLUDE_REMOTEIO_H
12 #define INCLUDE_REMOTEIO_H
13 
14 #include "CSL_Includes.h"
15 #include "ThreadUtilities.h"
16 #include "RemoteStream.h"
17 
18 namespace csl {
19 
20 // Driver thread function
21 
22 extern "C" void * RemoteIO_read_loop(void * inst);
23 
24 ///
25 /// the RemoteIO class
26 ///
27 
28 class RemoteIO : public IO {
29 
30 protected:
31  unsigned _inputs, _outputs; // The default # of I/O channels
32  Buffer _outputBuffer; // My output buffer (proxy for the remote frame stream client)
33  Buffer _inputBuffer; // empty input buffer (since we don't pass input across the network [yet])
34 
35  struct sockaddr_in _clientAddr, _myAddr; // Socket addresses for the remote client and me
36  int _inSock; // The RFS socket I listen to
37  int _outSock; // The RFS socket I read/write from/to
38 
39  sample * _buffer; // My local packet buffer (used for io and for the DSP graph)
40 #ifdef DO_TIMING // This is for the performance timing code
41  struct timeval then, now; // Used for getting the real time
42  long timeVals, thisSec; // Used for CPU usage statistics
43  long timeSum;
44 #endif
45  void init_io(unsigned in, unsigned out);
46 
47 public: // These data members are public so that they can be used from the thread call
48  RemoteIO();
49  RemoteIO(unsigned chans);
50  ~RemoteIO();
51 
52  status open();
53  status open(unsigned port);
54  virtual status start();
55  status stop();
56  status close();
57 
59  int get_out_sock() { return(_outSock); };
60  sample * get_buffer() { return(_buffer); };
61  struct sockaddr_in * get_client_addr() { return(&_clientAddr); };
62 };
63 
64 }
65 
66 #endif
67 
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
status stop()
Definition: RemoteIO.cpp:230
void process_request_packet()
Definition: RemoteIO.cpp:181
sample * get_buffer()
Definition: RemoteIO.h:60
unsigned _outputs
Definition: RemoteIO.h:31
void * RemoteIO_read_loop(void *inst)
Definition: RemoteIO.cpp:126
struct sockaddr_in * get_client_addr()
Definition: RemoteIO.h:61
status open()
Definition: RemoteIO.cpp:59
Buffer _outputBuffer
Definition: RemoteIO.h:32
sample * _buffer
Definition: RemoteIO.h:39
float sample
(could be changed to int, or double)
Definition: CSL_Types.h:191
IO – the abstract I/O scheduling class; subclasses interface to specific I/O APIs.
Definition: CSL_Core.h:752
the RemoteIO class
Definition: RemoteIO.h:28
int _outSock
Definition: RemoteIO.h:37
Buffer _inputBuffer
Definition: RemoteIO.h:33
int get_out_sock()
Definition: RemoteIO.h:59
void init_io(unsigned in, unsigned out)
Definition: RemoteIO.cpp:24
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
struct sockaddr_in _clientAddr _myAddr
Definition: RemoteIO.h:35
virtual status start()
Definition: RemoteIO.cpp:99
unsigned _inputs
Definition: RemoteIO.h:31
status close()
open/close start/stop methods
Definition: RemoteIO.cpp:87