Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   Tutorial


TcpWvIn.h

00001 /***************************************************/
00027 /***************************************************/
00028 
00029 #ifndef STK_TCPWVIN_H
00030 #define STK_TCPWVIN_H
00031 
00032 #include "WvIn.h"
00033 #include "Socket.h"
00034 #include "Thread.h"
00035 #include "Mutex.h"
00036 
00037 typedef struct {
00038   bool finished;
00039   void *object;
00040 } thread_info;
00041 
00042 class TcpWvIn : protected WvIn
00043 {
00044 public:
00046 
00049   TcpWvIn( int port = 2006 );
00050 
00052   ~TcpWvIn();
00053 
00055 
00058   void listen(unsigned int nChannels = 1, Stk::StkFormat format = STK_SINT16);
00059 
00061 
00065   bool isConnected(void);
00066 
00068   StkFloat lastOut(void) const;
00069 
00071   StkFloat tick(void);
00072 
00074   StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
00075 
00077 
00083   StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
00084 
00086   const StkFloat *lastFrame(void) const;
00087 
00089   const StkFloat *tickFrame(void);
00090 
00092   StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
00093 
00095 
00100   StkFrames& tickFrame( StkFrames& frames );
00101 
00102   // Called by the thread routine to receive data via the socket connection
00103   // and fill the socket buffer.  This is not intended for general use but
00104   // had to be made public for access from the thread.
00105   void receive(void);
00106 
00107 protected:
00108 
00109   // Initialize class variables.
00110   void init( int port );
00111 
00112   // Read buffered socket data into the data buffer ... will block if none available.
00113   int readData( void );
00114 
00115   Socket *soket_;
00116   Thread *thread_;
00117   Mutex mutex_;
00118   char *buffer_;
00119   long bufferBytes_;
00120   long bytesFilled_;
00121   long writePoint_;
00122   long readPoint_;
00123   long counter_;
00124   int dataSize_;
00125   bool connected_;
00126   int fd_;
00127   thread_info threadInfo_;
00128 
00129 };
00130 
00131 #endif

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