[Orxonox-commit 1514] r6232 - code/branches/presentation2/src/orxonox/sound

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Dec 3 19:48:43 CET 2009


Author: rgrieder
Date: 2009-12-03 19:48:42 +0100 (Thu, 03 Dec 2009)
New Revision: 6232

Modified:
   code/branches/presentation2/src/orxonox/sound/BaseSound.cc
   code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc
   code/branches/presentation2/src/orxonox/sound/SoundManager.cc
Log:
Fixed two problems in the sound system: Buffers did not get removed from the list in the SoundManager and failed creation was not caught.

Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc	2009-12-03 18:33:14 UTC (rev 6231)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc	2009-12-03 18:48:42 UTC (rev 6232)
@@ -169,7 +169,7 @@
         }
 
         this->source_ = source;
-        if (source_.empty()) 
+        if (source_.empty())
             return;
 
         // Get DataStream from the resources

Modified: code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc	2009-12-03 18:33:14 UTC (rev 6231)
+++ code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc	2009-12-03 18:48:42 UTC (rev 6232)
@@ -80,7 +80,7 @@
         delete[] buffer;
 
         if (this->audioBuffer_ == AL_NONE)
-            ThrowException(General, "Sound: Standard file loader failed: " << alutGetErrorString(alutGetError()));
+            ThrowException(General, "Sound Error: Standard file loader failed: " << alutGetErrorString(alutGetError()));
     }
 
     size_t readVorbis(void* ptr, size_t size, size_t nmemb, void* datasource)
@@ -126,7 +126,7 @@
         {
             COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
             ov_clear(&vf);
-            ThrowException(General, "Sound: Ogg file loader failed when opening the bitstream");
+            ThrowException(General, "Sound Error: Ogg file loader failed when opening the bitstream");
         }
 
         int current_section;
@@ -142,7 +142,7 @@
             {
                 COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
                 ov_clear(&vf);
-                ThrowException(General, "Sound: Ogg file loader failed when decoding the file");
+                ThrowException(General, "Sound Error: Ogg file loader failed when decoding the file");
             }
             else
             {

Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-03 18:33:14 UTC (rev 6231)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-03 18:48:42 UTC (rev 6232)
@@ -483,7 +483,16 @@
             return it->second.lock();
         else
         {
-            shared_ptr<SoundBuffer> buffer(new SoundBuffer(fileInfo));
+            shared_ptr<SoundBuffer> buffer;
+            try
+            {
+                buffer.reset(new SoundBuffer(fileInfo));
+            }
+            catch (...)
+            {
+                COUT(1) << Exception::handleMessage() << std::endl;
+                return shared_ptr<SoundBuffer>();
+            }
             this->soundBuffers_[fileInfo->group + '/' + fileInfo->filename] = buffer;
             return buffer;
         }
@@ -493,7 +502,7 @@
     {
         std::map<std::string, weak_ptr<SoundBuffer> >::iterator it
             = this->soundBuffers_.find(fileInfo->group + '/' + fileInfo->filename);
-        if (it == this->soundBuffers_.end())
+        if (it != this->soundBuffers_.end())
             this->soundBuffers_.erase(it);
     }
 }




More information about the Orxonox-commit mailing list