Mercurial > hg > beaglert
changeset 122:bc514f29c3aa scope-refactoring
ReceiveAudioThread updated to match the newest UdpServer
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 22 Aug 2015 01:20:55 +0100 |
parents | 2197435e8fb4 |
children | d6245d5880c5 |
files | core/ReceiveAudioThread.cpp projects/scope/render.cpp |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/core/ReceiveAudioThread.cpp Sat Aug 22 01:20:35 2015 +0100 +++ b/core/ReceiveAudioThread.cpp Sat Aug 22 01:20:55 2015 +0100 @@ -29,7 +29,7 @@ stackBuffer=NULL; } void ReceiveAudioThread::wrapWritePointer(){ - //this is not quite a simple wrapping as you wold in a circular buffer, + //this is not quite a simple wrapping as you would do in a circular buffer, //as there is no guarantee the buffer will be full at all times, given that there must alwas be enough space at the end of it //to hold a full payload // lastValidPointer indicates the last pointer in the buffer containing valid data @@ -58,13 +58,12 @@ return 0; if(writePointer<0) return 0; - if(1){ //TODO: implement waitUntilReady for UdpServer -//JUCE if(socket.waitUntilReady(true, waitForSocketTime)){ // waitForSocketTime could have been set to -1 (wait forever), + if(socket.waitUntilReady(true, waitForSocketTime)){ // waitForSocketTime could have been set to -1 (wait forever), // but it would have made it more difficult for the thread to be killed pushPayload(writePointer); //backup headerLength samples. This could be skipped if writePointer==0 //read header+payload //JUCE int numBytes=socket.read(buffer+writePointer, bytesToRead,1); - int numBytes=socket.read(buffer+writePointer, bytesToRead); + int numBytes=socket.read(buffer+writePointer, bytesToRead, false); //read without waiting. //TODO: (if using variable-length payload) validate the actual numBytes read against the size declared in the header if(numBytes<0){ printf("error numBytes1\n"); @@ -216,7 +215,9 @@ return bufferReady; } void ReceiveAudioThread::startThread(){ + printf("receivedata is going to be scheduled\n"); BeagleRT_scheduleAuxiliaryTask(receiveDataTask); + printf("receivedata has been scheduled\n"); } void ReceiveAudioThread::stopThread(){ threadIsExiting=true; @@ -234,6 +235,7 @@ usleep(sleepTime); #else for(unsigned int n=0; n<ReceiveAudioThread::objAddrs.size(); n++){ +// printf("%d\n", n); ReceiveAudioThread::objAddrs[n]->readUdpToBuffer(); } usleep(sleepTime); //TODO: use rt_task_sleep instead
--- a/projects/scope/render.cpp Sat Aug 22 01:20:35 2015 +0100 +++ b/projects/scope/render.cpp Sat Aug 22 01:20:55 2015 +0100 @@ -49,9 +49,10 @@ void render(BeagleRTContext *context, void *userData) { static int count=0; - if(count==0) + if(count==0){ + printf("startHread\n"); ReceiveAudioThread::startThread(); - + } for(unsigned int n = 0; n < context->audioFrames; n++) { float chn0 = sinf(gPhase1);