Mercurial > hg > beaglert
comparison include/ReceiveAudioThread.h @ 125:850a4a9bd832 scope-refactoring
Added ifdefs and unified the code with udpioplugin ... the latter has not been tested (or committed). TODO: still it hangs after ctrl-c BeagleRT (auxiliary tasks do not terminate). TODO: sometimes you can hear dropouts in the transmission. Maybe it is due to pointer drifting. Rebooting BBB fixes/affects this issue.
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 22 Aug 2015 02:53:36 +0100 |
parents | cdd441a304a9 |
children | 2696a7f00053 |
comparison
equal
deleted
inserted
replaced
124:23137a333c93 | 125:850a4a9bd832 |
---|---|
1 #ifndef RECEIVEAUDIOTHREAD_H_INCLUDED | 1 #ifndef RECEIVEAUDIOTHREAD_H_INCLUDED |
2 #define RECEIVEAUDIOTHREAD_H_INCLUDED | 2 #define RECEIVEAUDIOTHREAD_H_INCLUDED |
3 #ifdef JUCE | |
4 #else | |
3 #include <vector> | 5 #include <vector> |
4 #include <iostream> | 6 #include <iostream> |
5 #include <UdpServer.h> | 7 #include <UdpServer.h> |
6 #include <BeagleRT.h> | 8 #include <BeagleRT.h> |
7 #include <native/task.h> | 9 #include <native/task.h> |
10 #endif /*JUCE*/ | |
8 | 11 |
12 #ifdef JUCE | |
13 class ReceiveAudioThread : public Thread { | |
14 #else | |
9 class ReceiveAudioThread{ | 15 class ReceiveAudioThread{ |
16 #endif /* JUCE */ | |
10 private: | 17 private: |
11 // FILE *fd; //DEBUG | 18 // FILE *fd; //DEBUG |
12 // FILE *fd2; //DEBUG | 19 // FILE *fd2; //DEBUG |
20 #ifdef JUCE | |
21 DatagramSocket socket; | |
22 #else | |
13 UdpServer socket; | 23 UdpServer socket; |
14 //JUCE DatagramSocket socket; | 24 #endif /* JUCE */ |
15 bool listening; | 25 bool listening; |
16 bool bufferReady; | 26 bool bufferReady; |
17 #ifdef JUCE | 27 #ifdef JUCE |
18 bool threadRunning; | 28 bool threadRunning; //do we really need this ? |
19 #else | 29 #else |
20 static bool threadRunning; | 30 static bool threadRunning; |
21 static bool threadIsExiting; | 31 static bool threadIsExiting; |
22 #endif | 32 #endif |
23 float *buffer; | 33 float *buffer; |
49 static void staticConstructor(); | 59 static void staticConstructor(); |
50 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) | 60 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) |
51 static std::vector<ReceiveAudioThread *> objAddrs; | 61 static std::vector<ReceiveAudioThread *> objAddrs; |
52 #endif | 62 #endif |
53 public: | 63 public: |
64 #ifdef JUCE | |
65 ReceiveAudioThread(const String &threadName); | |
66 #else | |
54 ReceiveAudioThread(); | 67 ReceiveAudioThread(); |
68 #endif | |
55 ~ReceiveAudioThread(); | 69 ~ReceiveAudioThread(); |
56 void init(int port, int aSamplesPerBlock, int channel); | 70 void init(int port, int aSamplesPerBlock, int channel); |
57 void setup(); | |
58 void bindToPort(int aPort); | 71 void bindToPort(int aPort); |
59 bool isListening(); | 72 bool isListening(); |
60 float* getCurrentBuffer(int length); | 73 float* getCurrentBuffer(int length); |
61 /** | 74 /** |
62 * Copies the samples to a non-interleaved buffer. | 75 * Copies the samples to a non-interleaved buffer. |