PDA

View Full Version : callbacks in DEBUG and RELEASE



obscuraniklas
March 19, 2007, 18:15:04
Hi i have a problem with the callback function in

void CListener::frameReady( Grabber& caller, smart_ptr<MemBuffer> pBuffer, DWORD currFrame)
{

}

If i run my program in debug mode in the compiler it works fine, if i start it from explorer it also works fine.

However if i make a release build ( Multi-threaded DLL (/MD) ) it also works fine if i run it as (Start Debuging F5) but if i run it as (Start Without Dubuging Ctrl-F5) it never reaches frameReady. ( or if i start it form explorer )

Any ideas. i dont want to run in Multi-threaded Debug DLL if i can avoid it.

i Use Visual Studio 2005 under Vista with the latest Vista SP for Visual Studio.

thanks , niklas

Stefan Geissler
March 20, 2007, 08:05:24
Hi Niklas,

The frameReady is called only, if the snapmode of the sink has been set to false:


CMainFrame::CMainFrame()
: m_pSink( DShowLib::FrameHandlerSink::create( DShowLib::eY800, 5 ) ),
m_IsStillImageValid( false )
{
m_pSink->setSnapMode( false); // Means: call the frameReady()
m_Grabber.setSinkType( m_pSink );
}


I would suppose a not initialized variable in the first step.
What about the callback sample? Does it work as expected or has it the same behaviour than your application?

obscuraniklas
March 20, 2007, 18:10:20
That solved it!

Thanks!!!!!!!

obscuraniklas
March 20, 2007, 19:05:06
Another quick question.

i use

if( !setupDeviceFromFile( * grabber ) )
{
return false;
}

is it easy way to change that if there is a lastSelectedDeviceState.xml it loads without having to press ok on the dialog window.

Stefan Geissler
March 21, 2007, 08:15:53
Hi,

yes it is. You can call grabber.loadDeviceStateFromFile("lastSelectedDeviceState.xml") directly.

( http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_loadDeviceStateFromFile.htm )

For example (from the "Mainframe.cpp" of the "sample\vc6\demoapp") :



void LoadPreviouslyUsedDevice()
{
if( !m_Grabber.loadDeviceStateFromFile("lastSelectedDeviceState.xml") )
{
DShowLib::Error loadError = m_Grabber.getLastError();
// Evaluate the returned error code.
CString cErrorText;
switch( loadError )
{
case DShowLib::eINVALID_PARAM_VAL : cErrorText = "Invalid XML format.";
break;
case DShowLib::eINCOMPATIBLE_VERSION : cErrorText = "Incompatible XML version.";
break;
case DShowLib::eINCOMPLETE : cErrorText = "Not all properties could be restord.";
break;
case DShowLib::eDEVICE_NOT_FOUND : cErrorText = "Previously used device not found.";
break;
}

MessageBox(cErrorText, _T("Restoring the video capture device"), MB_ICONINFORMATION|MB_OK|MB_DEFBUTTON1);
}
}