Re: Crash on seek and stop




Geraint Davies wrote:
On 28 Sep 2006 08:31:11 -0700, czalkin@xxxxxxxxx wrote:

I have inherited control of a video recording playback system and it is
up to me to solve some freezing bugs. I've never worked with
directshow (or C#, which this program was written in).

The system hangs on a call to IMediaControl::Stop() as well as on
IMediaSeeking::SetPositions() (These are the C# wrapper names, I
assume they are the same as the native com object names) This seems to
be a common issue on the newsgroups, but I can't find a common
solution. Is there a list of usual suspects I can look for?

I have tried to call Pause() before Stop(), and added a delay between
them, but that didn't seem to help. The application is still running,
but breaking in with the debugger can't trace below the Stop() call. I
don't have any threads running that seem to interfere with the stopping
of the playback, but maybe there's some interaction that isn't obvious
(in which case, what's a good thing to look for?)

Perhaps the filtergraph is set up incorrectly? I can post a version of
that code if someone cares to help me look at it.


Thanks!

This is not going to be easy for you to debug. The stop is probably waiting
for one of the worker threads that is blocked inside a filter.

The graph will pause before stopping or seeking. A thread originating in a
source or demux filter will be calling down through a number of filters,
but when the graph is paused it will block, probably waiting for GetBuffer
to release another buffer, which it will not do while paused.

The app thread then tries to stop the graph. The filter owning the thread
should call flush and then wait for its thread to exit before stopping, and
it is probably at this stage that you are seeing the hang. Flush will
release any buffers and should prevent the worker thread blocking, but it
needs to be passed right down the graph. I would think that either the
flush is not being passed down the graph or the worker thread is not
checking the stop signal correctly. Either way, the problem is somewhere in
the filters and not in your app code.

G

Thanks for the information. I'm only using one nonstandard filter in
my graph, and that's the Elecard MPEG2 Decoder filter. (Seen below as
MPEG2DecoderClass).

I also forgot to mention that I am playing three mpeg videos
concurrently. Could this cause and issue? I don't have the option to
play one at a time, as this is student performance review from multiple
angles.

I've attached the graph creation (snipped of error checking and the
like...) below.


m_graphBuilder = new FilterGraph() as IFilterGraph2;
hr = capGraphBldr.SetFiltergraph(m_graphBuilder);

IBaseFilter sourceFilter = null;
m_graphBuilder.AddSourceFilter(FileName, "InputStream", out
sourceFilter);
IPin fileOutputPin = RpsUtils.getPin(sourceFilter, PinDirection.Output,
"");

// MPEG-2 Stream Splitter
MPEG2SplitterClass mpgSplitter = new MPEG2SplitterClass ();
IBaseFilter mpgSplitterIntfc = (IBaseFilter) mpgSplitter;
m_graphBuilder.AddFilter(mpgSplitterIntfc, "MPEG-2 Stream Splitter");
IPin splitterInputPin = RpsUtils.getPin(mpgSplitterIntfc,
PinDirection.Input, "");

//Connect file source to MPEG-2 splitter
m_graphBuilder.Connect(fileOutputPin, splitterInputPin);

// Get video and audio out pins from splitter
IPin splitterVideoOutputPin = RpsUtils.getPin(mpgSplitterIntfc,
PinDirection.Output, "Video");
IPin splitterAudioOutputPin = RpsUtils.getPin(mpgSplitterIntfc,
PinDirection.Output, "Audio");

//Create and add MPEG Video Decoder filter to graph
MPEG2DecoderClass mpgVideoDecoder = new MPEG2DecoderClass();
IBaseFilter mpgVideoDecoderIntfc = (IBaseFilter) mpgVideoDecoder;
m_graphBuilder.AddFilter(mpgVideoDecoderIntfc, "MPEG Video Decoder");
IPin mpgVideoDecoderInputPin = RpsUtils.getPin(mpgVideoDecoderIntfc,
PinDirection.Input, "");

//Connect MPEG splitter to MPEG Video Decoder
m_graphBuilder.Connect(splitterVideoOutputPin,
mpgVideoDecoderInputPin);

// Get video out pin for decoder, had to wait until after last
connection for it to work
IPin mpgVideoDecoderOutputPin = RpsUtils.getPin(mpgVideoDecoderIntfc,
PinDirection.Output, "");

//Create and add Video Renderer filter to graph
VideoRenderer videoRenderer = new VideoRenderer();
IBaseFilter videoRendererIntfc = (IBaseFilter) videoRenderer;
m_graphBuilder.AddFilter(videoRendererIntfc, "Video Renderer");
IPin videoRendererInputPin = RpsUtils.getPin(videoRendererIntfc,
PinDirection.Input, "");

//Connect Splitter to Video renderer
// Note: graph builder will automatically add MPEG-2 decompressor
between these two
m_graphBuilder.Connect(mpgVideoDecoderOutputPin,
videoRendererInputPin);

//Create and add Audio output card filter to graph if device is there
(or needed)
if( (m_AudioOutDeviceIntfc != null) && (splitterAudioOutputPin !=
null) )
{
m_graphBuilder.AddFilter( m_AudioOutDeviceIntfc, "Analog Audio Out
Device" );
IPin audioOutDeviceInputPin = RpsUtils.getPin(m_AudioOutDeviceIntfc,
PinDirection.Input, "");

//Connect the pins
m_graphBuilder.Connect(splitterAudioOutputPin,
audioOutDeviceInputPin);
}


Thanks for any help!

.



Relevant Pages

  • Re: CTransInPlaceFilter woes
    ... Why don't you post the graph building code? ... // This creates a fully working graph minus our filter ... CComPtr pRenderer; ... CComPtr <IPin> ppinOverlayOut; ...
    (microsoft.public.win32.programmer.directx.video)
  • Writing a Splitter filter that works with DirectShow editing services
    ... The filter works fine in a simple graph like ... My splitter inherits from CBaseFilter and implements IMediaSeeking. ... In case one i just get a Pause from the Filter Graph Manager, ...
    (microsoft.public.win32.programmer.directx.video)
  • AddSourceFilterForMoniker() locks up sometimes.
    ... I've coded a simple filter graph to capture frames from a video camera ... I can grab frames from the Sample Grabber with no ...
    (microsoft.public.win32.programmer.directx.video)
  • AddSourceFilterForMoniker() locks up sometimes.
    ... I've coded a simple filter graph to capture frames from a video camera ... I can grab frames from the Sample Grabber with no ...
    (microsoft.public.multimedia.directx.dshow.programming)
  • Re: Confusing message from GraphEdit
    ... GetState to the filter graph I walked thru the list of the filters and asked ... From GraphEdit I press Run and Pause - works fine. ...
    (microsoft.public.win32.programmer.directx.video)