]> 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 84fd81b9031dd0b33ca83b3fa5a723c3674c3630..d23ed8cf7037becbbcc9bde34b38d8553db95cc4 100644 (file)
@@ -109,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]);
     }
     
@@ -285,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);
@@ -304,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;
 }