Mercurial > hg > beaglert
comparison include/OSCServer.h @ 278:3c3d042dad12 prerelease
merge
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 17 May 2016 16:07:45 +0100 |
parents | de37582ce6f3 |
children | e4392164b458 |
comparison
equal
deleted
inserted
replaced
277:4b3ae93ab102 | 278:3c3d042dad12 |
---|---|
1 /***** OSCServer.h *****/ | |
2 #ifndef __OSCServer_H_INCLUDED__ | |
3 #define __OSCServer_H_INCLUDED__ | |
4 | |
5 #include <UdpServer.h> | |
6 #include <oscpkt.hh> | |
7 #include <BeagleRT.h> | |
8 #include <queue> | |
9 | |
10 #define UDP_RECIEVE_TIMEOUT_MS 20 | |
11 #define UDP_RECIEVE_MAX_LENGTH 16384 | |
12 | |
13 class OSCServer{ | |
14 public: | |
15 OSCServer(); | |
16 | |
17 // must be called once during setup | |
18 void setup(int port); | |
19 | |
20 // returns true if messages are queued | |
21 // audio-thread safe | |
22 bool messageWaiting(); | |
23 | |
24 // removes and returns the oldest message from the queue | |
25 // audio-thread safe, but don't call unless messageWaiting() returns true | |
26 oscpkt::Message popMessage(); | |
27 | |
28 // if there are OSC messages waiting, decode and queue them | |
29 // not audio-thread safe! | |
30 void recieveMessageNow(int timeout); | |
31 | |
32 private: | |
33 int port; | |
34 UdpServer socket; | |
35 | |
36 AuxiliaryTask OSCRecieveTask; | |
37 | |
38 void createAuxTasks(); | |
39 void messageCheck(); | |
40 | |
41 static void checkMessages(void*); | |
42 | |
43 int inBuffer[UDP_RECIEVE_MAX_LENGTH]; | |
44 std::queue<oscpkt::Message> inQueue; | |
45 oscpkt::Message poppedMessage; | |
46 oscpkt::PacketReader pr; | |
47 }; | |
48 | |
49 | |
50 #endif |