在IGraphbuilder上死锁 - > connect()

时间:2013-04-06 00:35:30

标签: directshow deadlock

所以在windows direct中调用专家显示:

我正在尝试在一台计算机上运行多个摄像头以用于我们的测试应用程序并获得与DirectShow相关的间歇性死锁。我遇到的最新死锁是IGraphBuilder Connect函数。

我首先添加我想要添加的过滤器,然后我得到我要连接的2个引脚,当我调用connect时,应用程序会陷入死锁。

在下面的代码中,m_graphbuilderIGraphBuilder对象。

这是我的代码:

HRESULT UVCCamera::SetupFrameGrabFilter()
{

    HRESULT hr = S_OK;
    CUnknown* unknown = FrameGrabber::CreateInstance(NULL, &hr);

   _ASSERT(SUCCEEDED(hr));
   _ASSERT(unknown);

   if (FAILED(hr))
      return hr;

   hr = unknown->NonDelegatingQueryInterface(IID_IBaseFilter, (void**)&m_frameGrabber);
   ASSERT(SUCCEEDED(hr));

   hr = m_graphBuilder->AddFilter(m_frameGrabber, TEXT("Frame Grabber Filter"));
   ASSERT(SUCCEEDED(hr));

  if (FAILED(hr))
      return hr;

  StopCapture();

   // Get the output pin and the input pin
  CComPtr<IPin> sourcePin;
  CComPtr<IPin> dumpPin;

  // Get the filter correpsonding to capture device so can connect camera with grabber
  utility::GetPin(m_uvcExtension.GetCaptureFilter(), PINDIR_OUTPUT, 0, &sourcePin);
  utility::GetPin(m_frameGrabber, PINDIR_INPUT, 0, &dumpPin);

  // Connect the filters (returns VFW_E_CANNOT_CONNECT if not starting in a disconnected state)
   **return m_graphBuilder->Connect(sourcePin, dumpPin);**** DEADLOCK source <----- that does not return**

}

这里是callstack:

ntdll.dll!_ZwCreateFile@44()  + 0x12 bytes  
ntdll.dll!_ZwCreateFile@44()  + 0x12 bytes  
ole32.dll!CRetailMalloc_Alloc(IMalloc * pThis, unsigned long cb)  Line 641  C++
ksproxy.ax!CreatePinHandle()  + 0x70 bytes  
ksproxy.ax!CKsOutputPin::ProcessCompleteConnect()  + 0x14e bytes    
ksproxy.ax!CKsOutputPin::CompleteConnect()  + 0x12 bytes    
ksproxy.ax!CBasePin::AttemptConnection()  + 0x62 bytes  
ksproxy.ax!CBasePin::TryMediaTypes()  + 0x68 bytes  
ksproxy.ax!CBasePin::AgreeMediaType()  + 0x73 bytes 
ksproxy.ax!CBasePin::Connect()  + 0x64 bytes    
ksproxy.ax!CKsOutputPin::Connect()  + 0x17d bytes   
quartz.dll!CFilterGraph::ConnectDirectInternal()  + 0x83 bytes  
quartz.dll!CFilterGraph::ConnectByFindingPin()  + 0x71 bytes    
quartz.dll!CFilterGraph::ConnectUsingFilter()  + 0x72 bytes 
quartz.dll!CFilterGraph::ConnectViaIntermediate()  + 0x113 bytes    
quartz.dll!CFilterGraph::ConnectRecursively()  + 0x78 bytes 
quartz.dll!CFilterGraph::ConnectInternal()  + 0xde bytes    
**quartz.dll!CFilterGraph::Connect()  + 0x17 bytes** ---< called into DirectShow    
cam.dll!UVCCamera::SetupFrameGrabFilter()  Line 827 + 0x16 bytes    C++
cam.dll!UVCCamera::SetupCapture(const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & deviceInstanceId)  Line 305 + 0x7 bytes   C++
cam.dll!UVCCamera::Initialize(const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & deviceInstanceId, int timeout, int flags)  Line 113 + 0xa bytes C++
cam.dll!`anonymous namespace'::createCamera(unsigned int & hCamera, int timeout, int flags)  Line 252 + 0x13 bytes  C++
cam.dll!`anonymous namespace'::CoreThreadFunc(void * data)  Line 912 + 0x17 bytes   C++
kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes    
ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes   
ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes

我可以做些什么来防止死锁?

0 个答案:

没有答案
相关问题