]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/readwav.cxx
Reset: allow re-init of Nasal Ghosts.
[simgear.git] / simgear / sound / readwav.cxx
index 54acda5acd771dc371363160dca6aac3817bed52..d23ed8cf7037becbbcc9bde34b38d8553db95cc4 100644 (file)
@@ -21,6 +21,7 @@
 #include "readwav.hxx"
 
 #include <cassert>
+#include <cstdlib>
 
 #include <zlib.h> // for gzXXX functions
 
@@ -108,11 +109,10 @@ int16_t mulaw2linear (uint8_t mulawbyte)
    uint8_t *d = (uint8_t *) b->data;
    size_t newLength = b->length * 2;
    int16_t *buf = (int16_t *) malloc(newLength);
-   size_t i;
    if (buf == NULL)
      throw sg_exception("malloc failed decoing ULaw WAV file");
    
-   for (i = 0; i < b->length; i++) {
+   for (ALsizei i = 0; i < b->length; i++) {
        buf[i] = mulaw2linear(d[i]);
     }
     
@@ -284,13 +284,14 @@ ALvoid* loadWAVFromFile(const SGPath& path, ALenum& format, ALsizei& size, ALflo
 
 ALuint createBufferFromFile(const SGPath& path)
 {
+  ALuint buffer = -1;
+#ifdef ENABLE_SOUND
   ALenum format;
   ALsizei size;
   ALfloat sampleFrequency;
   ALvoid* data = loadWAVFromFile(path, format, size, sampleFrequency);
   assert(data);
   
-  ALuint buffer;
   alGenBuffers(1, &buffer);
   if (alGetError() != AL_NO_ERROR) {
     free(data);
@@ -303,7 +304,7 @@ ALuint createBufferFromFile(const SGPath& path)
     free(data);
     throw sg_io_exception("OpenAL setting buffer data failed", sg_location(path.str()));
   }
-    
+#endif 
   return buffer;
 }