Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************************************
- Cry Video Source File.
- Copyright (C), Marwin Misselhorn 2012
- -------------------------------------------------------------------------
- *************************************************************************/
- #include "StdAfx.h"
- #include "CryVideo.h"
- #include "Nodes/G2FlowBaseNode.h"
- #include <ICryVideo.h>
- #include <IVideoManager.h>
- #include <CryLibrary.h>
- #include <IGameFramework.h>
- #include <IRenderer.h>
- #include <UIDraw/UIDraw.h>
- #include <IEditorGame.h> //0.9.8: Native Audio Support
- CCryVideo *g_pCryVideo = 0;
- // Needed for the Game02 specific flow node
- CG2AutoRegFlowNodeBase *CG2AutoRegFlowNodeBase::m_pFirst=0;
- CG2AutoRegFlowNodeBase *CG2AutoRegFlowNodeBase::m_pLast=0;
- //New CVars
- static int cv_useLevelAsMenuBg;
- static ICVar* cv_levelMenuBgMapName;
- static int cv_useVideoAsMenuBg;
- static ICVar* cv_videoMenuBgVideoName;
- static ICVar* cv_startingLevel;
- static int cv_renderToSecondWindow;
- static int cv_forceManualConversion;
- static int cv_swapBGRA;
- //static int cv_useOpenGL;
- static HMODULE m_hCryVideoOpenCVHandle = 0;
- typedef ICryVideoOpenCV *(*PFNCREATECRYVIDEOOPENCV)();
- static HMODULE m_hCryVideoWebMHandle = 0;
- typedef ICryVideoWebM *(*PFNCREATECRYVIDEOWEBM)();
- //0.9.8: Message Box
- void Error( const char* sErrorText )
- {
- MessageBox( 0,sErrorText, "...", MB_OK | MB_DEFAULT_DESKTOP_ONLY);
- }
- //0.9.8: Native Audio Support
- HANDLE CCryVideo::ExecuteProcess(string applicationName, string commandLine, string workingDir)
- {
- STARTUPINFO sStartInfo;
- ZeroMemory( &sStartInfo, sizeof(STARTUPINFO) );
- sStartInfo.cb = sizeof(STARTUPINFO);
- sStartInfo.dwFlags = STARTF_USESHOWWINDOW;
- //sStartInfo.wShowWindow = SW_SHOWDEFAULT;
- sStartInfo.wShowWindow = SW_HIDE;
- PROCESS_INFORMATION sProcessInfo;
- ZeroMemory( &sProcessInfo, sizeof(PROCESS_INFORMATION) );
- BOOL ok = CreateProcess( applicationName.c_str(), (LPSTR)commandLine.c_str(),
- NULL, NULL, true,
- NORMAL_PRIORITY_CLASS, NULL, workingDir.c_str(), &sStartInfo, &sProcessInfo );
- if ( ok == 0 )
- {
- sProcessInfo.hProcess = 0;
- DWORD error = GetLastError();
- CryLogAlways("CryVideo: Create Process Error Code: %i", error);
- }
- return sProcessInfo.hProcess;
- }
- CCryVideo::CCryVideo()
- : m_pTimerManager(0) //Cry Video MOD: Timer Manager
- {
- g_pCryVideo = this;
- started = false;
- soundUpdate = false;
- isRGB8Usable = false;
- m_bMenuRendered = false;
- //0.9.8: Native Audio Support
- //check if CryEngine runs in 32 or 64 Bit Mode
- #if defined(WIN64) //WIN 64
- m_bIs64Bit = true;
- #else //WIN 32
- m_bIs64Bit = false;
- #endif
- }
- CCryVideo::~CCryVideo()
- {
- g_pCryVideo = 0;
- started = false;
- soundUpdate = false;
- m_bMenuRendered = false;
- //Clean lists
- if(!m_globalVideoList.empty())
- m_globalVideoList.clear();
- if(!m_priorityAudioJobList.empty())
- m_priorityAudioJobList.clear();
- if(!m_globalAudioJobList.empty())
- m_globalAudioJobList.clear();
- //0.9.8: Native Audio Support
- if (gEnv->pRenderer)
- gEnv->pRenderer->UnRegisterCaptureFrame(this);
- //Clean TempAudio folder
- string audio = "Videos\\Library\\TempAudio\\";
- _finddata_t fileDataAudio;
- char szAudioPath[260];
- strncpy_s(szAudioPath, 260, audio.c_str(), 260);
- strncat_s(szAudioPath, 260, "*.mp2", 260);
- intptr_t hFileAudio = gEnv->pCryPak->FindFirst(szAudioPath, &fileDataAudio);
- if (hFileAudio > -1)
- {
- do
- {
- string audioPath = (audio+fileDataAudio.name);
- gEnv->pCryPak->RemoveFile(audioPath);
- } while (gEnv->pCryPak->FindNext(hFileAudio, &fileDataAudio) > -1);
- gEnv->pCryPak->FindClose(hFileAudio);
- }
- //Cry Video MOD: Timer Manager
- SAFE_DELETE(m_pTimerManager);
- //Free WebM DLL
- if (m_hCryVideoWebMHandle)
- CryFreeLibrary(m_hCryVideoWebMHandle);
- m_hCryVideoWebMHandle = 0;
- //Free OpenCV DLL
- if (m_hCryVideoOpenCVHandle)
- CryFreeLibrary(m_hCryVideoOpenCVHandle);
- m_hCryVideoOpenCVHandle = 0;
- //Unregister CVars
- gEnv->pConsole->UnregisterVariable("cv_useLevelAsMenuBg", true);
- gEnv->pConsole->UnregisterVariable("cv_levelMenuBgMapName", true);
- gEnv->pConsole->UnregisterVariable("cv_useVideoAsMenuBg", true);
- gEnv->pConsole->UnregisterVariable("cv_videoMenuBgVideoName", true);
- gEnv->pConsole->UnregisterVariable("cv_startingLevel", true);
- gEnv->pConsole->UnregisterVariable("cv_renderToSecondWindow", true);
- gEnv->pConsole->UnregisterVariable("cv_forceManualConversion", true);
- gEnv->pConsole->UnregisterVariable("cv_swapBGRA", true);
- //gEnv->pConsole->UnregisterVariable("cv_useOpenGL", true);
- }
- bool CCryVideo::Init(ISystem *pSystem, IGameFramework *pGameFramework, IGameToEditorInterface *pGameToEditorInterface) //0.9.8: Native Audio Support
- {
- //0.9.8: Dlls moved to CryVideo directory
- if (m_bIs64Bit)
- SetDllDirectory("Bin64\\CryVideo");
- else
- SetDllDirectory("Bin32\\CryVideo");
- started = false;
- m_bMenuRendered = false;
- gEnv = pSystem->GetGlobalEnvironment();
- m_pFramework = pGameFramework;
- //0.9.8: Native Audio Support
- gEnv->pRenderer->RegisterCaptureFrame(this);
- pGameToEditorIface = pGameToEditorInterface;
- //Cry Video MOD: Timer Manager
- if(!m_pTimerManager)
- m_pTimerManager = new CTimerManager();
- // Initialize Game02 flow nodes
- if (IFlowSystem *pFlow = m_pFramework->GetIFlowSystem())
- {
- CG2AutoRegFlowNodeBase *pFactory = CG2AutoRegFlowNodeBase::m_pFirst;
- while (pFactory)
- {
- pFlow->RegisterType( pFactory->m_sClassName,pFactory );
- pFactory = pFactory->m_pNext;
- }
- }
- //Init OpenCV plugin
- if (m_hCryVideoOpenCVHandle)
- CryFreeLibrary(m_hCryVideoOpenCVHandle);
- m_hCryVideoOpenCVHandle = 0;
- m_hCryVideoOpenCVHandle = CryLoadLibrary( "CryVideo\\CryVideoOpenCV.dll" );
- if (!m_hCryVideoOpenCVHandle)
- {
- GameWarning( "CryVideoOpenCV.DLL Loading Failed" );
- }
- //Init WebM plugin
- if (m_hCryVideoWebMHandle)
- CryFreeLibrary(m_hCryVideoWebMHandle);
- m_hCryVideoWebMHandle = 0;
- m_hCryVideoWebMHandle = CryLoadLibrary( "CryVideo\\CryVideoWebM.dll" );
- if (!m_hCryVideoWebMHandle)
- {
- GameWarning( "CryVideoWebM.dll Loading Failed" );
- }
- //Test if RGB8 is available
- int testTextureId = m_pFramework->GetIUIDraw()->CreateTexture("Textures\\defaults\\black.tif", false);
- ITexture *pTestTexture = gEnv->pRenderer->EF_GetTextureByID(testTextureId);
- unsigned char* textureData = pTestTexture->GetData32(0,0,(uint8*)0, eTF_A8R8G8B8);
- int finalTestTextureId = gEnv->pRenderer->DownLoadToVideoMemory(textureData, pTestTexture->GetWidth(), pTestTexture->GetHeight(), eTF_A8R8G8B8, eTF_R8G8B8, 0x1, false);
- ITexture *pFinalTestTexture = gEnv->pRenderer->EF_GetTextureByID(finalTestTextureId);
- if (pFinalTestTexture->IsTextureLoaded())
- isRGB8Usable = true;
- else
- isRGB8Usable = false;
- m_pFramework->GetIUIDraw()->DeleteTexture(testTextureId);
- m_pFramework->GetIUIDraw()->DeleteTexture(finalTestTextureId);
- if (isRGB8Usable)
- CryLogAlways("CryVideo: RGB8 is available!");
- else
- CryLogAlways("CryVideo: RGB8 is NOT available!");
- //Check for right color order
- int features = gEnv->pRenderer->GetFeatures();
- if (features & RFT_RGBA)
- CryLogAlways("CryVideo: Special --> RGBA color channel order!!!");
- else
- CryLogAlways("CryVideo: Default --> BGRA color channel order!");
- //Overide Window Name
- //ICVar *gameName = gEnv->pConsole->GetCVar("cvGameName");
- //if (gameName)
- //gameName->ForceSet("CryENGINE 3 CryVideo System © Marwin Misselhorn");
- //ICVar *verboseWindow = gEnv->pConsole->GetCVar("cvDoVerboseWindowTitle");
- //if (verboseWindow)
- //verboseWindow->ForceSet("1");
- //Register CVars
- gEnv->pConsole->Register("cv_useLevelAsMenuBg", &cv_useLevelAsMenuBg, 0, VF_NULL, "use level as menu background");
- cv_levelMenuBgMapName = gEnv->pConsole->RegisterString("cv_levelMenuBgMapName", "", VF_NULL, "level menu map name");
- gEnv->pConsole->Register("cv_useVideoAsMenuBg", &cv_useVideoAsMenuBg, 0, VF_NULL, "use video as menu background");
- cv_videoMenuBgVideoName = gEnv->pConsole->RegisterString("cv_videoMenuBgVideoName", "", VF_NULL, "video menu video name");
- cv_startingLevel = gEnv->pConsole->RegisterString("cv_startingLevel", "", VF_CHEAT|VF_DUMPTODISK|VF_READONLY, "default starting level when running the launcher");
- gEnv->pConsole->Register("cv_renderToSecondWindow", &cv_renderToSecondWindow, 0, VF_NULL, "render all videos to a separate window for debugging");
- gEnv->pConsole->Register("cv_forceManualConversion", &cv_forceManualConversion, 0, VF_NULL, "force manual color conversion for debugging");
- gEnv->pConsole->Register("cv_swapBGRA", &cv_swapBGRA, -1, VF_CHEAT|VF_DUMPTODISK|VF_READONLY, "-1=Autodetect(Default); 0=BGRA; 1=RGBA");
- //gEnv->pConsole->Register("cv_useOpenGL", &cv_useOpenGL, 0, VF_NULL, "use OpenGL for color conversion");
- //Cry Video MOD: Load Config
- gEnv->pConsole->ExecuteString( "exec CryVideo.cfg" );
- //Swap BRGA Auto-Detect
- ICVar* swapChannels = gEnv->pConsole->GetCVar("cv_swapBGRA");
- if (swapChannels)
- {
- if (swapChannels->GetIVal() == -1)
- {
- if (gEnv->pRenderer->GetRenderType()== eRT_DX11)
- swapChannels->ForceSet("1");
- else
- swapChannels->ForceSet("0");
- }
- }
- /*
- //Test
- HANDLE hNote;
- bool exit = false;
- hNote = ExecuteProcess( "Bin32\\CryVideo\\ffmpeg.exe", "ffmpeg -i Elephants_Dream.WebM -vn TempAudio\\output.mp2", "Game\\Videos\\Library");
- if ( hNote )
- {
- while (!exit)
- {
- DWORD noteExitCode;
- if ( GetExitCodeProcess(hNote , ¬eExitCode) )
- {
- if ( noteExitCode == STILL_ACTIVE )
- {
- // immer noch an
- }
- else
- {
- // Programm beendet
- CloseHandle( hNote );
- exit = true;
- }
- }
- }
- }
- */
- //0.9.8: Detect number of Cores for Audio Job
- SYSTEM_INFO sysinfo;
- GetSystemInfo( &sysinfo );
- maxSoundJobs = sysinfo.dwNumberOfProcessors;
- CryLogAlways("CryVideo: Use %i thread(s) for audio conversion!", maxSoundJobs);
- //0.9.8: Create Global Video List on startup
- CreateGlobalVideoList();
- CryLogAlways("Hello20");
- //Start Timer
- m_LastSoundUpdate = gEnv->pTimer->GetAsyncCurTime();
- started = true;
- return true;
- }
- IVideoManager* CCryVideo::CreateVideoPlayerInstance()
- {
- CVideoManager* m_pVideoManager;
- m_pVideoManager = new CVideoManager();
- return m_pVideoManager;
- }
- ICryVideoOpenCV* CCryVideo::CreateOpenCVInstance()
- {
- ICryVideoOpenCV* m_pCryVideoOpenCV;
- PFNCREATECRYVIDEOOPENCV pfnCreateCryVideoOpenCV = (PFNCREATECRYVIDEOOPENCV)::GetProcAddress( m_hCryVideoOpenCVHandle, "CreateCryVideoOpenCV" );
- m_pCryVideoOpenCV = pfnCreateCryVideoOpenCV();
- if (!m_pCryVideoOpenCV)
- {
- GameWarning("CreateOpenCVInterface Failed" );
- }
- bool success = m_pCryVideoOpenCV->Init(gEnv->pSystem, m_pFramework, this);
- if (!success)
- GameWarning("Init OpenCV Failed" );
- return m_pCryVideoOpenCV;
- }
- ICryVideoWebM* CCryVideo::CreateWebMInstance()
- {
- ICryVideoWebM* m_pCryVideoWebM;
- PFNCREATECRYVIDEOWEBM pfnCreateCryVideoWebM = (PFNCREATECRYVIDEOWEBM)::GetProcAddress( m_hCryVideoWebMHandle, "CreateCryVideoWebM" );
- m_pCryVideoWebM = pfnCreateCryVideoWebM();
- if (!m_pCryVideoWebM)
- {
- GameWarning("CreateWebMInterface Failed" );
- }
- bool success = m_pCryVideoWebM->Init(gEnv->pSystem, m_pFramework);
- if (!success)
- GameWarning("Init WebM Failed" );
- return m_pCryVideoWebM;
- }
- //////////////////////////////////////////////////////////////////////////
- void CCryVideo::CreateGlobalVideoList()
- {
- if (soundUpdate || m_pFramework->GetISystem()->IsQuitting())
- return;
- if (!started) //First Start Only
- {
- //Clean list
- m_globalVideoList.clear();
- //Create TempAudio folder
- gEnv->pCryPak->MakeDir("Videos\\Library\\TempAudio", true);
- //Clean TempAudio folder
- string audio = "Videos\\Library\\TempAudio\\";
- _finddata_t fileDataAudio;
- char szAudioPath[260];
- strncpy_s(szAudioPath, 260, audio.c_str(), 260);
- strncat_s(szAudioPath, 260, "*.mp2", 260);
- intptr_t hFileAudio = gEnv->pCryPak->FindFirst(szAudioPath, &fileDataAudio);
- if (hFileAudio > -1)
- {
- do
- {
- string audioPath = (audio+fileDataAudio.name);
- gEnv->pCryPak->RemoveFile(audioPath);
- } while (gEnv->pCryPak->FindNext(hFileAudio, &fileDataAudio) > -1);
- gEnv->pCryPak->FindClose(hFileAudio);
- }
- }
- CryLogAlways("Hello1");
- //Create temp OpenCV instance
- ICryVideoOpenCV* m_pCryVideoOpenCV = CreateOpenCVInstance();
- //Clean lists
- m_priorityAudioJobList.clear();
- m_globalAudioJobList.clear();
- //Detect right game folder
- const char* gameFolder;
- ICVar *pVar = gEnv->pConsole->GetCVar("sys_game_folder");
- if (pVar)
- gameFolder = pVar->GetString();
- else
- gameFolder = "Game";
- //Search for all Videos in Library and apply default settings
- string videos = "Videos\\Library\\";
- _finddata_t fileData;
- char szVideoPath[260];
- strncpy_s(szVideoPath, 260, videos.c_str(), 260);
- strncat_s(szVideoPath, 260, "*", 260);
- intptr_t hFile = gEnv->pCryPak->FindFirst(szVideoPath, &fileData);
- if (hFile > -1)
- {
- do
- {
- if (fileData.size <= 0)
- continue;
- string videoPath = (videos+fileData.name);
- string videoName = fileData.name;
- CryLogAlways("Hello2.4");
- //ToDo: Check if videoName is already in list. If yes, did checksum changed? If yes or when video is not in list update VideoList
- std::vector<SVideoInfo>::const_iterator iter (m_globalVideoList.begin());
- while (iter != m_globalVideoList.end())
- {
- if (iter->videoName == fileData.name)
- {
- //Compare MD5 Checksum
- char* file1 = new char[255];
- char* file2 = new char[255];
- unsigned char* checkSumFile1 = new unsigned char[16];
- unsigned char* checkSumFile2 = new unsigned char[16];
- sprintf(file1, "%s%s", videos, iter->videoName);
- sprintf(file2, "%s%s", videos, fileData.name);
- gEnv->pCryPak->ComputeMD5(file1,checkSumFile1);
- gEnv->pCryPak->ComputeMD5(file2,checkSumFile2);
- if (checkSumFile1 == checkSumFile2) //Skip identical files
- continue;
- }
- ++iter;
- }
- //Init Video File
- char fileName[255];
- sprintf(fileName, "%s/Videos/Library/%s", gameFolder, videoName.MakeLower());
- string fileNameString;
- fileNameString = fileName;
- int videoFormat; //AVI=1 ; WebM=2
- bool success = false;
- CryLogAlways("Hello2.5");
- if (fileNameString.substr(fileNameString.size()-5,5) == ".webm")
- {
- videoFormat = 2;
- CryLogAlways("Hello2.6");
- success = m_pCryVideoOpenCV->LoadVideoFile(fileName, videoFormat);
- if (!success)
- {
- GameWarning("CryVideo: WebM file '%s' couldn't be opened. Retrying!", fileData.name);
- success = m_pCryVideoOpenCV->LoadVideoFile(fileName, videoFormat);
- }
- }
- else
- {
- videoFormat = 1;
- CryLogAlways("Hello2.7");
- success = m_pCryVideoOpenCV->LoadVideoFile(fileName, videoFormat);
- CryLogAlways("Hello2.8");
- if (!success)
- {
- //One retry
- success = m_pCryVideoOpenCV->LoadVideoFile(fileName, videoFormat);
- CryLogAlways("Hello2.9");
- }
- }
- if (success)
- {
- CryLogAlways("Hello2.10");
- SVideoInfo videoInfo;
- //Set Default Settings
- videoInfo.videoName = fileData.name;
- videoInfo.videoWidth = 800.0f;
- videoInfo.videoHeight = 600.0f;
- videoInfo.posX = 0.0f;
- videoInfo.posY = 0.0f;
- videoInfo.soundFile = "Default";
- videoInfo.allowSkip = 1;
- m_globalVideoList.push_back(videoInfo);
- CryLogAlways("Hello2.11");
- }
- } while (gEnv->pCryPak->FindNext(hFile, &fileData) > -1);
- gEnv->pCryPak->FindClose(hFile);
- }
- //Search for xml files and overwrite default settings with it
- string xml = "Videos\\Library\\";
- _finddata_t fileDataXml;
- char szXmlPath[260];
- strncpy_s(szXmlPath, 260, xml.c_str(), 260);
- strncat_s(szXmlPath, 260, "*.xml", 260);
- intptr_t hFileXml = gEnv->pCryPak->FindFirst(szXmlPath, &fileDataXml);
- if (hFileXml > -1)
- {
- do
- {
- string xmlPath = (xml+fileDataXml.name);
- XmlNodeRef videoInfo = gEnv->pSystem->LoadXmlFromFile(xmlPath);
- if(videoInfo == 0)
- {
- GameWarning("Cry Video: Could not load video xml: %s", xmlPath);
- }
- else
- {
- if(videoInfo)
- {
- const char* name = videoInfo->getTag();
- if(!stricmp(name, "VideoSettings"))
- {
- SVideoInfo info;
- int attribs = videoInfo->getNumAttributes();
- const char* key;
- const char* value;
- for(int i = 0; i < attribs; ++i)
- {
- videoInfo->getAttributeByIndex(i, &key, &value);
- if(!stricmp(key,"Name"))
- {
- info.videoName = value;
- }
- else if(!stricmp(key,"Width") && value)
- {
- info.videoWidth = (float)atof(value);
- }
- else if(!stricmp(key,"Height") && value)
- {
- info.videoHeight = (float)atof(value);
- }
- else if(!stricmp(key,"PosX") && value)
- {
- info.posX = (float)atof(value);
- }
- else if(!stricmp(key,"PosY") && value)
- {
- info.posY = (float)atof(value);
- }
- else if(!stricmp(key,"SoundFile"))
- {
- info.soundFile = value;
- }
- else if(!stricmp(key,"AllowSkip") && value)
- {
- info.allowSkip = atoi(value);
- }
- }
- //Search for video file and replace settings
- if (!m_globalVideoList.empty())
- {
- for(int i=0; i<m_globalVideoList.size(); i++)
- {
- SVideoInfo currInfo = m_globalVideoList[i];
- if (currInfo.videoName.MakeLower() == info.videoName.MakeLower())
- {
- m_globalVideoList[i] = info;
- break;
- }
- }
- }
- }
- }
- }
- } while (gEnv->pCryPak->FindNext(hFileXml, &fileDataXml) > -1);
- gEnv->pCryPak->FindClose(hFileXml);
- }
- CryLogAlways("Hello3");
- //Send Video List to UIEnum, so they show up in Editor
- if (pGameToEditorIface) //Only in Editor
- {
- CryLogAlways("Hello4");
- int numAllVideos = 0;
- const char** allVideos = new const char*[m_globalVideoList.size()];
- CryLogAlways("Hello5");
- std::vector<SVideoInfo>::const_iterator iter (m_globalVideoList.begin());
- CryLogAlways("Hello6");
- while (iter != m_globalVideoList.end())
- {
- allVideos[numAllVideos++] = iter->videoName;
- ++iter;
- }
- CryLogAlways("Hello7");
- pGameToEditorIface->SetUIEnums("video", allVideos, numAllVideos);
- CryLogAlways("Hello8");
- delete[] allVideos;
- }
- CryLogAlways("Hello9");
- //ToDo: Create Sound Job Lists and Priority Lists (introvideolist.xml & cv_videoMenuBgVideoName - Only in Launcher!!)
- //ToDo: If Firststart=true ---> When Editor or PriorityList = Empty then durchstarten. When Launcher and PriorityList not empty, then warten bis List empty wird, dann durchstarten
- if (!m_priorityAudioJobList.empty() || !m_globalAudioJobList.empty())
- soundUpdate = true;
- CryLogAlways("Hello10");
- //Free temp OpenCV instance
- SAFE_DELETE(m_pCryVideoOpenCV);
- CryLogAlways("Hello11");
- //Start first sound job
- DoSoundJob();
- }
- void CCryVideo::DoSoundJob() //0.9.8: Check for Sound Job
- {
- if (!soundUpdate)
- return;
- //ToDo: Jeweils getrennt für Priority und Normal Jobs anlegen
- //int currentSoundJobs;
- //int finishedSoundJobs;
- //1 ---> Priority Jobs:
- //1. List empty? If no...continue, if yes...go to Normal Jobs
- //2. Check priority job status. If started = true && finished = false then check exit code. if exit code = exited then finished true && started = false && CloseHandle
- //3. Check finished priority jobs. If jobFinishedCount = PriorityListSize then clear list (Signal zum Durchstarten)
- //4. Count running priority jobs. maxSoundJobs - RunningJobCount = Number of free threads that can be used
- //5. if freeThreads > 0 then find entrys where started = false and launch them (in einer for Schleife: i=1 ; i <= freeThreads; i++)
- //2 ---> Normal Jobs:
- //1. List empty? If no...continue, if yes...then soundUpdate = false
- //2. Check job status. If started = true && finished = false then check exit code. if exit code = exited then finished true && started = false && CloseHandle
- //3. Check finished jobs. If jobFinishedCount = ListSize then soundUpdate = false
- //4. Count running jobs. maxSoundJobs - RunningJobCount = Number of free threads that can be used
- //5. if freeThreads > 0 then find entrys where started = false and launch them (in einer for Schleife: i=1 ; i <= freeThreads; i++)
- }
- void CCryVideo::Update()
- {
- if (m_pFramework->IsGamePaused() == false)
- {
- //Cry Video MOD: Update Video Timer System
- if(m_pTimerManager)
- {
- m_pTimerManager->Update();
- }
- }
- }
- //0.9.8: Native Audio Support
- int CCryVideo::OnCaptureFrameBegin(void)
- {
- CryLogAlways("UPDATE: New Frame!");
- //Check for updates
- if (started)
- {
- if(m_LastSoundUpdate + 1.0f <= gEnv->pTimer->GetAsyncCurTime())
- {
- if (soundUpdate) //Check for sound update
- DoSoundJob();
- if (gEnv->IsEditor() && !soundUpdate) //Check for video list update (only in Editor)
- CreateGlobalVideoList();
- m_LastSoundUpdate = gEnv->pTimer->GetAsyncCurTime();
- }
- }
- return 0;
- }
- void CCryVideo::Shutdown()
- {
- this->~CCryVideo();
- }
- void CCryVideo::GetMemoryStatistics(ICrySizer * s) const
- {
- s->Add(*this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement