Mercurial > hg > beaglert
comparison core/NetworkSend.cpp @ 222:6a23c07d0fbb mergingClockSync
Working with UdpIoPlugin
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 14 Feb 2016 01:09:23 +0000 |
parents | 46bd63a50933 |
children | e4392164b458 |
comparison
equal
deleted
inserted
replaced
221:dbff109f64c2 | 222:6a23c07d0fbb |
---|---|
104 // http://stackoverflow.com/questions/7542054/global-vector-emptying-itself-between-calls . | 104 // http://stackoverflow.com/questions/7542054/global-vector-emptying-itself-between-calls . |
105 // and maybe use accessor function instead of global, as was done in #1374 | 105 // and maybe use accessor function instead of global, as was done in #1374 |
106 #endif /* USE_JUCE */ | 106 #endif /* USE_JUCE */ |
107 cleanup(); | 107 cleanup(); |
108 int numSamples=blockSize*4>4*channel.bufferLength ? blockSize*4 : 4*channel.bufferLength; | 108 int numSamples=blockSize*4>4*channel.bufferLength ? blockSize*4 : 4*channel.bufferLength; |
109 channel.numBuffers= 1+numSamples/channel.bufferLength; //the +1 takes the ceil() of the division | 109 channel.numBuffers= (1+numSamples/channel.bufferLength) * 3; //the +1 takes the ceil() of the division |
110 channel.buffers=(float**)malloc(channel.numBuffers*sizeof(float*)); | 110 channel.buffers=(float**)malloc(channel.numBuffers*sizeof(float*)); |
111 printf("NumBuffers: %d\n", channel.numBuffers); | 111 printf("NumBuffers: %d\n", channel.numBuffers); |
112 if(channel.buffers==NULL) | 112 if(channel.buffers==NULL) |
113 return; | 113 return; |
114 for(int n=0; n<channel.numBuffers; n++){ | 114 for(int n=0; n<channel.numBuffers; n++){ |
141 channel.readyToBeSent[channel.writeBuffer]=true; // flag it as such | 141 channel.readyToBeSent[channel.writeBuffer]=true; // flag it as such |
142 // printf("Scheduling for send %d\n",(int)channel.buffers[channel.writeBuffer][channel.headerTimestampIndex]); | 142 // printf("Scheduling for send %d\n",(int)channel.buffers[channel.writeBuffer][channel.headerTimestampIndex]); |
143 channel.writePointer=channel.headerLength; //reset the writePointer | 143 channel.writePointer=channel.headerLength; //reset the writePointer |
144 channel.writeBuffer=(channel.writeBuffer+1); //switch buffer | 144 channel.writeBuffer=(channel.writeBuffer+1); //switch buffer |
145 if(channel.writeBuffer==channel.numBuffers) // and wrap it | 145 if(channel.writeBuffer==channel.numBuffers) // and wrap it |
146 channel.writeBuffer=0; | 146 channel.writeBuffer=0; |
147 // printf("WriteBuffer:%d\n", channel.writeBuffer); | 147 // printf("WriteBuffer:%d\n", channel.writeBuffer); |
148 if(channel.doneOnTime[channel.writeBuffer]==false){ //check if this buffer's last sending has completed on time ... | 148 if(channel.doneOnTime[channel.writeBuffer]==false){ //check if this buffer's last sending has completed on time ... |
149 printf("NetworkSend buffer underrun. timestamp: %d :-{\n", | 149 printf("NetworkSend buffer underrun. timestamp: %d :-{\n", |
150 (int)channel.buffers[channel.writeBuffer][channel.headerTimestampIndex]); | 150 (int)channel.buffers[channel.writeBuffer][channel.headerTimestampIndex]); |
151 } | 151 } |