IMediaControl DirectShow

  • Thread starter Thread starter anonymous
  • Start date Start date
A

anonymous

I recently purchased a new computer and with this started having an issue
with previously written software which works fine on XP suddenly crashing
when I close on Vista. Inside the dispose event for the class the first
think I do is stop the running graph and tear down existing filters. I am
receiving a "System.AccessViolationException" when I call the
lpMediaControl->Stop();. Just to make sure I wasnt missing anything I added
the Pause() and sleep before both of which succeed. Once it runs the stop
on the media control I get the error. Any ideas on what I might check?

IEnumFilters *lpEnumFilters;
IBaseFilter *lpBaseFilter;
ULONG lcFetched;
HRESULT hr = NOERROR;

IMediaControl *lpMediaControl = NULL;
if (gpGraphBuilder->QueryInterface(IID_IMediaControl, (void
**)&lpMediaControl) == S_OK && lpMediaControl)
{
OAFilterState lfilterState = NULL;
if(lpMediaControl->GetState(1000, &lfilterState) == S_OK && lfilterState)
if(lfilterState == State_Running)
{
hr = lpMediaControl->Pause();
System::Threading::Thread::Sleep(1000);
hr = lpMediaControl->Stop();
}
SAFE_RELEASE(lpMediaControl);
}
 
Should anyone find this later the problem was actually with the ffdshow
filter being used in the graph for recording. This could be reproduced by
setting up the same filters inside graphedit and attempting to stop the
graph. No work around that I could find so I simply moved my encoder over
to 3ivx MPEG-4 Video Encoder and problem solved.

Hope this helps.
 
Back
Top