This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux: actions after data availability in Streamer class

Tool/software: Linux

In trying to understand how the control is flowing among the classes I see that there is

  bool putBuffer()
  {
    Lock<Mutex> _(_dataAccessMutex);

.....SomeCodeHere.....

    auto f = _rawBuffers.get();

    RawDataFramePtr &raw = *f;

    if(!raw || raw->data.size() != usbBuffer.size())
    {
      raw = RawDataFramePtr(new RawDataFrame());
      raw->data.resize(usbBuffer.size());
    }

.....SomeCodeHere.....


    memcpy(raw->data.data(), usbBuffer.data(), usbBuffer.size() - BULK_XFER_EXTRA_SIZE);


    _dataAvailableCondition.notify_all();

    return true;
  }

I would like to know what happens after the condition variable _dataAvailableCondition properties is modified in above code ?

Does it then invoke the function _captureRawUnprocessedFrame(RawFramePtr &rawFrame) to run in class ToFCameraBase as shown below ?

bool ToFCameraBase::_captureRawUnprocessedFrame(RawFramePtr &rawFrame)
{
  if(!isInitialized() || !_streamer->isRunning())
    return false;
 
  if(_streamer->capture(_rawDataFrame))
  {
    rawFrame = std::dynamic_pointer_cast<RawFrame>(_rawDataFrame);
    return true;
  }
 
  return false;
}

I am also trying to connet the above code  to the way ToFTintin camera works ?

Which streamer class does Tintin CDK uses and how does Tintin CDK get its raw data from usb buffers ?

  • Hi Tauseef, 

    I guess this would help you understand the std::condtion_variable better. 

    All functions where this _dataAvailableCondition is used stay blocked unless there is data in the _inUseBuffers. Once the data is received, the getBuffer functions is also called (since the same thread is locked). notify_all notifies all the functions that the input buffer data is changing. 

    TintinCDKCamera uses the USBBulkStreamer class. This can be seen from the following line:

      _streamer = Ptr<Streamer>(new USBBulkStreamer(usbIO, controlDevice, 0x82));

    If you see the Streamer capture function, you'll see that the capture function calls the protected _capture function (of USBBulkStreamer), where the buffers are converted to raw data. 

    Suramya