Mercurial > hg > beaglert
annotate include/ReceiveAudioThread.h @ 117:ada68d50e56a scope-refactoring
ReceiveAudioThread hs been ported to BBB. The scope project now is sending audio locally and receiving it at the same time
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 20 Aug 2015 16:37:15 +0100 |
parents | |
children | c692827083e1 |
rev | line source |
---|---|
giuliomoro@117 | 1 #ifndef RECEIVEAUDIOTHREAD_H_INCLUDED |
giuliomoro@117 | 2 #define RECEIVEAUDIOTHREAD_H_INCLUDED |
giuliomoro@117 | 3 #include <vector> |
giuliomoro@117 | 4 #include <iostream> |
giuliomoro@117 | 5 #include <UdpServer.h> |
giuliomoro@117 | 6 #include <BeagleRT.h> |
giuliomoro@117 | 7 #include <native/task.h> |
giuliomoro@117 | 8 |
giuliomoro@117 | 9 class ReceiveAudioThread{ |
giuliomoro@117 | 10 private: |
giuliomoro@117 | 11 // FILE *fd; //DEBUG |
giuliomoro@117 | 12 // FILE *fd2; //DEBUG |
giuliomoro@117 | 13 UdpServer socket; |
giuliomoro@117 | 14 //JUCE DatagramSocket socket; |
giuliomoro@117 | 15 bool listening; |
giuliomoro@117 | 16 bool bufferReady; |
giuliomoro@117 | 17 bool threadIsExiting; |
giuliomoro@117 | 18 bool threadRunning; |
giuliomoro@117 | 19 float *buffer; |
giuliomoro@117 | 20 float *stackBuffer; |
giuliomoro@117 | 21 int bufferLength; |
giuliomoro@117 | 22 float readPointer; |
giuliomoro@117 | 23 int writePointer; |
giuliomoro@117 | 24 int lastValidPointer; |
giuliomoro@117 | 25 int sleepTime; |
giuliomoro@117 | 26 int waitForSocketTime; |
giuliomoro@117 | 27 int payloadLength; //size of the payload of each datagram |
giuliomoro@117 | 28 int headerLength; //size of the header of each datagram |
giuliomoro@117 | 29 int bytesToRead; |
giuliomoro@117 | 30 int threadPriority; |
giuliomoro@117 | 31 void dealloc(); |
giuliomoro@117 | 32 void wrapWritePointer(); |
giuliomoro@117 | 33 void pushPayload(int startIndex); |
giuliomoro@117 | 34 void popPayload(int startIndex); |
giuliomoro@117 | 35 int readUdpToBuffer(); |
giuliomoro@117 | 36 bool threadShouldExit(); |
giuliomoro@117 | 37 static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) |
giuliomoro@117 | 38 // static std::vector<NetworkReceive *> objAddrs; |
giuliomoro@117 | 39 public: |
giuliomoro@117 | 40 ReceiveAudioThread(); |
giuliomoro@117 | 41 ~ReceiveAudioThread(); |
giuliomoro@117 | 42 void init(int aSamplesPerBlock); |
giuliomoro@117 | 43 void setup(); |
giuliomoro@117 | 44 void bindToPort(int aPort); |
giuliomoro@117 | 45 bool isListening(); |
giuliomoro@117 | 46 float* getCurrentBuffer(int length); |
giuliomoro@117 | 47 int getSamplesSrc(float *destination, int length, float samplingRateRatio); |
giuliomoro@117 | 48 bool isBufferReady(); |
giuliomoro@117 | 49 void run(); |
giuliomoro@117 | 50 void startThread(); |
giuliomoro@117 | 51 void stopThread(); |
giuliomoro@117 | 52 // static int getNumInstances(); |
giuliomoro@117 | 53 // static void receiveAllData(); |
giuliomoro@117 | 54 }; |
giuliomoro@117 | 55 #endif // RECEIVEAUDIOTHREAD_H_INCLUDED |