Discussion:
Threading model, interop and Direct Show
(too old to reply)
m***@gmail.com
2007-09-26 14:24:35 UTC
Permalink
I have a DirectShow player implemented as an ATL COM object.
The threading model is CComMultiThreadModel.
Whenever the player builds the graph to render a media file, it also
launches a thread which monitors the graph events (IMediaEvent).


The player, as a COM object, exposes an event sync to the C# form is
embedded in.
Whenever the graph triggers an EC_COMPLETE event, the monitoring
thread will notify the form trough the event sync. The form will call
Pause method from the player which is converted in
IMediaControl::Pause().


Sometimes, in this specific scenario, IMediaControl::Pause blocks.


I am wondering what causes and how can I fix this problem.
Any advice is appreciated.
Olie
2007-09-26 18:22:29 UTC
Permalink
Post by m***@gmail.com
I have a DirectShow player implemented as an ATL COM object.
The threading model is CComMultiThreadModel.
Whenever the player builds the graph to render a media file, it also
launches a thread which monitors the graph events (IMediaEvent).
The player, as a COM object, exposes an event sync to the C# form is
embedded in.
Whenever the graph triggers an EC_COMPLETE event, the monitoring
thread will notify the form trough the event sync. The form will call
Pause method from the player which is converted in
IMediaControl::Pause().
Sometimes, in this specific scenario, IMediaControl::Pause blocks.
I am wondering what causes and how can I fix this problem.
Any advice is appreciated.
Does the IMediaEvent get cleared before calling Pause(). If I remember
correctly if the IMediaEvent is not cleared and the event monitoring
thread is not clear to process new events then the Pause() function
will block until it can generate new events.

You can use BeginInvoke() from the event thread to signal the main
form, that way it will not block the events processing
m***@gmail.com
2007-09-27 16:24:29 UTC
Permalink
Post by Olie
Post by m***@gmail.com
I have a DirectShow player implemented as an ATL COM object.
The threading model is CComMultiThreadModel.
Whenever the player builds the graph to render a media file, it also
launches a thread which monitors the graph events (IMediaEvent).
The player, as a COM object, exposes an event sync to the C# form is
embedded in.
Whenever the graph triggers an EC_COMPLETE event, the monitoring
thread will notify the form trough the event sync. The form will call
Pause method from the player which is converted in
IMediaControl::Pause().
Sometimes, in this specific scenario, IMediaControl::Pause blocks.
I am wondering what causes and how can I fix this problem.
Any advice is appreciated.
Does the IMediaEvent get cleared before calling Pause(). If I remember
correctly if the IMediaEvent is not cleared and the event monitoring
thread is not clear to process new events then the Pause() function
will block until it can generate new events.
You can use BeginInvoke() from the event thread to signal the main
form, that way it will not block the events processing- Hide quoted text -
- Show quoted text -
Thanks for the reply.

The problem was caused by calling IMediaControl::Stop() right before
triggering the event.
If I don't call Stop(), everything works fine.

Loading...