/* Send a timestamped chunk to the device */ void RadioInterfaceResamp::pushBuffer() { int rc, chunks, num_sent; int inner_len, outer_len; if (sendCursor < resamp_inchunk) return; if (sendCursor > innerSendBuffer->size()) LOG(ALERT) << "Send buffer overflow"; chunks = sendCursor / resamp_inchunk; inner_len = chunks * resamp_inchunk; outer_len = chunks * resamp_outchunk; /* Always send from the beginning of the buffer */ rc = upsampler->rotate((float *) innerSendBuffer->begin(), inner_len, (float *) outerSendBuffer->begin(), outer_len); if (rc < 0) { LOG(ALERT) << "Sample rate downsampling error"; } convert_float_short(convertSendBuffer[0], (float *) outerSendBuffer->begin(), powerScaling[0], 2 * outer_len); num_sent = mRadio->writeSamples(convertSendBuffer, outer_len, &underrun, writeTimestamp); if (num_sent != outer_len) { LOG(ALERT) << "Transmit error " << num_sent; } /* Shift remaining samples to beginning of buffer */ memmove(innerSendBuffer->begin(), innerSendBuffer->begin() + inner_len, (sendCursor - inner_len) * 2 * sizeof(float)); writeTimestamp += outer_len; sendCursor -= inner_len; assert(sendCursor >= 0); }
/* Send timestamped chunk to the device with arbitrary size */ bool RadioInterface::pushBuffer() { size_t numSent, segmentLen = sendBuffer[0]->getSegmentLen(); if (sendBuffer[0]->getAvailSegments() < 1) return false; for (size_t i = 0; i < mChans; i++) { convert_float_short(convertSendBuffer[i], (float *) sendBuffer[i]->getReadSegment(), powerScaling[i], segmentLen * 2); } /* Send the all samples in the send buffer */ numSent = mRadio->writeSamples(convertSendBuffer, segmentLen, &underrun, writeTimestamp); writeTimestamp += numSent; return true; }
/* Send timestamped chunk to the device with arbitrary size */ void RadioInterface::pushBuffer() { int num_sent; if (sendCursor < CHUNK) return; if (sendCursor > sendBuffer[0]->size()) LOG(ALERT) << "Send buffer overflow"; for (size_t i = 0; i < mChans; i++) { convert_float_short(convertSendBuffer[i], (float *) sendBuffer[i]->begin(), powerScaling[i], 2 * sendCursor); } /* Send the all samples in the send buffer */ num_sent = mRadio->writeSamples(convertSendBuffer, sendCursor, &underrun, writeTimestamp); writeTimestamp += num_sent; sendCursor = 0; }