From c0c0605a3de2812a27a2071e1bbf7c1d7c4433a0 Mon Sep 17 00:00:00 2001 From: torcs-ng Date: Tue, 31 Jul 2012 10:30:00 +0000 Subject: [PATCH] fix bug with new module sound by Gaetan git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4820 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 8349fad9e34dac41ae7f15dc71913e0d1d9cca2b Former-commit-id: 981664cc625fb8e2e086f6a0d789145eb877a0bc --- src/interfaces/isoundengine.h | 2 +- src/modules/sound/snddefault/grsound.cpp | 2 +- src/modules/sound/snddefault/grsound.h | 2 +- src/modules/sound/snddefault/snddefault.cpp | 4 ++-- src/modules/sound/snddefault/snddefault.h | 4 ++-- .../userinterface/legacymenu/legacymenu.cpp | 16 +++++++++++++++- .../userinterface/legacymenu/legacymenu.h | 1 + 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/interfaces/isoundengine.h b/src/interfaces/isoundengine.h index ea4bcd82c..dca96c0b5 100755 --- a/src/interfaces/isoundengine.h +++ b/src/interfaces/isoundengine.h @@ -36,7 +36,7 @@ public: //virtual void mute(bool bOn = true) = 0; virtual void initSound(struct Situation* s) = 0; - virtual void shutdownSound(struct Situation* s) = 0; + virtual void shutdownSound() = 0; virtual void refreshSound(struct Situation *s, SoundCam *camera) = 0; virtual void mute(bool bOn = true) = 0; }; diff --git a/src/modules/sound/snddefault/grsound.cpp b/src/modules/sound/snddefault/grsound.cpp index ea8af24e8..123cc59fe 100644 --- a/src/modules/sound/snddefault/grsound.cpp +++ b/src/modules/sound/snddefault/grsound.cpp @@ -156,7 +156,7 @@ void grInitSound(tSituation* s, int ncars) void -grShutdownSound(int ncars) +grShutdownSound() { GfLogInfo("Shutting down sound engine\n"); diff --git a/src/modules/sound/snddefault/grsound.h b/src/modules/sound/snddefault/grsound.h index c1fee3e68..1b6b174c2 100644 --- a/src/modules/sound/snddefault/grsound.h +++ b/src/modules/sound/snddefault/grsound.h @@ -26,7 +26,7 @@ class cGrCamera; //Declared in ""grcam.h" extern void grInitSound(tSituation* s, int ncars); -extern void grShutdownSound(int ncars); +extern void grShutdownSound(); extern void grRefreshSound(tSituation *s, SoundCam *camera); extern void grMuteSound(bool bOn = true); diff --git a/src/modules/sound/snddefault/snddefault.cpp b/src/modules/sound/snddefault/snddefault.cpp index f2c219116..12b50fdb6 100644 --- a/src/modules/sound/snddefault/snddefault.cpp +++ b/src/modules/sound/snddefault/snddefault.cpp @@ -72,8 +72,8 @@ sndDefault::~sndDefault() void sndDefault::initSound(Situation* s){ grInitSound(s,s->_ncars); } -void sndDefault::shutdownSound(Situation* s){ - grShutdownSound(s->_ncars); +void sndDefault::shutdownSound(){ + grShutdownSound(); } void sndDefault::refreshSound(Situation *s, SoundCam *camera){ grRefreshSound(s, camera); diff --git a/src/modules/sound/snddefault/snddefault.h b/src/modules/sound/snddefault/snddefault.h index be2288e16..d34f410bf 100644 --- a/src/modules/sound/snddefault/snddefault.h +++ b/src/modules/sound/snddefault/snddefault.h @@ -34,7 +34,7 @@ class ssgLoaderOptions; // DLL exported symbols declarator for Windows. #ifdef WIN32 -# ifdef SNDDEFAULTDLL +# ifdef SNDDEFAULT_DLL # define SNDDEFAULT_API __declspec(dllexport) # else # define SNDDEFAULT_API __declspec(dllimport) @@ -55,7 +55,7 @@ class SNDDEFAULT_API sndDefault : public GfModule, public ISoundEngine public: virtual void initSound(Situation* s); - virtual void shutdownSound(Situation* s); + virtual void shutdownSound(); virtual void refreshSound(Situation *s, SoundCam*camera); virtual void mute(bool bOn = true); diff --git a/src/modules/userinterface/legacymenu/legacymenu.cpp b/src/modules/userinterface/legacymenu/legacymenu.cpp index fb45e5592..102438ab9 100644 --- a/src/modules/userinterface/legacymenu/legacymenu.cpp +++ b/src/modules/userinterface/legacymenu/legacymenu.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -162,6 +163,7 @@ void LegacyMenu::quit() { void LegacyMenu::shutdown() { // Shutdown graphics in case relevant and not already done. if (_piRaceEngine->inData()->_displayMode == RM_DISP_MODE_NORMAL) { + shutDownSound(); unloadCarsGraphics(); shutdownGraphicsView(); unloadTrackGraphics(); @@ -330,8 +332,8 @@ void LegacyMenu::onRaceInterrupted() { void LegacyMenu::onRaceFinishing() { if (_piRaceEngine->inData()->_displayMode == RM_DISP_MODE_NORMAL) { + shutDownSound(); unloadCarsGraphics(); - _piSoundEngine->shutdownSound(_piRaceEngine->outData()->s); shutdownGraphicsView(); unloadTrackGraphics(); RmScreenShutdown(); @@ -531,6 +533,18 @@ void LegacyMenu::redrawGraphicsView(struct Situation* pSituation) { } +void LegacyMenu::shutDownSound() { + std::cout <<"there " << std::endl; + if (!_piSoundEngine) + return; + + if (_bfGraphicsState & eCarsLoaded) { +std::cout <<"there " << std::endl; + _piSoundEngine->shutdownSound(); + } + std::cout <<"there " << std::endl; +} + void LegacyMenu::unloadCarsGraphics() { if (!_piGraphicsEngine) return; diff --git a/src/modules/userinterface/legacymenu/legacymenu.h b/src/modules/userinterface/legacymenu/legacymenu.h index 0800b4adc..55203cfa0 100644 --- a/src/modules/userinterface/legacymenu/legacymenu.h +++ b/src/modules/userinterface/legacymenu/legacymenu.h @@ -142,6 +142,7 @@ public: void shutdownGraphicsView(); void unloadCarsGraphics(); void unloadTrackGraphics(); + void shutDownSound(); //! Load stuff in the background of the splash screen (menus, XML data, ...). static bool backLoad();