annotate include/OSCServer.h @ 556:ce391098f321 prerelease tip

THIS PROJECT HAS MOVED TO https://github.com/BelaPlatform/bela
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 25 Jun 2016 20:21:00 +0100
parents faa5f58c71af
children
rev   line source
l@270 1 /***** OSCServer.h *****/
l@270 2 #ifndef __OSCServer_H_INCLUDED__
l@270 3 #define __OSCServer_H_INCLUDED__
l@270 4
l@270 5 #include <UdpServer.h>
l@270 6 #include <oscpkt.hh>
giuliomoro@301 7 #include <Bela.h>
l@270 8 #include <queue>
l@270 9
giuliomoro@475 10 #define UDP_RECEIVE_TIMEOUT_MS 20
giuliomoro@475 11 #define UDP_RECEIVE_MAX_LENGTH 16384
l@270 12
l@270 13 class OSCServer{
l@270 14 public:
l@270 15 OSCServer();
l@270 16
l@270 17 // must be called once during setup
l@270 18 void setup(int port);
l@270 19
l@270 20 // returns true if messages are queued
l@270 21 // audio-thread safe
l@270 22 bool messageWaiting();
l@270 23
l@270 24 // removes and returns the oldest message from the queue
l@270 25 // audio-thread safe, but don't call unless messageWaiting() returns true
l@270 26 oscpkt::Message popMessage();
l@270 27
l@270 28 // if there are OSC messages waiting, decode and queue them
l@270 29 // not audio-thread safe!
giuliomoro@475 30 void receiveMessageNow(int timeout);
l@270 31
l@270 32 private:
l@270 33 int port;
l@270 34 UdpServer socket;
l@270 35
giuliomoro@475 36 AuxiliaryTask OSCReceiveTask;
l@270 37
l@270 38 void createAuxTasks();
l@270 39 void messageCheck();
l@270 40
l@270 41 static void checkMessages(void*);
l@270 42
giuliomoro@475 43 int inBuffer[UDP_RECEIVE_MAX_LENGTH];
l@270 44 std::queue<oscpkt::Message> inQueue;
l@270 45 oscpkt::Message poppedMessage;
l@270 46 oscpkt::PacketReader pr;
l@270 47 };
l@270 48
l@270 49
giuliomoro@301 50 #endif