Here's the CloseCamera code:
pVSC[a_nCamNum-1].Release();
piBDR[a_nCamNum-1].Release(); // filter for BDR camera
if (pFilter[a_nCamNum-1]) // like gcap.Vcap in Amcap
NukeDownstream(pFilter[a_nCamNum-1], a_nCamNum);
if (pFilter[a_nCamNum-1])
pBuilder[a_nCamNum-1]->ReleaseFilters();
pFilter[a_nCamNum-1].Release();
pEvent[a_nCamNum-1].Release();
pControl[a_nCamNum-1].Release();
pGraph[a_nCamNum-1].Release();
if (pBuilder[a_nCamNum-1] != NULL)
{
//delete pBuilder[a_nCamNum-1];
pBuilder[a_nCamNum-1] = NULL;
}
The program works if the delete row is commented out - but causes
memory leaks.
What am I doing wrong?
Any ideas or suggestions?
Thanks!
Hi!
I added the row
graphBuilder2_.Release();
to the ReleaseFilters() function in SampleCGB.h.
Is this OK?
The delete pBuilder works, but i then get errors with other filters
that don't succeed being released.
Please help!
Mechi
I know - I tried using smart pointers, but I get an error
1>c:\program files\microsoft sdks\windows\v6.1\samples\multimedia
\directshow\common\smartptr.h(75) : error C2039: 'AddRef' : is not a
member of 'ISampleCaptureGraphBuilder'
1> c:\work\bec\capturefiltersample\samplecgb.h(44) : see
declaration of 'ISampleCaptureGraphBuilder'
1> c:\program files\microsoft sdks\windows\v6.1\samples
\multimedia\directshow\common\smartptr.h(70) : while compiling class
template member function 'SmartPtr<T>::SmartPtr(T *)'
1> with
1> [
1> T=ISampleCaptureGraphBuilder
1> ]
1> c:\work\bec\capturefiltersample\bdr_samplecodedlg.cpp
(49) : see reference to class template instantiation 'SmartPtr<T>'
being compiled
1> with
1> [
1> T=ISampleCaptureGraphBuilder
1> ]
Since I took the code (SampleCGB.cpp and .h) from the SDK, I though i
could use it as is.
Thanks!
Mechi
=====================================================================================
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
'AmCap.exe': Loaded 'C:\WINDOWS\system32\mslbui.dll', Symbols loaded
(source information stripped).
The thread 'COutputQueue::InitialThreadProc' (0x168c) has exited with
code 0 (0x0).
The thread 'Win32 Thread' (0x1004) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1f8) has exited with code 0 (0x0).
HEAP[AmCap.exe]: HEAP: Free Heap block d6d000 modified at d6d184 after
it was freed
Windows has triggered a breakpoint in AmCap.exe.
This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
The thread 'Win32 Thread' (0x1208) has exited with code 0 (0x0).
'AmCap.exe': Loaded 'C:\vcam\Bin\VCamD.ax', Symbols loaded.
The thread 'Win32 Thread' (0x1648) has exited with code 0 (0x0).
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
The thread 'Win32 Thread' (0x14fc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x139c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x109c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1684) has exited with code 0 (0x0).
First-chance exception at 0x75f45e2d (devenum.dll) in AmCap.exe:
0xC0000005: Access violation reading location 0x00000000.
The thread 'Win32 Thread' (0x980) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe18) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x440) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x300) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x964) has exited with code 0 (0x0).
Windows has triggered a breakpoint in AmCap.exe.
This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
vcamd.ax(tid 1640) 46129 :
vcamd.ax(tid 1640) 46129 : ID Object Description
vcamd.ax(tid 1640) 46129 :
vcamd.ax(tid 1640) 46129 : 3 (0012EBF8)
Virtual Cam
vcamd.ax(tid 1640) 46129 : 2 (0012EBF8)
Virtual Cam
vcamd.ax(tid 1640) 46130 :
vcamd.ax(tid 1640) 46130 : Total object count 2
'AmCap.exe': Unloaded 'C:\vcam\Bin\VCamD.ax'
Windows has triggered a breakpoint in AmCap.exe.
This may be due to a corruption of the heap, and indicates a bug in
AmCap.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : ID Object Description
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : 143 (0012EBF8)
BDR Camera
BECfilter.ax(tid 1640) 61263 : 142 (0012EBF8) BDR
BEC Camera
BECfilter.ax(tid 1640) 61263 : 3 (0012EBF8)
BDR Camera
BECfilter.ax(tid 1640) 61263 : 2 (0012EBF8) BDR
BEC Camera
BECfilter.ax(tid 1640) 61263 :
BECfilter.ax(tid 1640) 61263 : Total object count 4
'AmCap.exe': Unloaded 'C:\Work\BEC\BECfilter\Bin\BECfilter.ax'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\quartz.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\qcap.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\msvfw32.dll'
'AmCap.exe': Unloaded 'C:\WINDOWS\system32\devenum.dll'
The thread 'Win32 Thread' (0x1090) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1678) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x470) has exited with code 0 (0x0).
The program '[5712] AmCap.exe: Native' has exited with code 0 (0x0).
If you get a heap corruption, you have some serious bug - you are
overwriting variables or buffers in the data segment. I suspect your
FillBuffer code is writing more data than can fit into the sample
buffer.....
Vivek