RE: Memory leak when using directshow, help!
- From: Peter Donson <PeterDonson@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Dec 2005 05:42:03 -0800
Hello Lee,
I believe I am chasing the same problem with essentially the same app level
code, but playing a wmv file.
Can I suggest you take a look at your window list with the remote spy tool.
On my system every RenderFile() creates 2 windows with title
"ActiveMovieWindow", one for class "VideoRenderer" and one for class
"FilterGraphWindow". These do not get destroyed after all the directshow
interfaces have been "Release()"ed.
What "ActiveMovieWindow" windows do you see and are they destroyed?
I see the same behaviour in desktop windows.
I have used the ocx to play the same files with no memory leak. Presumably
the ocx is built on top of directshow in the same way as our apps but knows
what to do about those windows. Sadly I need to use a custom video renderer
so I can no longer use the ocx.
Peter Donson (peterdotdonsonatteckprodotcom)
"Lee" wrote:
> Hi, All
>
> I am using eVC.40 sp2 and programm on wince4.2.
> I use directshow to play mp3 music file.
> The following is the code:
>
> IGraphBuilder *pGraph;
> IMediaControl *pMediaControl;
> IMediaEventEx *m_pMediaEvent;
> IBasicAudio *m_pBasicAudio;
> IMediaPosition *pMediaPosition;
>
> void DirectShowInit()
> {
>
> TRACE(_T("Mp3Player:: +++DirectShowInit\r\n"));
>
>
> // Create the filter graph manager.
> CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
> IID_IGraphBuilder, (void **)&pGraph);
>
> pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
>
> pGraph->QueryInterface(IID_IBasicAudio, (void **)&m_pBasicAudio);
>
> pGraph->QueryInterface(IID_IMediaEventEx, (void **)&m_pMediaEvent);
>
> pGraph->QueryInterface(IID_IMediaPosition, (void **)&pMediaPosition);
>
> TRACE(_T("Mp3Player:: ---DirectShowInit\r\n"));
>
> }
>
> void DirectShowClean()
> {
>
> TRACE(_T("Mp3Player:: +++DirectShowClean\r\n"));
>
> pMediaControl->Release();
> m_pMediaEvent->Release();
> m_pBasicAudio->Release();
> pMediaPosition->Release();
> pGraph->Release();
>
>
>
> TRACE(_T("Mp3Player:: ---DirectShowClean\r\n"));
> }
>
> void Play(TCHAR *szfilename)
> {
> REFTIME length,curPositon;
>
> GetDlgItem(IDC_BTN_PLAY)->EnableWindow(false);
>
> m_bStop = false;
>
> while(1)
> {
> DirectShowInit();
>
> pGraph->RenderFile(szfilename, NULL);
>
> pMediaPosition->get_Duration(&length);
>
> pMediaControl->Run();
>
>
> while(1)
> {
> Sleep(500);
>
> pMediaPosition->get_CurrentPosition(&curPositon);
> if(curPositon >= length)
> break;
>
>
> }
>
> pMediaControl->Stop();
>
> pMediaPosition->put_CurrentPosition(0);
>
> // Clean up.
> DirectShowClean();
>
>
> }
> }
>
> In the main function, I init the com and play multi mp3 file like this:
>
> woid DoWork()
> {
> CoInitializeEx(NULL, COINIT_MULTITHREADED);
>
> CString playlist[10];
>
> .....
> .....
> for(int i =0;i<10;i++)
> {
> play(playlist[i]);
> }
>
> CoUninitialize();
>
> }
>
> When music files are being played, I watch the systme memory state by
> control panel utility. The programm memory available is decreasing.
>
> The problem is in my source code,not in the low level driver. Because if i
> use ceplayer to play, everything is ok.
>
> Is there any problem in my source code?
> BTW, is there any general method to detect memory leak in eVC? Is there any
> system API to do this?
>
> Thanks a lot!!!!
>
>
.
- Follow-Ups:
- Re: Memory leak when using directshow, help!
- From: Michael J. Salamone
- Re: Memory leak when using directshow, help!
- References:
- Memory leak when using directshow, help!
- From: Lee
- Memory leak when using directshow, help!
- Prev by Date: regsitry entries in emulator
- Next by Date: ShellExecuteEx problem
- Previous by thread: Re: Memory leak when using directshow, help!
- Next by thread: Re: Memory leak when using directshow, help!
- Index(es):
Relevant Pages
|