Ryan: you have to take care of the "len" - parameters, they can change on every call. you could implement the buffer as some sort of circular buffer and check your write and read positions ...
this should work:
@qint64 myProcessing::writeData(const char *data, qint64 len) {
qint16* aVal;
qint64 numSamples = len / 2;
qint64 posSamples = 1;
aVal = (qint16*) data;
while (posSamples <= numSamples) {
mBuffer[mBufWritePos] = doSomething(*aVal);
mBufWritePos = (mBufWritePos+1) % bufSize;
aVal++;
posSamples++;
}
mBufFill += len;
return len;
}
qint64 myProcessing::readData(char *data, qint64 maxlen)
{
if (mBufFill<=0) return 0;
qint64 toDo = qMin(maxlen, (qint64) mBufFill);
if (toDo / 2 + mBufReadPos > bufSize) {
qint64 firstNum = (bufSize - mBufReadPos) * 2;
memcpy( data,
&mBuffer;[mBufReadPos],
firstNum );
memcpy( data + firstNum,
&mBuffer;[0],
toDo - firstNum);
} else {
memcpy(data, &mBuffer;[mBufReadPos], toDo);
}
mBufReadPos =  (mBufReadPos + toDo/2) % bufSize;
mBufFill -= toDo;
return toDo;
}@