Пример #1
0
bool NzAudio::Initialize()
{
	if (s_moduleReferenceCounter++ != 0)
		return true; // Déjà initialisé

	// Initialisation des dépendances
	if (!NzCore::Initialize())
	{
		NazaraError("Failed to initialize core module");
		Uninitialize();

		return false;
	}

	// Initialisation d'OpenGL
	if (!NzOpenAL::Initialize())
	{
		NazaraError("Failed to initialize OpenAL");
		Uninitialize();

		return false;
	}

	// Définition de l'orientation par défaut
	SetListenerDirection(NzVector3f::Forward());

	// Loaders
	NzLoaders_sndfile_Register();

	NazaraNotice("Initialized: Audio module");

	return true;
}
Пример #2
0
/*****************************************************************************************
Initialize
*****************************************************************************************/
int CUnMAC::Initialize(IAPEDecompress *pAPEDecompress) 
{
    // uninitialize if it is currently initialized
    if (m_bInitialized)
        Uninitialize();

    if (pAPEDecompress == NULL)
    {
        Uninitialize();
        return ERROR_INITIALIZING_UNMAC;
    }

    // set the member pointer to the IAPEDecompress class
    m_pAPEDecompress = pAPEDecompress;

    // set the last decode frame to -1 so it forces a seek on start
    m_LastDecodedFrameIndex = -1;

    m_pAPEDecompressCore = new CAPEDecompressCore(GET_IO(pAPEDecompress), pAPEDecompress);
    m_pPrepare = new CPrepare;

    // set the initialized flag to TRUE
    m_bInitialized = TRUE;
    
    m_pAPEDecompress->GetInfo(APE_INFO_WAVEFORMATEX, (long) &m_wfeInput);

    // return a successful value
    return ERROR_SUCCESS;
}
Пример #3
0
void BaseProgramRenderPass::Link()
{
	RETURN_IF(mProgramState->Program()==0||mIsLinked);
	SAFE_DELETE_DICTIONARY_VALUE(mUniforms);
	SAFE_DELETE_DICTIONARY_VALUE(mAttributes);

	uint program=mProgramState->Program();
	Render::Instance().LinkProgram(program);
	int outLinkStatus=Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::LinkStatus);

	if (!outLinkStatus)
	{
		//link error
		int outInfoLogLength=Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::InfoLogLength);

		HeapString infoLog((size_t)outInfoLogLength+1,true);
		Render::Instance().GetProgramInfoLog(program,infoLog);
		Log::FormatError("Failed to link effect:{}",infoLog.Buffer());
		Uninitialize();
		return ;
	}

	Render::Instance().ValidateProgram(program);
	int outValidateStatus=Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::ValidateStatus);

	if (!outValidateStatus)
	{
		//link error
		int outInfoLogLength=Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::InfoLogLength);

		HeapString infoLog((size_t)outInfoLogLength+1,true);
		Render::Instance().GetProgramInfoLog(program,infoLog);
		Log::FormatError("Failed to validate effect:{}",infoLog.Buffer());
		Uninitialize();
		return;
	}
	RenderStateMachine::Instance().Push(mProgramState);

	//add all uniforms
	uint uniformCount=(uint)Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::ActiveUniformCount);
	uint maxUniformNameLength=(uint)Render::Instance().GetProgramStatus(program,GraphicsProgramStatus::MaxActiveUniformNameLength);
	HeapString outName((size_t)maxUniformNameLength+1,true);
	FOR_EACH_SIZE(i,uniformCount)
	{
		int outSize;
		uint outDataType;
		Render::Instance().GetActiveUniformName(program,static_cast<uint>(i),outSize,outDataType,outName);
		int index= Render::Instance().GetUniformLocation(program,outName);	//NOTE: Cannot use i as index
		ShaderUniform* uniform=new ShaderUniform(this,index,outName,(GraphicsUniformDataType)outDataType);
		mUniforms.Add(outName,uniform);
	}
Пример #4
0
bool EffectRenderGroup::Uninitialize()
{
	FOR_EACH_TO(mGroups, Uninitialize());

	FOR_EACH_ITEM_CLEAR(mGroups, MaterialRenderGroupPool::Instance().Recycle);
	return true;
}
void COXNetBrowseTree::PostNcDestroy() 
{
	// Unitialize the control
	Uninitialize();

	CTreeCtrl::PostNcDestroy();
}
Пример #6
0
CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	CLStatus s = Initialize();
	if(!s.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Initialize error", 0);
		return CLStatus(-1, 0);
	}
	
	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		if(pMsg == 0)
		{
			CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), pMsg == 0", 0);
			continue;
		}
		
		CLStatus s3 = DispatchMessage(pMsg);

		delete pMsg;

		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)
			break;
	}

	CLStatus s4 = Uninitialize();
	if(!s4.IsSuccess())
	{
		CLLogger::WriteLogMsg("In CLMessageLoopManager::EnterMessageLoop(), Uninitialize() error", 0);
		return CLStatus(-1, 0);
	}

	return CLStatus(0, 0);
}
Пример #7
0
bool BaseProgramRenderPass::Initialize()
{
	if (mProgramState->Program()!=0)
	{
		Uninitialize();
	}

	uint newProgram=Render::Instance().CreateProgram();
	RETURN_FALSE_IF_ZERO(newProgram);
	mProgramState->SetProgram(newProgram);
	if (mVertexShader!=nullptr)
	{
		Render::Instance().AttachShader(newProgram,mVertexShader->Shader());
	}

	if (mPixelShader!=nullptr)
	{
		Render::Instance().AttachShader(newProgram,mPixelShader->Shader());
	}

	if (!IsLinked())
	{
		Link();
	}

	return true;	
}
CLStatus CLMessageLoopManager::EnterMessageLoop(void *pContext)
{
	SLExecutiveInitialParameter *para = (SLExecutiveInitialParameter *)pContext;
	CLStatus s = Initialize();//队列(管道,网络等对象)等的初始化工作
	if(!s.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), Initialize() error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	CLStatus s1 = m_pMessageOberver->Initialize(this,para->pContext);//初始化CLMessageOberver对象,如注册不同消息的处理方法
	if(!s1.IsSuccess())
	{
		throw "In CLMessageLoopManager::EnterMessageLoop(), m_pMessageOberver->Initialize error.";
		para->pNotifier->NotifyInitialFinished(false);
		return CLStatus(-1,0);
	}
	para->pNotifier->NotifyInitialFinished(true);

	while(true)
	{
		CLMessage *pMsg = WaitForMessage();
		CLStatus s3 = DispatchMessage(pMsg);
		if(s3.m_clReturnCode == QUIT_MESSAGE_LOOP)  //注意此退出返回码要与QUIT_MESSAGE_LOOP保持一致
			break;
		delete pMsg;
	}
	delete m_pMessageOberver; //所有消息处理完毕,删除消息处理方法CLMessageOberver对象
	m_pMessageOberver = 0;  //这里加入了赋值语句,使得m_pMessageOberver = 0,因为在本类的析构中还释放了一次,造成segmentation fault
	CLStatus s4 = Uninitialize();//反初始化队列(管道,网络等对象)等
	return CLStatus(0,0);
}
Пример #9
0
CWelsH264SVCEncoder::~CWelsH264SVCEncoder() {
  if (m_pWelsTrace) {
    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::~CWelsH264SVCEncoder()");

#ifdef REC_FRAME_COUNT
    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
             "CWelsH264SVCEncoder::~CWelsH264SVCEncoder(), m_uiCountFrameNum= %d, m_iCspInternal= 0x%x", m_uiCountFrameNum,
             m_iCspInternal);
#endif
  }

#ifdef REC_FRAME_COUNT
  m_uiCountFrameNum = 0;
#endif//REC_FRAME_COUNT

#ifdef OUTPUT_BIT_STREAM
  if (m_pFileBs) {
    WelsFclose (m_pFileBs);
    m_pFileBs = NULL;
  }
  if (m_pFileBsSize) {
    WelsFclose (m_pFileBsSize);
    m_pFileBsSize = NULL;
  }
  m_bSwitch	= false;
  m_iSwitchTimes	= 0;
#endif//OUTPUT_BIT_STREAM

  Uninitialize();

  if (m_pWelsTrace) {
    delete m_pWelsTrace;
    m_pWelsTrace = NULL;
  }
}
Пример #10
0
CGraphics::~CGraphics(void)
{
	UninitializeRenderer();
	UninitializeDisplay();
	UninitializeTimer();
	Uninitialize();
}
Пример #11
0
int _tmain(int argc, _TCHAR* argv[])
{	
	Initialize();

	const int bufferLen = 1024;
	unsigned char* buffer = (unsigned char*)malloc(bufferLen * sizeof(unsigned char));
	buffer[0] = '\0';
	
	printf("presentation slide index: %d\n", PresentationCurrentSlideIndex());

	PresentationCurrentSlideNote(buffer, bufferLen);
	printf("presentation note: %s\n", buffer);

	PresentationCurrentSlideName(buffer, bufferLen);
	printf("slide name: %s\n", buffer);

	printf("saving presentation slides thumbnails...\n");
	RefreshPresentationSlidesThumbnail();

	/*printf("gonna goto previous slide...\n");
	system("pause");
	PresentationPreviousSlide();

	printf("gonna goto next slide...\n");
	system("pause");
	PresentationNextSlide();*/
	
	Uninitialize();

	printf("Test finished\n");
	system("pause");

	return 0;
}
Пример #12
0
int CWelsH264SVCEncoder::InitializeExt (const SEncParamExt* argv) {
  if (m_pWelsTrace == NULL) {
    return cmMallocMemeError;
  }

  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsH264SVCEncoder::InitEncoder(), openh264 codec version = %s",
           VERSION_NUMBER);

  if (NULL == argv) {
    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitializeExt(), invalid argv= 0x%p",
             argv);
    return cmInitParaError;
  }

  SWelsSvcCodingParam	sConfig;
  // Convert SEncParamExt into WelsSVCParamConfig here..
  if (sConfig.ParamTranscode (*argv)) {
    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR,
             "CWelsH264SVCEncoder::InitializeExt(), parameter_translation failed.");
    TraceParamInfo (&sConfig);
    Uninitialize();
    return cmInitParaError;
  }

  return InitializeInternal (&sConfig);
}
Пример #13
0
CShader::~CShader()
{
    if (IsInitialized())
    {
        Uninitialize();
    }
}
Пример #14
0
	bool DebugDrawer::Initialize()
	{
		if (!s_initialized)
		{
			// s_shader
			s_shader = ShaderLibrary::Get("DebugSimple");
			s_colorLocation = s_shader->GetUniformLocation("Color");

			// s_vertexBuffer
			try
			{
				ErrorFlags flags(ErrorFlag_ThrowException, true);
				s_vertexBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ), 65365, DataStorage_Hardware, BufferUsage_Dynamic);
			}
			catch (const std::exception& e)
			{
				NazaraError("Failed to create buffer: " + String(e.what()));

				Uninitialize();
				return false;
			}

			s_primaryColor = Color::Red;
			s_renderStates.parameters[RendererParameter_DepthBuffer] = true;
			s_secondaryColor = Color::Green;

			s_initialized = true;
		}

		return true;
	}
Пример #15
0
FileStorage::~FileStorage()
{
	//SIREN_BODY_DESTRUCT_BEGIN
//SIREN_BODY_DESTRUCT_END

	Uninitialize();
}
Пример #16
0
HRESULT CGraphics::Initialize(void)
{
	InitializeCriticalSection(&m_UpdateSection);

	m_Direct3DLibrary = LoadLibrary(D3DDLL);
	if(!m_Direct3DLibrary)
	{
		TRACE(TEXT("Error: Failed to load \"%s\".\n"),D3DDLL);
		return E_FAIL;
	}

	m_Direct3DCreate9 = (LPDIRECT3DCREATE9)GetProcAddress(m_Direct3DLibrary,"Direct3DCreate9");
	if(!m_Direct3DCreate9)
	{
		Uninitialize();
		TRACE(TEXT("Error: Failed to find \"Direct3DCreate9\" in \"%s\".\n"),D3DDLL);
		return NULL;
	}

	m_Direct3DSetRegion = (LPDIRECT3DSETREGION)GetProcAddress(m_Direct3DLibrary,"D3DPERF_SetRegion");
	if(!m_Direct3DSetRegion)
	{
		Uninitialize();
		TRACE(TEXT("Error: Failed to find \"D3DPERF_SetRegion\" in \"%s\".\n"),D3DDLL);
		return NULL;
	}

	m_Direct3DBeginEvent = (LPDIRECT3DBEGINEVENT)GetProcAddress(m_Direct3DLibrary,"D3DPERF_BeginEvent");
	if(!m_Direct3DBeginEvent)
	{
		Uninitialize();
		TRACE(TEXT("Error: Failed to find \"D3DPERF_BeginEvent\" in \"%s\".\n"),D3DDLL);
		return NULL;
	}

	m_Direct3DEndEvent = (LPDIRECT3DENDEVENT)GetProcAddress(m_Direct3DLibrary,"D3DPERF_EndEvent");
	if(!m_Direct3DEndEvent)
	{
		Uninitialize();
		TRACE(TEXT("Error: Failed to find \"D3DPERF_EndEvent\" in \"%s\".\n"),D3DDLL);
		return NULL;
	}

	return S_OK;
}
CDriverSimBroadcast::~CDriverSimBroadcast()
{
    Uninitialize();

    SAFE_FREELIBRARY(_hXdeModule);

    _pfnXdeInitialize = nullptr;
    _pfnXdeGetInternalMacAddress = nullptr;
}
CMouseInterface::CMouseInterface() :
    m_pSlotRom(NULL)
{
    m_6821.SetListenerB( this, M6821_Listener_B );
    m_6821.SetListenerA( this, M6821_Listener_A );

    Uninitialize();
    Reset();
}
Пример #19
0
int Shoebill::Restart()
{
    JNIEnv *env;
    jvm->AttachCurrentThread((void **) &env, NULL);
    if (!env) return 0;
    Uninitialize(env);
    Initialize(env);
    return 1;
}
Пример #20
0
bool MaterialRenderGroup::Uninitialize()
{
	FOR_EACH_ITEM_TO(mGroups, Uninitialize());

	FOR_EACH_ITEM_CLEAR(mGroups, StateRenderGroupPool::Instance().Recycle);
	SAFE_RELEASE(mMaterial);

	return true;
}
Пример #21
0
GHOST_DropTargetX11::~GHOST_DropTargetX11()
{
    m_refCounter--;
    if (m_refCounter == 0) {
        Uninitialize();
        m_xdndInitialized = false;
        GHOST_PRINT("XDND uninitialized\n");
    }
}
Пример #22
0
/*
** Destructor.
**
*/
PlayerITunes::~PlayerITunes()
{
	c_Player = nullptr;

	DestroyWindow(m_CallbackWindow);
	UnregisterClass(L"NowPlayingITunesClass", g_Instance);

	Uninitialize();
}
Пример #23
0
void USART_Driver::CloseAllPorts()
{
    for( int port = 0; port < TOTAL_USART_PORT; port++)
    {
        if ( USART_FLAG_STATE(Hal_Usart_State[port], HAL_USART_STATE::c_INITIALIZED))
        {
            Uninitialize(port);
        }
    }
}
Пример #24
0
SessionImpl::~SessionImpl ()
{
  try
    {
      Uninitialize ();
    }
  catch (const exception &)
    {
    }
}
CMouseInterface::CMouseInterface() :
	m_pSlotRom(NULL)
{
	m_6821.SetListenerB( this, M6821_Listener_B );
	m_6821.SetListenerA( this, M6821_Listener_A );
//	g_cDIMouse.SetMouseListener( this, MouseHandler );

	Uninitialize();
	Reset();
}
Пример #26
0
CFlexMeters::~CFlexMeters()
{
	Uninitialize();
    if (memDC) {
        DeleteDC(memDC);
    }
    if (memBM) {
        DeleteObject(memBM);
    }
}
Пример #27
0
//=============================================================================
int PLATFORM_MAIN ()
{
    DebugBreakOnAllocation(71);

    Initialize();

    CApplication app;
    app.Go();

    Uninitialize();

    return 0;
}
CSocketThreadManager::~CSocketThreadManager()
{
	try
	{
		//Are we initialized
		if (m_bInitialized)
			Uninitialize();

		//Delete the CS
		delete m_pCSection;
	}
	ERROR_HANDLER("~CSocketThreadManager")
}
Пример #29
0
bool ScriptModule::Initialize()
{
	Uninitialize();
	mScriptBuilder = new CScriptBuilder();
	mScriptBuilder->SetIncludeCallback(OnInclude, nullptr);

	mScriptBuilder->StartNewModule(ScriptEngine::Instance().GetScriptEngine(), mName.c_str());
	mScriptModule = mScriptBuilder->GetModule();



	return true;
}
CStatus CMessageLoopManager::EnterMessageLoop(void * pContext)
{
	
	//允许传递给线程的参数是NULL型,表示不传递参数,所以不做检查

	//1、进入消息循环前,允许消息循环做一些初始化的工作
 	CStatus s1 = Initialize();
	if(!s1.IsSuccess())
		return s1;

	//在进入消息循环前,调用观察者的初始化函数
	CStatus s_initOfMsgObserver = m_pMsgObserver->Initialize(this,pContext);
	if(!s_initOfMsgObserver.IsSuccess())
		return s_initOfMsgObserver;

	//3、消息队列的拥有线程owner开始进入一个死循环(即消息循环机制)
	//owner 阻塞的一直从消息队列中读取other线程发给它的消息
	//然后根据自己手中的消息分发表,将消息派送给不同的消息处理类去
	//处理消息。
	//当任何其他线程向他发送一个退出消息后,owner结束处理消息的工作j
	while(true)
	{
		int failed_counter = 0;
		CMessage * pMsg = WaitForMessage();
		if(0 == pMsg)
		{
			//如果等待消息失败超过5次,就认为消息队列出问题
			//推出消息循环
			if(failed_counter++ < WaitForMessageFailedTimes)	
					continue;
			else
				return CStatus(-1,0,"in EnterMessageLoop of CMessageLoopManager : wait for message faild");
		}
		
		CStatus s2 = DispatchMessage(pMsg);
		if(!s2.IsSuccess())
			return s2;
		
		if(s2.m_ciReturnCode == QUIT_MESSAGE_LOOP)
			break;
	}	
	
	//5、允许消息队列做一些收尾工作
	CStatus s3 = Uninitialize();
	if(!s3.IsSuccess())
		return s3;

	return CStatus(0,0);
}