Home   Information   Classes   Download   Usage   Mail List   Requirements   Tutorial


TcpWvIn.h

00001 /***************************************************/
00027 /***************************************************/
00028 
00029 #if !defined(__TCPWVIN_H)
00030 #define __TCPWVIN_H
00031 
00032 #include "WvIn.h"
00033 #include "Socket.h"
00034 #include "Thread.h"
00035 
00036 typedef struct {
00037   bool finished;
00038   void *object;
00039 } thread_info;
00040 
00041 class TcpWvIn : protected WvIn
00042 {
00043 public:
00045 
00048   TcpWvIn( int port = 2006 );
00049 
00051   ~TcpWvIn();
00052 
00054 
00057   void listen(unsigned int nChannels = 1, Stk::STK_FORMAT format = STK_SINT16);
00058 
00060 
00064   bool isConnected(void);
00065 
00067   MY_FLOAT lastOut(void) const;
00068 
00070   MY_FLOAT tick(void);
00071 
00073   MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
00074 
00076   const MY_FLOAT *lastFrame(void) const;
00077 
00079   const MY_FLOAT *tickFrame(void);
00080 
00082   MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames);
00083 
00084   // Called by the thread routine to receive data via the socket connection
00085   // and fill the socket buffer.  This is not intended for general use but
00086   // had to be made public for access from the thread.
00087   void receive(void);
00088 
00089 protected:
00090 
00091   // Initialize class variables.
00092   void init( int port );
00093 
00094   // Read buffered socket data into the data buffer ... will block if none available.
00095   int readData( void );
00096 
00097   Socket *soket;
00098   Thread *thread;
00099   Mutex mutex;
00100   char *buffer;
00101   long bufferBytes;
00102   long bytesFilled;
00103   long writePoint;
00104   long readPoint;
00105   long counter;
00106   int dataSize;
00107   bool connected;
00108   int fd;
00109   thread_info threadInfo;
00110 
00111 };
00112 
00113 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.