Make sure n_read is > 0 ..

This commit is contained in:
Charles J. Cliffe 2015-09-19 22:30:00 -04:00
parent 7f2f3d95d2
commit d551d5f2c4

View File

@ -276,21 +276,22 @@ void SDRThread::run() {
// std::cout << n_read << ", " << timeNs << std::endl;
SDRThreadIQData *dataOut = buffers.getBuffer();
if (n_read > 0) {
SDRThreadIQData *dataOut = buffers.getBuffer();
dataOut->setRefCount(1);
dataOut->frequency = frequency;
dataOut->sampleRate = sampleRate.load();
dataOut->setRefCount(1);
dataOut->frequency = frequency;
dataOut->sampleRate = sampleRate.load();
dataOut->data.resize(n_read * 2);
memcpy(&dataOut->data[0],buffs[0],n_read * sizeof(float) * 2);
dataOut->data.resize(n_read * 2);
memcpy(&dataOut->data[0],buffs[0],n_read * sizeof(float) * 2);
if (iqDataOutQueue != NULL) {
iqDataOutQueue->push(dataOut);
} else {
dataOut->setRefCount(0);
if (iqDataOutQueue != NULL) {
iqDataOutQueue->push(dataOut);
} else {
dataOut->setRefCount(0);
}
}
}
device->deactivateStream(stream);
device->closeStream(stream);