[Orxonox-commit 704] r3236 - branches/core4/src/orxonox/sound

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Jun 28 13:42:54 CEST 2009


Author: rgrieder
Date: 2009-06-28 13:42:54 +0200 (Sun, 28 Jun 2009)
New Revision: 3236

Modified:
   branches/core4/src/orxonox/sound/SoundManager.cc
   branches/core4/src/orxonox/sound/SoundManager.h
Log:
Fixed a bug in SoundManager: Construction, destruction and construction again failed due to a static variable that now is a member.

Modified: branches/core4/src/orxonox/sound/SoundManager.cc
===================================================================
--- branches/core4/src/orxonox/sound/SoundManager.cc	2009-06-26 10:55:14 UTC (rev 3235)
+++ branches/core4/src/orxonox/sound/SoundManager.cc	2009-06-28 11:42:54 UTC (rev 3236)
@@ -38,7 +38,6 @@
 namespace orxonox
 {
     SoundManager* SoundManager::singletonRef_s = NULL;
-    ALCdevice* SoundManager::device_s = NULL;
 
     /**
      * Default constructor
@@ -48,6 +47,7 @@
         assert(singletonRef_s == NULL);
         singletonRef_s = this;
 
+        this->device_ = NULL;
         this->soundavailable_ = true;
         if(!alutInitWithoutContext(NULL,NULL))
         {
@@ -56,13 +56,11 @@
         }
         else
         {
-            if(SoundManager::device_s == NULL)
-            {
-                COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
-                SoundManager::device_s = alcOpenDevice(NULL);
-            }
+            assert(this->device_ == NULL);
+            COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
+            this->device_ = alcOpenDevice(NULL);
 
-            if(SoundManager::device_s == NULL)
+            if(this->device_ == NULL)
             {
                 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
                 this->soundavailable_ = false;
@@ -70,7 +68,7 @@
             else
             {
                 COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
-                this->context_ = alcCreateContext(SoundManager::device_s, NULL);
+                this->context_ = alcCreateContext(this->device_, NULL);
                 if(this->context_ == NULL)
                 {
                     COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl;
@@ -98,7 +96,7 @@
         singletonRef_s = NULL;
 
         alcDestroyContext(this->context_);
-        alcCloseDevice(SoundManager::device_s);
+        alcCloseDevice(this->device_);
         alutExit();
     }
 

Modified: branches/core4/src/orxonox/sound/SoundManager.h
===================================================================
--- branches/core4/src/orxonox/sound/SoundManager.h	2009-06-26 10:55:14 UTC (rev 3235)
+++ branches/core4/src/orxonox/sound/SoundManager.h	2009-06-28 11:42:54 UTC (rev 3236)
@@ -54,7 +54,7 @@
         static SoundManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
 
     private:
-        static ALCdevice* device_s;
+        ALCdevice* device_;
         ALCcontext* context_;
         std::list<SoundBase*> soundlist_;
         bool soundavailable_;




More information about the Orxonox-commit mailing list