just for you tomreyn (fade sound on application exit)

This commit is contained in:
Mark Vejvoda 2011-10-21 22:07:34 +00:00
parent c305af8063
commit b10c489418
3 changed files with 74 additions and 4 deletions

View File

@ -2400,6 +2400,10 @@ int glestMain(int argc, char** argv) {
ExceptionHandler exceptionHandler;
exceptionHandler.install( getCrashDumpFileName() );
const int shutdownFadeSoundMilliseconds = 3500;
Chrono chronoshutdownFadeSound;
SimpleTaskThread *soundThreadManager = NULL;
try {
// Setup paths to game items (like data, logs, ini etc)
int setupResult = setupGameItemPaths(argc, argv, NULL);
@ -3430,6 +3434,15 @@ int glestMain(int argc, char** argv) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] starting normal application shutdown\n",__FILE__,__FUNCTION__,__LINE__);
if(isMasterServerModeEnabled == false) {
soundThreadManager = program->getSoundThreadManager(true);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
cleanupCRCThread();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -3437,16 +3450,52 @@ int glestMain(int argc, char** argv) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
catch(const exception &e){
catch(const exception &e) {
if(isMasterServerModeEnabled == false) {
soundThreadManager = program->getSoundThreadManager(true);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(e.what());
}
catch(const char *e){
catch(const char *e) {
if(isMasterServerModeEnabled == false) {
soundThreadManager = program->getSoundThreadManager(true);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(e);
}
catch(const string &ex){
catch(const string &ex) {
if(isMasterServerModeEnabled == false) {
soundThreadManager = program->getSoundThreadManager(true);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError(ex.c_str());
}
catch(...){
catch(...) {
if(isMasterServerModeEnabled == false) {
soundThreadManager = program->getSoundThreadManager(true);
if(soundThreadManager) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
}
ExceptionHandler::handleRuntimeError("Unknown error!");
}
@ -3470,6 +3519,17 @@ int glestMain(int argc, char** argv) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(soundThreadManager) {
//printf("chronoshutdownFadeSound.getMillis() = %llu\n",chronoshutdownFadeSound.getMillis());
for(;chronoshutdownFadeSound.getMillis() <= shutdownFadeSoundMilliseconds;) {
sleep(10);
}
BaseThread::shutdownAndWait(soundThreadManager);
delete soundThreadManager;
soundThreadManager = NULL;
}
return 0;
}

View File

@ -712,4 +712,12 @@ void Program::consoleAddLine(string line) {
}
}
SimpleTaskThread * Program::getSoundThreadManager(bool takeOwnership) {
SimpleTaskThread *result = soundThreadManager;
if(takeOwnership) {
soundThreadManager = NULL;
}
return result;
}
}}//end namespace

View File

@ -201,6 +201,8 @@ public:
virtual void consoleAddLine(string line);
virtual SimpleTaskThread * getSoundThreadManager(bool takeOwnership);
private:
void setDisplaySettings();