Mercurial > hg > beaglert
view 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 |
line wrap: on
line source
#ifndef RECEIVEAUDIOTHREAD_H_INCLUDED #define RECEIVEAUDIOTHREAD_H_INCLUDED #include <vector> #include <iostream> #include <UdpServer.h> #include <BeagleRT.h> #include <native/task.h> class ReceiveAudioThread{ private: // FILE *fd; //DEBUG // FILE *fd2; //DEBUG UdpServer socket; //JUCE DatagramSocket socket; bool listening; bool bufferReady; bool threadIsExiting; bool threadRunning; float *buffer; float *stackBuffer; int bufferLength; float readPointer; int writePointer; int lastValidPointer; int sleepTime; int waitForSocketTime; int payloadLength; //size of the payload of each datagram int headerLength; //size of the header of each datagram int bytesToRead; int threadPriority; void dealloc(); void wrapWritePointer(); void pushPayload(int startIndex); void popPayload(int startIndex); int readUdpToBuffer(); bool threadShouldExit(); static AuxiliaryTask receiveDataTask; //TODO: allow different AuxiliaryTasks for different priorities (e.g.: audio vs scope) // static std::vector<NetworkReceive *> objAddrs; public: ReceiveAudioThread(); ~ReceiveAudioThread(); void init(int aSamplesPerBlock); void setup(); void bindToPort(int aPort); bool isListening(); float* getCurrentBuffer(int length); int getSamplesSrc(float *destination, int length, float samplingRateRatio); bool isBufferReady(); void run(); void startThread(); void stopThread(); // static int getNumInstances(); // static void receiveAllData(); }; #endif // RECEIVEAUDIOTHREAD_H_INCLUDED