PDA

View Full Version : weird smart pointer crash?



Unregistered
January 19, 2004, 11:07:08
Hi Everyone

I'm using the following code:

void Initialize()
{
m_pCallbackListener = new CListener(this);
m_pFrameGrabber = new DirectShowLib::Grabber();
//Reset callback
m_pFrameGrabber->setCallback();

// Get the list of all available video capture devices.
DirectShowLib::Grabber::tVidCapDevListPtr pVidCapDevList = m_pFrameGrabber->getAvailableVideoCaptureDevices();
if( pVidCapDevList == 0 || pVidCapDevList->empty() )
{
return false;
}
//Choose the first grabber
m_pFrameGrabber->openDev( pVidCapDevList->at(0));
DirectShowLib::Grabber::tVidNrmListPtr pVidNrmList;
// Determine whether the device is capable of setting the video norm.
if ( m_pFrameGrabber->isVideoNormAvailableWithCurDev() )
{
// Query for all available video norms.
pVidNrmList = m_pFrameGrabber->getAvailableVideoNorms();
if ( pVidNrmList == 0 )
{
return false;
}

m_pFrameGrabber->setVideoNorm( pVidNrmList->at( 0 ) );
if ( m_pFrameGrabber->getLastError() )
{
return false;
}
}
/* Generate a list of all available video formats and set the one
that was selected by the user.
*/
DirectShowLib::Grabber::tVidFmtListPtr pVidFmtList = m_pFrameGrabber->getAvailableVideoFormats();
if ( pVidFmtList == 0 )
{
return false;
}
// Set the selected video format.
m_pFrameGrabber->setVideoFormat( pVidFmtList->at( 0 ) );
if ( m_pFrameGrabber->getLastError() )
{
return false;
}

DirectShowLib::Grabber::tInChnListPtr pInChnList;
// Determine whether the device is capable of setting the input channel.
if ( m_pFrameGrabber->isInputChannelAvailableWithCurDev() )
{
// Get the list of all available input channels.
pInChnList = m_pFrameGrabber->getAvailableInputChannels();
if ( pInChnList == 0 )
{
return false;
}

// Set the selected input channel
m_pFrameGrabber->setInputChannel( pInChnList->at(0));
if ( m_pFrameGrabber->getLastError() )
{
return false;
}
}

// Assign the number of buffers to the cListener object.
m_pCallbackListener->setBufferSize(1);

// Register the pcListener object for the frame ready and
// the overlay callback event.
m_pFrameGrabber->addListener( m_pCallbackListener, DirectShowLib::GrabberListener::eFRAMEREADY|
DirectShowLib::GrabberListener::eOVERLAYCALLBACK );


// Choose a sink format that is copmatible to the given video format.
DirectShowLib::tColorformatEnum eSinkColorformat = DirectShowLib::eY8;
// start the grabber in single snap mode with a Colorformat corresponding to the videoformat.
m_pFrameGrabber->setSinkType( FrameGrabberSink( FrameGrabberSink::tFrameGrabberMode::eSNAP, eSinkColorformat ) );
// Set a MemBufferCollection.
DirectShowLib::Grabber::tMemBufferCollectionPtr pMemBuffColl = m_pFrameGrabber->newMemBufferCollection( 1 );
m_pFrameGrabber->setActiveMemBufferCollection( pMemBuffColl );
m_pFrameGrabber->startLive( true ); // Start the grabber.
//Set gamma value
m_pFrameGrabber->setProperty(VideoProcAmp_Gamma,1l);
//Get camera offset(contrast) range
tsPropertyRange tsRange = m_pFrameGrabber->getPropertyRange(VideoProcAmp_Contrast);
m_fCameraMinOffset = tsRange.min;
m_fCameraMaxOffset = tsRange.max;
tsRange = m_pFrameGrabber->getPropertyRange(VideoProcAmp_Brightness);
m_fCameraMinGain = tsRange.min;
m_fCameraMaxGain = tsRange.max;

//Get image size
m_szBufferSize = m_pFrameGrabber->getVideoFormat().getSize();
}

but when this function ends the application which calls a dll with this function crashes
on the following code :

std::allocator<DirectShowLib::AnalogChannelItem>::deallocate(void*,unsigned int)
{
operator delete(_P);
}

any ideas?

Stefan Geissler
January 22, 2004, 08:31:29
Hello,

Without an error message it is hard to make a diagnose.
Is your code generation set to “Multithreaded DLL” / “Multithreaded DLL debug”?
If the error occurs can you open the debug call stack window and check whether the error occurs in a function called “_CRTValidheappointer()”? If so, you have created a debug version of your application and run it with the release DLLs of IC Imaging Control. In this case, change the debug execution path to “classlib\debug” of your IC Imaging Control installation path.