# HG changeset patch # User Giulio Moro # Date 1440202855 -3600 # Node ID bc514f29c3aa698b99145e870c529410fb4b5faf # Parent 2197435e8fb45489f8281dba5d8ebc690c667548 ReceiveAudioThread updated to match the newest UdpServer diff -r 2197435e8fb4 -r bc514f29c3aa core/ReceiveAudioThread.cpp --- 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; nreadUdpToBuffer(); } usleep(sleepTime); //TODO: use rt_task_sleep instead diff -r 2197435e8fb4 -r bc514f29c3aa projects/scope/render.cpp --- 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);