void Sbs2EmocapDataReader::turnReceiveUdpDataOff()
{
    QObject::disconnect(sbs2NetworkHandler,SIGNAL(rawDataReceived(QUdpSocket*)),this,SLOT(udpDataReceived(QUdpSocket*)));
    if (sbs2NetworkHandler != 0)
        delete sbs2NetworkHandler;
    sbs2NetworkHandler = 0;


    if (readOnlyFromNetwork)
    {

    }
    else
    {
        QObject::connect(sbs2EmocapMounter,SIGNAL(deviceFound(QMap<QString,QVariant>)),this,SLOT(deviceFound(QMap<QString,QVariant>)));
        QObject::connect(sbs2EmocapMounter,SIGNAL(deviceLost()),this,SLOT(deviceLost()));
        sbs2EmocapMounter->start();
    }
}
void Sbs2EmocapDataReader::turnReceiveUdpDataOn(QString address, int port)
{
    Sbs2DataReader::turnReceiveUdpDataOn(address, port);

    if (sbs2EmocapMounter != 0)
    {
        QObject::disconnect(sbs2EmocapMounter,SIGNAL(deviceFound(QMap<QString,QVariant>)),this,SLOT(deviceFound(QMap<QString,QVariant>)));
        QObject::disconnect(sbs2EmocapMounter,SIGNAL(deviceLost()),this,SLOT(deviceLost()));
        sbs2EmocapMounter->invalidate();

    }

    running = 0;
    if (sbs2NetworkHandler != 0)
        delete sbs2NetworkHandler;

    sbs2NetworkHandler = new Sbs2NetworkHandler(this);
    sbs2NetworkHandler->turnReceiveRawDataOn(address,port);
    QObject::connect(sbs2NetworkHandler,SIGNAL(rawDataReceived(QUdpSocket*)),this,SLOT(udpDataReceived(QUdpSocket*)));
}
Sbs2EmocapDataReader::Sbs2EmocapDataReader(Sbs2Callback *sbs2Callback_, int readOnlyFromNetwork_, QObject *parent):Sbs2DataReader(sbs2Callback_,readOnlyFromNetwork_,parent)
{

    for (int i=0; i< bufferSize; ++i)
    {
        sbs2Packets.append(new Sbs2EmocapPacket(this));
    }

    if (!readOnlyFromNetwork) //read from the local device
    {
        sbs2EmotivDecryptor = new Sbs2EmotivDecryptor(this);
        sbs2EmocapMounter = Sbs2EmocapMounter::New(this);
        QObject::connect(sbs2EmocapMounter,SIGNAL(deviceFound(QMap<QString,QVariant>)),this,SLOT(deviceFound(QMap<QString,QVariant>)));
        QObject::connect(sbs2EmocapMounter,SIGNAL(deviceLost()),this,SLOT(deviceLost()));
        sbs2EmocapMounter->start();
    }
    else //receive packets from remote host, we do nothing, waiting for turnOn
    {
        sbs2EmocapMounter = 0;
    }
}
void QD3D12WindowPrivate::flush(const QRegion &region)
{
    Q_Q(QD3D12Window);
    Q_UNUSED(region);

    HRESULT hr = swapChain->Present(1, 0);
    if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
        deviceLost();
        return;
    } else if (FAILED(hr)) {
        qWarning("Present failed: 0x%x", hr);
        return;
    }

    q->afterPresent();
}
void QD3D12WindowPrivate::resize()
{
    Q_Q(QD3D12Window);

    if (!initialized)
        return;

    // Clear these, otherwise resizing will fail.
    depthStencil = Q_NULLPTR;
    for (int i = 0; i < swapChainBufferCount; ++i)
        renderTargets[i] = Q_NULLPTR;

    HRESULT hr = swapChain->ResizeBuffers(swapChainBufferCount, q->width(), q->height(), DXGI_FORMAT_R8G8B8A8_UNORM, 0);
    if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
        deviceLost();
        return;
    } else if (FAILED(hr)) {
        qWarning("Failed to resize buffers: 0x%x", hr);
        return;
    }

    setupRenderTargets();
}
Esempio n. 6
0
void XD3DSwapChainImpl::present(ID3D11DeviceContext1 *context, bool *deviceListOptional)
  {
  Optional<bool> deviceLost(deviceListOptional);
  deviceLost = false;

  // The application may optionally specify "dirty" or "scroll"
  // rects to improve efficiency in certain scenarios.
  DXGI_PRESENT_PARAMETERS parameters = {0};
  parameters.DirtyRectsCount = 0;
  parameters.pDirtyRects = nullptr;
  parameters.pScrollRect = nullptr;
  parameters.pScrollOffset = nullptr;

  // The first argument instructs DXGI to block until VSync, putting the application
  // to sleep until the next VSync. This ensures we don't waste any cycles rendering
  // frames that will never be displayed to the screen.
  HRESULT hr = swapChain->Present1(1, 0, &parameters);

  // Discard the contents of the render target.
  // This is a valid operation only when the existing contents will be entirely
  // overwritten. If dirty or scroll rects are used, this call should be removed.
  context->DiscardView(renderTargetView.Get());

  // Discard the contents of the depth stencil.
  context->DiscardView(depthStencilView.Get());

  // If the device was removed either by a disconnect or a driver upgrade, we
  // must recreate all device resources.
  if (hr == DXGI_ERROR_DEVICE_REMOVED)
    {
    deviceLost = true;
    }
  else
    {
    failedCheck(hr);
    }
  }
Esempio n. 7
0
Operator::~Operator()
{
    deviceLost();
}