Exemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////
// 
//  Function Name:  DisconnectCamera 
//  Description:    Disconnects the camera
//  Parameters:                    
//  Returns:        void
//  Summary:        Disconnecting the camera involves calling the 
//                  CDExitReleaseControl (which turns the camera off)
//                  and calling CDCloseSource (which closes the camera source)
//  Author:         CannonSDK
//                           
///////////////////////////////////////////////////////////////////////////
void CCameraConnect::DisconnectCamera()
{
	cdError err;

	if( m_fVFEnd )
	{
		/* A view finder is ended. */
		err = CDTermViewfinder( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
		//	goto	camerr;
		}
		
		/* A thread is ended. */
		m_fVFEnd = FALSE;
		g_CpVFThread->ResumeThread();
		WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE );
		
		// window related command
		//m_CViewFinder.SetWindowText( "Start" );
		//Invalidate();
		//UpdateWindow();	
	}
	if( m_hSource )
	{
		/* Remote release control mode is ended. */
		err = CDExitReleaseControl( m_hSource );
		// if( GETERRORID(err) != cdOK )
		//{
		//	goto	camerr;
		//}
		
		/* The function which receives the event from a camera is canceled. */
		//if( m_hCallbackFunction )
		//{
		//	err = CDUnregisterEventCallbackFunction( m_hSource, m_hCallbackFunction );
		//	if( GETERRORID(err) != cdOK )
		//	{
		//		goto	camerr;
		//	}
		//	m_hCallbackFunction = NULL;
		//}
		
		/* A device is closed. */
		err = CDCloseSource( m_hSource );
		//if( GETERRORID(err) != cdOK )
		//{
		//	goto	camerr;
		//}
		
		//m_hSource = NULL;
	}
	
	
	
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////////////////
// 
//  Function Name:  CameraError 
//  Description:    Called when any cdSDK functions has reported an error 
//  Parameters:     cdError err - the reported error               
//  Returns:        void
//  Summary:        This functions was written for the purpose of having 
//                  a specific way of dealing with errors generated by the 
//                  cdSDK.  The error codes and their meaning are located 
//                  in the cdError.h file.  
//  Author:         CannonSDK
//                           
///////////////////////////////////////////////////////////////////////////
void CCameraConnect::CameraError(cdError err)
{
	if(err != cdNOT_SUPPORTED ){
		char	szErrStr[256];
		wsprintf( szErrStr, "ErrorCode = 0x%08X", err );
		//MessageBox( szErrStr );
	}

	if( m_hSource )
	{
		//if( m_hCallbackFunction )
		//{
		//	CDUnregisterEventCallbackFunction( m_hSource, m_hCallbackFunction );
		//	m_hCallbackFunction = NULL;
		//}
		
		CDUnlockUI( m_hSource );
		CDCloseSource( m_hSource );
		m_hSource = NULL;
	}
	
}
Exemplo n.º 3
0
BOOL CCameraConnect::EndCamera()
{
	cdError			err;
	
	
	if( m_fVFEnd )
	{
		/* A view finder is ended. */
		err = CDTermViewfinder( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
			goto	camerr;
		}
		
		/* A thread is ended. */
		m_fVFEnd = FALSE;
		g_CpVFThread->ResumeThread();
		WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE );
	}
	
	if( m_hSource )
	{
		/* Remote release control mode is ended. */
		err = CDExitReleaseControl( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
			goto	camerr;
		}
		
		if( m_hCallbackFunction )
		{
			/* The function which receives the event from a camera is canceled. */
			err = CDUnregisterEventCallbackFunction( m_hSource, m_hCallbackFunction );
			if( GETERRORID(err) != cdOK )
			{
				goto	camerr;
			}
			m_hCallbackFunction = NULL;
		}
		
		/* A device is closed. */
		err = CDCloseSource( m_hSource );
		if( GETERRORID(err) != cdOK )
		{
			goto	camerr;
		}
		
		m_hSource = NULL;
	}
	
	/* A picture buffer is deleted. */
	if( m_BackSurface.hBmp )
	{
		DeleteObject( m_BackSurface.hBmp );
		m_BackSurface.hBmp = NULL;
	}
	
	//EndDialog( 0 );	
	return TRUE;
	
camerr:
	char	szErrStr[256];
	
	wsprintf( szErrStr, "ErrorCode = 0x%08X", err );
	//MessageBox( szErrStr );
	
	if( m_fVFEnd )
	{
		CDTermViewfinder( m_hSource );
		m_fVFEnd = FALSE;
		g_CpVFThread->ResumeThread();
		WaitForSingleObject( g_CpVFThread->m_hThread, INFINITE );
	}
	
	if( m_hSource )
	{
		CDExitReleaseControl( m_hSource );
		if( m_hCallbackFunction )
		{
			CDUnregisterEventCallbackFunction( m_hSource, m_hCallbackFunction );
			m_hCallbackFunction = NULL;
		}
		CDCloseSource( m_hSource );
		m_hSource = NULL;
	}
	
	if( m_BackSurface.hBmp )
	{
		DeleteObject( m_BackSurface.hBmp );
		m_BackSurface.hBmp = NULL;
	}
	
	//EndDialog( 0 );
	return FALSE;
}
Exemplo n.º 4
0
 /// dtor
 virtual ~SourceDeviceImpl() throw()
 {
    cdError err = CDCloseSource(m_hSource);
    LOG_TRACE(_T("CDCloseSource(%08x) returned %08x\n"), m_hSource, err);
 }