[Orxonox-commit 525] r3075 - trunk/src/orxonox/sound

erwin at orxonox.net erwin at orxonox.net
Mon May 25 21:08:55 CEST 2009


Author: erwin
Date: 2009-05-25 21:08:55 +0200 (Mon, 25 May 2009)
New Revision: 3075

Modified:
   trunk/src/orxonox/sound/SoundBase.cc
Log:
fixed ogg loader. it works, bitches

Modified: trunk/src/orxonox/sound/SoundBase.cc
===================================================================
--- trunk/src/orxonox/sound/SoundBase.cc	2009-05-25 18:40:39 UTC (rev 3074)
+++ trunk/src/orxonox/sound/SoundBase.cc	2009-05-25 19:08:55 UTC (rev 3075)
@@ -160,6 +160,7 @@
 
         alGenSources(1, &this->source_);
         alSourcei(this->source_, AL_BUFFER, this->buffer_);
+//         ALenum
         if(alGetError() != AL_NO_ERROR) {
             COUT(2) << "Sound: OpenAL: Error loading sample file: " << filename << std::endl;
             return false;
@@ -178,8 +179,11 @@
         char inbuffer[4096];
         std::vector<char> outbuffer;
         OggVorbis_File vf;
+        vorbis_info* vorbisInfo;
         int eof = false;
         int current_section;
+        ALuint buffer;
+        ALenum format;
 
         FILE* f = fopen(filename.c_str(), "rb");
 
@@ -209,8 +213,16 @@
             }
         }
 
+        vorbisInfo = ov_info(&vf, -1);
+        if(vorbisInfo->channels == 1)
+            format = AL_FORMAT_MONO16;
+        else
+            format = AL_FORMAT_STEREO16;
+
+        alGenBuffers(1, &buffer);
+        alBufferData(buffer, format, &outbuffer[0], outbuffer.size(), vorbisInfo->rate);
         ov_clear(&vf);
 
-        return alutCreateBufferFromFileImage(&outbuffer, outbuffer.size());
+        return buffer;
     }
 } // namespace: orxonox




More information about the Orxonox-commit mailing list