// Create the event that will signal the thread for commands
m_handle[0] = CreateEvent( NULL, FALSE, FALSE, NULL );
if( m_handle[0] == NULL )
{
ERR( HRESULT_FROM_WIN32( GetLastError() ));
}
m_handle[1] = 0;
// Create the event to sync on to wait for the command to be executed
m_hCommandCompleted = CreateEvent( NULL, FALSE, FALSE, NULL ); //建立事件
if( m_hCommandCompleted == NULL )
{
ERR( HRESULT_FROM_WIN32( GetLastError() ));
}
// CCreate the thread that will run the filtergraph.
// The filtergraph is runing on a background thread to prevent any window message
// reentrancy issue.
m_hThread = CreateThread( NULL, 0, CGraphManager::ThreadProc, this, 0, &m_dwThreadId );//建立线程
if( m_hThread == NULL )
{
ERR( HRESULT_FROM_WIN32( GetLastError() ));
}
我还有一点很不明白 在运行的时候是先开始运行到 CGraphManager::BuildCaptureGraph() 这个函数
但是这个函数
HRESULT
CGraphManager::BuildCaptureGraph()
{
RETAILMSG(1,(L"CGraphManager::BuildCaptureGraph() \n"));
// The Graph is built on a separate thread to
// prevent reentrancy issues.
m_currentCommand = COMMAND_BUILDGRAPH;
SetEvent( m_handle[0] );
WaitForSingleObject( m_hCommandCompleted, INFINITE ); //请看这句话