Mercurial > hg > beaglert
comparison include/ReceiveAudioThread.h @ 132:e24c531220ee scope-refactoring
Added some sort of synchronization, not working great though
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 27 Aug 2015 01:42:04 +0100 |
parents | ff28e56e5b7e |
children |
comparison
equal
deleted
inserted
replaced
131:ff28e56e5b7e | 132:e24c531220ee |
---|---|
2 #define RECEIVEAUDIOTHREAD_H_INCLUDED | 2 #define RECEIVEAUDIOTHREAD_H_INCLUDED |
3 | 3 |
4 #ifdef USE_JUCE | 4 #ifdef USE_JUCE |
5 #include <JuceHeader.h> | 5 #include <JuceHeader.h> |
6 #else | 6 #else |
7 #include <BeagleRT.h> | |
8 #include <UdpServer.h> | |
7 #include <vector> | 9 #include <vector> |
8 #include <iostream> | 10 #include <iostream> |
9 #include <UdpServer.h> | |
10 #include <BeagleRT.h> | |
11 #include <native/task.h> | 11 #include <native/task.h> |
12 #include <native/timer.h> | |
12 #include <math.h> | 13 #include <math.h> |
14 | |
13 #endif /*USE_JUCE*/ | 15 #endif /*USE_JUCE*/ |
14 | 16 |
15 #ifdef USE_JUCE | 17 #ifdef USE_JUCE |
16 class ReceiveAudioThread : public Thread { | 18 class ReceiveAudioThread : public Thread { |
17 #else | 19 #else |
48 int payloadLength; //size of the payload of each datagram | 50 int payloadLength; //size of the payload of each datagram |
49 int headerLength; //size of the header of each datagram | 51 int headerLength; //size of the header of each datagram |
50 int bytesToRead; | 52 int bytesToRead; |
51 int threadPriority; | 53 int threadPriority; |
52 int channel; | 54 int channel; |
55 int timestamp; | |
53 void dealloc(); | 56 void dealloc(); |
54 void wrapWritePointer(); | 57 void wrapWritePointer(); |
55 void pushPayload(int startIndex); | 58 void pushPayload(int startIndex); |
56 void popPayload(int startIndex); | 59 void popPayload(int startIndex); |
57 int readUdpToBuffer(); | 60 int readUdpToBuffer(); |
58 #ifdef USE_JUCE | 61 #ifdef USE_JUCE |
59 #else | 62 #else |
63 RTIME lastTime; // Used for clock synchronization | |
60 static bool threadShouldExit(); | 64 static bool threadShouldExit(); |
61 static bool staticConstructed; | 65 static bool staticConstructed; |
62 static void staticConstructor(); | 66 static void staticConstructor(); |
63 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) | 67 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) |
64 static std::vector<ReceiveAudioThread *> objAddrs; | 68 static std::vector<ReceiveAudioThread *> objAddrs; |
83 */ | 87 */ |
84 int getSamplesSrc(float *destination, int length, | 88 int getSamplesSrc(float *destination, int length, |
85 float samplingRateRatio, int numChannelsInDestination, | 89 float samplingRateRatio, int numChannelsInDestination, |
86 int channelToWriteTo); | 90 int channelToWriteTo); |
87 bool isBufferReady(); | 91 bool isBufferReady(); |
92 int getTimestamp(); | |
88 #ifdef USE_JUCE // if we are in Juce, then we run a separate thread for each receiver | 93 #ifdef USE_JUCE // if we are in Juce, then we run a separate thread for each receiver |
89 // (as each of them are typically receiving on a mono or stereo track) | 94 // (as each of them are typically receiving on a mono or stereo track) |
90 void run(); | 95 void run(); |
91 #else | 96 #else |
97 RTIME getLastTime(); | |
92 void static run(); //while in BeagleRT we have a single thread that receives for all the instances. | 98 void static run(); //while in BeagleRT we have a single thread that receives for all the instances. |
93 //TODO: make run() private in BeagleRT | 99 //TODO: make run() private in BeagleRT |
94 static void startThread(); | 100 static void startThread(); |
95 static void stopThread(); | 101 static void stopThread(); |
96 static int getNumInstances(); | 102 static int getNumInstances(); |