Exemplo n.º 1
0
XnStatus XnFrameStream::CreateStreamData(XnStreamData** ppStreamData)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XnStreamData* pStreamData;

    // we create a StreamData object with no buffer allocated. The buffer will just be
    // a pointer to the triple buffer
    nRetVal = XnStreamDataCreateNoBuffer(&pStreamData, GetName());
    XN_IS_STATUS_OK(nRetVal);

    // However, we don't want the user to get a null pointer, even if no new frame yet,
    // so we'll initialize the data with one of the buffers
    nRetVal = m_pBufferPool->GetBuffer(&pStreamData->pInternal->pLockedBuffer);
    if (nRetVal != XN_STATUS_OK)
    {
        XnStreamDataDestroy(&pStreamData);
        return (nRetVal);
    }

    pStreamData->pData = (void*)pStreamData->pInternal->pLockedBuffer->GetData();

    *ppStreamData = pStreamData;

    return (XN_STATUS_OK);
}
Exemplo n.º 2
0
XN_DDK_API XnStatus XnStreamDataCreate(XnStreamData** ppStreamOutput, const XnChar* StreamName, XnUInt32 nAllocSize)
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = XnStreamDataCreateNoBuffer(ppStreamOutput, StreamName);
	XN_IS_STATUS_OK(nRetVal);

	XnStreamData* pStreamOutput = *ppStreamOutput;

	// allocate buffer
	nRetVal = XnStreamDataUpdateSize(pStreamOutput, nAllocSize);
	if (nRetVal != XN_STATUS_OK)
	{
		XnStreamDataDestroy(ppStreamOutput);
		return nRetVal;
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnFrameStream::CreateStreamData(XnStreamData** ppStreamData)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnStreamData* pStreamData;

	// NOTE: in any case, we must make sure data is not null, because some old applications
	// counts on it (they might read the data before the first frame).

	// check if the buffer pool has been set yet
	if (m_pBufferPool == NULL)
	{
		// Create it with a buffer. This buffer will be later on freed when buffers from 
		// the buffer pool will be used.
		nRetVal = XnStreamDataCreate(&pStreamData, GetName(), GetRequiredDataSize());
		XN_IS_STATUS_OK(nRetVal);
	}
	else
	{
		// we create a StreamData object with no buffer allocated. The buffer will just be 
		// a pointer from the buffer pool
		nRetVal = XnStreamDataCreateNoBuffer(&pStreamData, GetName());
		XN_IS_STATUS_OK(nRetVal);

		// take a buffer from the pool
		nRetVal = m_pBufferPool->GetBuffer(&pStreamData->pInternal->pLockedBuffer);
		if (nRetVal != XN_STATUS_OK)
		{
			XnStreamDataDestroy(&pStreamData);
			return (nRetVal);
		}

		pStreamData->pData = (void*)pStreamData->pInternal->pLockedBuffer->GetData();
	}

	*ppStreamData = pStreamData;
	
	return (XN_STATUS_OK);
}