问题
I use DirectShowNet and when my Graph is stopped I release com objects.
The problem is that while I try to release COM objects [ filters, interface] ,sometimes this cleanup cause directshow graph not STOPPED.It "suspend".
If I do not make clen up [ release com objects] everthing is OK [ except i have memory leaks] ...
Here is how i make clean up:
if (videoWindow != nullptr)
{
Marshal::ReleaseComObject(videoWindow);
videoWindow = nullptr;
}
if (mediaControl != nullptr)
{
Marshal::ReleaseComObject(mediaControl);
mediaControl = nullptr;
}
if (graphBuilder != nullptr)
{
Marshal::ReleaseComObject(graphBuilder);
graphBuilder = nullptr;
}
....
What may be wrong? Do I relase filters in a wrong way? What may cause this "unstopable graph"?
回答1:
You did not mention which exactly call stopped (froze) and what was the call stack.
It is a typical scenario that a faulty filter, or it might be a Sample Grabber
filter with a faulty callback, fails to synchronize "main" thread on which it receives stop request, and a worker thread or worker activity on background thread, and eventually locks dead. You should be able to identify a broken component by checking thread states under debugger.
Another method to isolate the problem to specific filter is to temporarily remove certain fragment from the pipeline and find out addition/removal of which fragment leads to the problems.
来源:https://stackoverflow.com/questions/9792775/clean-up-directshow-graph-directshow-graph-is-not-stopping