[Orxonox-commit 415] r2998 - in branches/sound/src/orxonox: objects/items sound

erwin at orxonox.net erwin at orxonox.net
Wed May 20 20:31:23 CEST 2009


Author: erwin
Date: 2009-05-20 20:31:23 +0200 (Wed, 20 May 2009)
New Revision: 2998

Modified:
   branches/sound/src/orxonox/objects/items/Engine.cc
   branches/sound/src/orxonox/sound/SoundBase.cc
   branches/sound/src/orxonox/sound/SoundManager.cc
   branches/sound/src/orxonox/sound/SoundManager.h
Log:
fixed some bugs

Modified: branches/sound/src/orxonox/objects/items/Engine.cc
===================================================================
--- branches/sound/src/orxonox/objects/items/Engine.cc	2009-05-20 14:18:02 UTC (rev 2997)
+++ branches/sound/src/orxonox/objects/items/Engine.cc	2009-05-20 18:31:23 UTC (rev 2998)
@@ -225,9 +225,6 @@
     {
         this->ship_ = ship;
 
-        if(this->sound_ != NULL)
-            this->sound_->attachToEntity(ship);
-
         if (ship)
         {
             this->shipID_ = ship->getObjectID();
@@ -239,6 +236,9 @@
                 delete this->boostBlur_;
                 this->boostBlur_ = 0;
             }
+
+            if(this->sound_ != NULL)
+                this->sound_->attachToEntity(ship);
         }
     }
 

Modified: branches/sound/src/orxonox/sound/SoundBase.cc
===================================================================
--- branches/sound/src/orxonox/sound/SoundBase.cc	2009-05-20 14:18:02 UTC (rev 2997)
+++ branches/sound/src/orxonox/sound/SoundBase.cc	2009-05-20 18:31:23 UTC (rev 2998)
@@ -133,6 +133,13 @@
 
     bool SoundBase::loadFile(std::string filename) {
         filename = Core::getMediaPathString() + "/audio/" + filename;
+
+        if(!SoundBase::soundmanager_s->isSoundAvailable())
+        {
+            COUT(3) << "Sound: not available, skipping " << filename << std::endl;
+            return false;
+        }
+
         COUT(3) << "Sound: OpenAL ALUT: loading file " << filename << std::endl;
         this->buffer_ = alutCreateBufferFromFile(filename.c_str());
         if(this->buffer_ == AL_NONE) {

Modified: branches/sound/src/orxonox/sound/SoundManager.cc
===================================================================
--- branches/sound/src/orxonox/sound/SoundManager.cc	2009-05-20 14:18:02 UTC (rev 2997)
+++ branches/sound/src/orxonox/sound/SoundManager.cc	2009-05-20 18:31:23 UTC (rev 2998)
@@ -43,9 +43,11 @@
      */
     SoundManager::SoundManager()
     {
+        this->soundavailable_ = true;
         if(!alutInitWithoutContext(NULL,NULL))
         {
             COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
+            this->soundavailable_ = false;
         }
         else
         {
@@ -60,6 +62,7 @@
             if(SoundManager::device_s == NULL)
             {
                 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
+                this->soundavailable_ = false;
             }
             else
             {
@@ -68,6 +71,7 @@
                 if(this->context_ == NULL)
                 {
                     COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl;
+                    this->soundavailable_ = false;
                 }
                 else
                 {
@@ -145,4 +149,12 @@
         for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)
             (*i)->update();
     }
+    
+    /**
+    * Check if sound is available
+    */
+    bool SoundManager::isSoundAvailable()
+    {
+        return this->soundavailable_;
+    }
 }

Modified: branches/sound/src/orxonox/sound/SoundManager.h
===================================================================
--- branches/sound/src/orxonox/sound/SoundManager.h	2009-05-20 14:18:02 UTC (rev 2997)
+++ branches/sound/src/orxonox/sound/SoundManager.h	2009-05-20 18:31:23 UTC (rev 2998)
@@ -49,13 +49,14 @@
         ~SoundManager();
         void addSound(SoundBase* sound);
         void removeSound(SoundBase* sound);
-
         virtual void tick(float dt);
+        bool isSoundAvailable();
 
     private:
         static ALCdevice* device_s;
         ALCcontext* context_;
         std::list<SoundBase*> soundlist_;
+        bool soundavailable_;
 
     }; // class SoundManager
 } // namespace orxonox




More information about the Orxonox-commit mailing list