l@270: /***** OSCServer.h *****/ l@270: #ifndef __OSCServer_H_INCLUDED__ l@270: #define __OSCServer_H_INCLUDED__ l@270: l@270: #include l@270: #include l@270: #include l@270: #include l@270: l@270: #define UDP_RECIEVE_TIMEOUT_MS 20 l@270: #define UDP_RECIEVE_MAX_LENGTH 16384 l@270: l@270: class OSCServer{ l@270: public: l@270: OSCServer(); l@270: l@270: // must be called once during setup l@270: void setup(int port); l@270: l@270: // returns true if messages are queued l@270: // audio-thread safe l@270: bool messageWaiting(); l@270: l@270: // removes and returns the oldest message from the queue l@270: // audio-thread safe, but don't call unless messageWaiting() returns true l@270: oscpkt::Message popMessage(); l@270: l@270: // if there are OSC messages waiting, decode and queue them l@270: // not audio-thread safe! l@270: void recieveMessageNow(int timeout); l@270: l@270: private: l@270: int port; l@270: UdpServer socket; l@270: l@270: AuxiliaryTask OSCRecieveTask; l@270: l@270: void createAuxTasks(); l@270: void messageCheck(); l@270: l@270: static void checkMessages(void*); l@270: l@270: int inBuffer[UDP_RECIEVE_MAX_LENGTH]; l@270: std::queue inQueue; l@270: oscpkt::Message poppedMessage; l@270: oscpkt::PacketReader pr; l@270: }; l@270: l@270: l@270: #endif