[Orxonox-commit 1693] r6411 - code/branches/presentation2/src/orxonox/sound

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Dec 24 16:01:24 CET 2009


Author: rgrieder
Date: 2009-12-24 16:01:23 +0100 (Thu, 24 Dec 2009)
New Revision: 6411

Modified:
   code/branches/presentation2/src/orxonox/sound/BaseSound.cc
   code/branches/presentation2/src/orxonox/sound/SoundManager.cc
Log:
BaseSound should release the buffer upon destruction and the SoundManager should delete all remaining buffers and sources.

Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc	2009-12-24 14:56:22 UTC (rev 6410)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc	2009-12-24 15:01:23 UTC (rev 6411)
@@ -59,6 +59,12 @@
     BaseSound::~BaseSound()
     {
         this->stop();
+        // Release buffer
+        if (this->soundBuffer_ != NULL)
+        {
+            assert(GameMode::playsSound());
+            SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_);
+        }
     }
 
     void BaseSound::XMLPortExtern(Element& xmlelement, XMLPort::Mode mode)

Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-24 14:56:22 UTC (rev 6410)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-24 15:01:23 UTC (rev 6411)
@@ -161,6 +161,26 @@
 
     SoundManager::~SoundManager()
     {
+        // Erase fade lists because of the smart pointers
+        this->fadeInList_.clear();
+        this->fadeOutList_.clear();
+
+        // If there are still used buffers around, well, that's just very bad...
+        if (this->soundBuffers_.size() != this->effectsPool_.size())
+            COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+        // Empty buffer pool and buffer list
+        this->effectsPool_.clear();
+        this->soundBuffers_.clear();
+
+        // There should not be any sources in use anymore
+        if (!this->usedSoundSources_.empty())
+            COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+        while (!this->availableSoundSources_.empty())
+        {
+            alDeleteSources(1, &this->availableSoundSources_.back());
+            this->availableSoundSources_.pop_back();
+        }
+
         GameMode::setPlaysSound(false);
 
         // Relieve context to destroy it




More information about the Orxonox-commit mailing list