Exemplo n.º 1
0
/* Receive a timestamped chunk from the device */
void RadioInterface::pullBuffer()
{
  bool local_underrun;
  int num_recv;
  float *output;

  if (recvCursor > recvBuffer[0]->size() - CHUNK)
    return;

  /* Outer buffer access size is fixed */
  num_recv = mRadio->readSamples(convertRecvBuffer,
                                 CHUNK,
                                 &overrun,
                                 readTimestamp,
                                 &local_underrun);
  if (num_recv != CHUNK) {
          LOG(ALERT) << "Receive error " << num_recv;
          return;
  }

  for (size_t i = 0; i < mChans; i++) {
    output = (float *) (recvBuffer[i]->begin() + recvCursor);
    convert_short_float(output, convertRecvBuffer[i], 2 * num_recv);
  }

  underrun |= local_underrun;

  readTimestamp += num_recv;
  recvCursor += num_recv;
}
Exemplo n.º 2
0
/* Receive a timestamped chunk from the device */
void RadioInterface::pullBuffer()
{
  bool local_underrun;
  size_t numRecv, segmentLen = recvBuffer[0]->getSegmentLen();

  if (recvBuffer[0]->getFreeSegments() <= 0)
    return;

  /* Outer buffer access size is fixed */
  numRecv = mRadio->readSamples(convertRecvBuffer,
                                segmentLen,
                                &overrun,
                                readTimestamp,
                                &local_underrun);

  if (numRecv != segmentLen) {
          LOG(ALERT) << "Receive error " << numRecv;
          return;
  }

  for (size_t i = 0; i < mChans; i++) {
    convert_short_float(recvBuffer[i]->getWriteSegment(),
			convertRecvBuffer[i],
			segmentLen * 2);
  }

  underrun |= local_underrun;
  readTimestamp += numRecv;
}
/* Receive a timestamped chunk from the device */
void RadioInterfaceResamp::pullBuffer()
{
    bool local_underrun;
    int rc, num_recv;

    if (recvCursor > innerRecvBuffer->size() - resamp_inchunk)
        return;

    /* Outer buffer access size is fixed */
    num_recv = mRadio->readSamples(convertRecvBuffer,
                                   resamp_outchunk,
                                   &overrun,
                                   readTimestamp,
                                   &local_underrun);
    if (num_recv != (int) resamp_outchunk) {
        LOG(ALERT) << "Receive error " << num_recv;
        return;
    }

    convert_short_float((float *) outerRecvBuffer->begin(),
                        convertRecvBuffer[0], 2 * resamp_outchunk);

    underrun |= local_underrun;
    readTimestamp += (TIMESTAMP) resamp_outchunk;

    /* Write to the end of the inner receive buffer */
    rc = dnsampler->rotate((float *) outerRecvBuffer->begin(),
                           resamp_outchunk,
                           (float *) (innerRecvBuffer->begin() + recvCursor),
                           resamp_inchunk);
    if (rc < 0) {
        LOG(ALERT) << "Sample rate upsampling error";
    }

    recvCursor += resamp_inchunk;
}