Beispiel #1
0
XnStatus XnDeviceBase::DestroyStream(const XnChar* StreamName)
{
	XnStatus nRetVal = XN_STATUS_OK;

	xnLogInfo(XN_MASK_DDK, "Destroying stream '%s'...", StreamName);

	// keep the stream name (we now delete the module, so the name will be lost)
	XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH];
	strncpy(strStreamName, StreamName, XN_DEVICE_MAX_STRING_LENGTH);

	// Find the stream
	XnDeviceModuleHolder* pStreamHolder;
	nRetVal = FindStream(strStreamName, &pStreamHolder);
	XN_IS_STATUS_OK(nRetVal);

	// remove it from map
	nRetVal = RemoveModule(strStreamName);
	XN_IS_STATUS_OK(nRetVal);

	// and free it's memory
	DestroyStreamModule(pStreamHolder);

	// free memory of registered properties to this stream
	FreeModuleRegisteredProperties(StreamName);

	// raise event
	m_OnStreamsChangeEvent.Raise(GetDeviceHandle(), strStreamName, XN_DEVICE_STREAM_DELETED);

	xnLogVerbose(XN_MASK_DDK, "'%s' stream destroyed.", strStreamName);

	return XN_STATUS_OK;
}
Beispiel #2
0
XnStatus XnDeviceBase::Destroy()
{
    XnStatus nRetVal = XN_STATUS_OK;

    // free all modules
    while (m_Modules.Size() != 0)
    {
        XnDeviceModuleHolder* pModuleHolder = m_Modules.Begin()->Value();
        if (IsStream(pModuleHolder->GetModule()))
        {
            XnChar strName[XN_DEVICE_MAX_STRING_LENGTH];
            strcpy(strName, pModuleHolder->GetModule()->GetName());
            nRetVal = DestroyStream(strName);
            XN_IS_STATUS_OK(nRetVal);
        }
        else
        {
            // free memory of registered properties to this module
            FreeModuleRegisteredProperties(m_Modules.Begin()->Key());

            pModuleHolder->GetModule()->Free();
            DestroyModule(pModuleHolder);
            m_Modules.Remove(m_Modules.Begin());
        }
    }

    m_pDevicePropertiesHolder = NULL;

    m_Modules.Clear();

    // close dump
    xnDumpFileClose(m_StreamsDataDump);

    if (m_hLock != NULL)
    {
        xnOSCloseCriticalSection(&m_hLock);
        m_hLock = NULL;
    }

    return XN_STATUS_OK;
}
Beispiel #3
0
XnStatus XnDeviceBase::DestroyStream(const XnChar* StreamName)
{
    XnStatus nRetVal = XN_STATUS_OK;

    xnLogInfo(XN_MASK_DDK, "Destroying stream '%s'...", StreamName);

    // keep the stream name (we now delete the module, so the name will be lost)
    XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH];
    strncpy(strStreamName, StreamName, XN_DEVICE_MAX_STRING_LENGTH);

    xnl::AutoCSLocker lock(m_hLock);

    // Find the stream
    XnDeviceModuleHolder* pStreamHolder;
    nRetVal = FindStream(strStreamName, &pStreamHolder);
    XN_IS_STATUS_OK(nRetVal);

    XnDeviceStream* pStream = (XnDeviceStream*)pStreamHolder->GetModule();
    XnUInt32 nRefCount = pStream->DecRef();
    if (0 == nRefCount)
    {
        // remove it from map
        nRetVal = RemoveModule(strStreamName);
        XN_IS_STATUS_OK(nRetVal);

        // and free it's memory
        DestroyStreamModule(pStreamHolder);

        // free memory of registered properties to this stream
        FreeModuleRegisteredProperties(StreamName);

        xnLogVerbose(XN_MASK_DDK, "'%s' stream destroyed.", strStreamName);
    }
    else
    {
        xnLogVerbose(XN_MASK_DDK, "'%s' stream now has %d references.", strStreamName, nRefCount);
    }

    return XN_STATUS_OK;
}