Mercurial > hg > beaglert
changeset 220:46bd63a50933 mergingClockSync
Fixed initialization of writePointer
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 13 Feb 2016 16:55:39 +0000 |
parents | 0183185cab1b |
children | dbff109f64c2 |
files | core/NetworkSend.cpp |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/core/NetworkSend.cpp Sat Feb 13 15:55:33 2016 +0000 +++ b/core/NetworkSend.cpp Sat Feb 13 16:55:39 2016 +0000 @@ -100,7 +100,9 @@ objAddrs.push_back(this);//TODO: this line should be in the constructor, but something weird happens if // an instance of NetworkSend is then declared globally: the constructor gets called, // and objAddrs.size()==1 but when you get to setup, objAddrs.size() has reverted back to 0, without - // any destructor being called in between ... + // any destructor being called in between ... Have a look here + // http://stackoverflow.com/questions/7542054/global-vector-emptying-itself-between-calls . + // and maybe use accessor function instead of global, as was done in #1374 #endif /* USE_JUCE */ cleanup(); int numSamples=blockSize*4>4*channel.bufferLength ? blockSize*4 : 4*channel.bufferLength; @@ -122,7 +124,7 @@ } if(channel.readyToBeSent==NULL || channel.doneOnTime==NULL) return; - channel.writePointer=0; + channel.writePointer=channel.headerLength; channel.writeBuffer=0; channel.readBuffer=0; setChannelNumber(aChannelNumber); @@ -144,7 +146,7 @@ channel.writeBuffer=0; // printf("WriteBuffer:%d\n", channel.writeBuffer); if(channel.doneOnTime[channel.writeBuffer]==false){ //check if this buffer's last sending has completed on time ... - printf("Network buffer underrun. timestamp: %d :-{\n", + printf("NetworkSend buffer underrun. timestamp: %d :-{\n", (int)channel.buffers[channel.writeBuffer][channel.headerTimestampIndex]); } channel.doneOnTime[channel.writeBuffer]=false; // ... and then reset the flag @@ -185,7 +187,7 @@ void NetworkSend::setChannelNumber(int aChannelNumber){ channel.channelNumber=aChannelNumber; - for(int n=0; n<channel.numBuffers; n++){ //initialize the header + for(int n=0; n < channel.numBuffers; n++){ //initialize the header channel.buffers[n][channel.headerChannelIndex]=channel.channelNumber; //add here more static header fields } @@ -218,6 +220,8 @@ } #else udpClient.send(sourceBuffer, numBytesToSend); +// printf("sent sourceBuffer: %d, channel: %f, timestamp: %f\n", channel.readBuffer, channel.buffers[channel.readBuffer][0], +// channel.buffers[channel.readBuffer][1]); channel.doneOnTime[channel.readBuffer]=true; #endif /* USE_JUCE */ channel.readBuffer++;