Mercurial > hg > beaglert
diff 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 |
line wrap: on
line diff
--- a/include/ReceiveAudioThread.h Fri Aug 21 14:37:19 2015 +0100 +++ b/include/ReceiveAudioThread.h Fri Aug 21 15:21:34 2015 +0100 @@ -14,42 +14,61 @@ //JUCE DatagramSocket socket; bool listening; bool bufferReady; - bool threadIsExiting; +#ifdef JUCE bool threadRunning; +#else + static bool threadRunning; + static bool threadIsExiting; +#endif float *buffer; float *stackBuffer; int bufferLength; float readPointer; int writePointer; int lastValidPointer; +#ifdef JUCE int sleepTime; +#else + static int sleepTime; +#endif int waitForSocketTime; int payloadLength; //size of the payload of each datagram int headerLength; //size of the header of each datagram int bytesToRead; int threadPriority; + int channel; void dealloc(); void wrapWritePointer(); void pushPayload(int startIndex); void popPayload(int startIndex); int readUdpToBuffer(); - bool threadShouldExit(); +#ifdef JUCE +#else + static bool threadShouldExit(); + static bool staticConstructed; + static void staticConstructor(); static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) -// static std::vector<NetworkReceive *> objAddrs; + static std::vector<ReceiveAudioThread *> objAddrs; +#endif public: ReceiveAudioThread(); ~ReceiveAudioThread(); - void init(int aSamplesPerBlock); + void init(int port, int aSamplesPerBlock, int channel); void setup(); void bindToPort(int aPort); bool isListening(); float* getCurrentBuffer(int length); int getSamplesSrc(float *destination, int length, float samplingRateRatio); bool isBufferReady(); +#ifdef JUCE // if we are in Juce, then we run a separate thread for each receiver + // (as each of them are typically receiving on a mono or stereo track) void run(); - void startThread(); - void stopThread(); -// static int getNumInstances(); -// static void receiveAllData(); +#else + void static run(); //while in BeagleRT we have a single thread that receives for all the instances. + //TODO: make run() private in BeagleRT + static void startThread(); + static void stopThread(); + static int getNumInstances(); +#endif // JUCE }; #endif // RECEIVEAUDIOTHREAD_H_INCLUDED