[Orxonox-commit 2013] r6730 - code/branches/sound5/src/orxonox/sound

erwin at orxonox.net erwin at orxonox.net
Thu Apr 15 13:57:51 CEST 2010


Author: erwin
Date: 2010-04-15 13:57:51 +0200 (Thu, 15 Apr 2010)
New Revision: 6730

Modified:
   code/branches/sound5/src/orxonox/sound/AmbientSound.cc
Log:
Transfer changes again

Modified: code/branches/sound5/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/branches/sound5/src/orxonox/sound/AmbientSound.cc	2010-04-15 11:32:59 UTC (rev 6729)
+++ code/branches/sound5/src/orxonox/sound/AmbientSound.cc	2010-04-15 11:57:51 UTC (rev 6730)
@@ -148,6 +148,12 @@
     // hacky solution for file streaming
     void AmbientSound::setStreamSource(const std::string& source)
     {
+        if (!GameMode::playsSound())
+        {
+            this->source_ = source;
+            return;
+        }
+
         this->audioSource_ = SoundManager::getInstance().getSoundSource(this);
         if (this->source_ == source)
         {
@@ -177,6 +183,25 @@
         if(this->soundstreamthread_ == boost::thread())
             COUT(2) << "Sound: Failed to create thread." << std::endl;
 
+        if (alIsSource(this->audioSource_)) // already playing or paused
+        {
+            // Sound was already playing or paused because there was a source acquired
+            assert(this->isPlaying() || this->isPaused());
+            alSourcePlay(this->audioSource_);
+            if (int error = alGetError())
+                COUT(2) << "Sound: Error playing sound: " << getALErrorString(error) << std::endl;
+            if (this->isPaused())
+                alSourcePause(this->audioSource_);
+        }
+        else // No source acquired so far, but might be set to playing or paused
+        {
+            if (this->isPlaying() || this->isPaused())
+                doPlay();
+            if (this->isPaused())
+            {
+                doPause();
+            }
+        }
 
         this->updateVolume();
         this->setPitch(this->getPitch());




More information about the Orxonox-commit mailing list