Mercurial > hg > beaglert
comparison include/ReceiveAudioThread.h @ 119:c692827083e1 scope-refactoring
Enabled multi channel audio receive
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 21 Aug 2015 15:21:34 +0100 |
parents | ada68d50e56a |
children | cdd441a304a9 |
comparison
equal
deleted
inserted
replaced
118:26ad97b8aa9e | 119:c692827083e1 |
---|---|
12 // FILE *fd2; //DEBUG | 12 // FILE *fd2; //DEBUG |
13 UdpServer socket; | 13 UdpServer socket; |
14 //JUCE DatagramSocket socket; | 14 //JUCE DatagramSocket socket; |
15 bool listening; | 15 bool listening; |
16 bool bufferReady; | 16 bool bufferReady; |
17 bool threadIsExiting; | 17 #ifdef JUCE |
18 bool threadRunning; | 18 bool threadRunning; |
19 #else | |
20 static bool threadRunning; | |
21 static bool threadIsExiting; | |
22 #endif | |
19 float *buffer; | 23 float *buffer; |
20 float *stackBuffer; | 24 float *stackBuffer; |
21 int bufferLength; | 25 int bufferLength; |
22 float readPointer; | 26 float readPointer; |
23 int writePointer; | 27 int writePointer; |
24 int lastValidPointer; | 28 int lastValidPointer; |
29 #ifdef JUCE | |
25 int sleepTime; | 30 int sleepTime; |
31 #else | |
32 static int sleepTime; | |
33 #endif | |
26 int waitForSocketTime; | 34 int waitForSocketTime; |
27 int payloadLength; //size of the payload of each datagram | 35 int payloadLength; //size of the payload of each datagram |
28 int headerLength; //size of the header of each datagram | 36 int headerLength; //size of the header of each datagram |
29 int bytesToRead; | 37 int bytesToRead; |
30 int threadPriority; | 38 int threadPriority; |
39 int channel; | |
31 void dealloc(); | 40 void dealloc(); |
32 void wrapWritePointer(); | 41 void wrapWritePointer(); |
33 void pushPayload(int startIndex); | 42 void pushPayload(int startIndex); |
34 void popPayload(int startIndex); | 43 void popPayload(int startIndex); |
35 int readUdpToBuffer(); | 44 int readUdpToBuffer(); |
36 bool threadShouldExit(); | 45 #ifdef JUCE |
46 #else | |
47 static bool threadShouldExit(); | |
48 static bool staticConstructed; | |
49 static void staticConstructor(); | |
37 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) | 50 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) |
38 // static std::vector<NetworkReceive *> objAddrs; | 51 static std::vector<ReceiveAudioThread *> objAddrs; |
52 #endif | |
39 public: | 53 public: |
40 ReceiveAudioThread(); | 54 ReceiveAudioThread(); |
41 ~ReceiveAudioThread(); | 55 ~ReceiveAudioThread(); |
42 void init(int aSamplesPerBlock); | 56 void init(int port, int aSamplesPerBlock, int channel); |
43 void setup(); | 57 void setup(); |
44 void bindToPort(int aPort); | 58 void bindToPort(int aPort); |
45 bool isListening(); | 59 bool isListening(); |
46 float* getCurrentBuffer(int length); | 60 float* getCurrentBuffer(int length); |
47 int getSamplesSrc(float *destination, int length, float samplingRateRatio); | 61 int getSamplesSrc(float *destination, int length, float samplingRateRatio); |
48 bool isBufferReady(); | 62 bool isBufferReady(); |
63 #ifdef JUCE // if we are in Juce, then we run a separate thread for each receiver | |
64 // (as each of them are typically receiving on a mono or stereo track) | |
49 void run(); | 65 void run(); |
50 void startThread(); | 66 #else |
51 void stopThread(); | 67 void static run(); //while in BeagleRT we have a single thread that receives for all the instances. |
52 // static int getNumInstances(); | 68 //TODO: make run() private in BeagleRT |
53 // static void receiveAllData(); | 69 static void startThread(); |
70 static void stopThread(); | |
71 static int getNumInstances(); | |
72 #endif // JUCE | |
54 }; | 73 }; |
55 #endif // RECEIVEAUDIOTHREAD_H_INCLUDED | 74 #endif // RECEIVEAUDIOTHREAD_H_INCLUDED |