]> git.mxchange.org Git - simgear.git/commitdiff
Be more specific about what audio type is detected and for which file if it is not...
authorErik Hofman <erik@ehofman.com>
Wed, 20 Jul 2016 06:37:07 +0000 (08:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/sound/readwav.cxx
simgear/sound/soundmgr_openal.cxx

index 9026e7fc525558460f0190236cf6132142ec6b5d..fa892d23e004c6c08d24a612783e633ce98e8961 100644 (file)
@@ -23,6 +23,7 @@
 #include <cassert>
 #include <cstdlib>
 
+#include <stdio.h> // snprintf
 #include <zlib.h> // for gzXXX functions
 
 #include <simgear/misc/sg_path.hxx>
@@ -61,11 +62,19 @@ namespace
       else if (numChannels == 1 && bitsPerSample == 8) rv = SG_SAMPLE_MONO8;
       else if (numChannels == 2 && bitsPerSample == 16) rv = SG_SAMPLE_STEREO16;
       else if (numChannels == 2 && bitsPerSample == 8) rv = SG_SAMPLE_STEREO8;
-      else throw sg_exception("Unsupported audio format");
+      else {
+        char msg[65];
+        snprintf(msg, 64, "Unsupported audio format: tracks: %i, bits/sample: %i", numChannels, bitsPerSample);
+        throw sg_exception(msg);
+      }
     } else {
       if (numChannels == 1 && bitsPerSample == 4) rv = SG_SAMPLE_ADPCM; 
       else if (numChannels == 1 && bitsPerSample == 8) rv = SG_SAMPLE_MULAW;
-      else throw sg_exception("Unsupported audio format");
+      else {
+        char msg[65];
+        snprintf(msg, 64, "Unsupported compressed audio format: tracks: %i, bits/sample: %i", numChannels, bitsPerSample);
+        throw sg_exception(msg);
+      }
     }
     return rv;
   }
@@ -382,7 +391,12 @@ ALvoid* loadWAVFromFile(const SGPath& path, unsigned int& format, ALsizei& size,
     throw sg_io_exception("loadWAVFromFile: unable to open file", path);
   }
   
-  loadWavFile(fd, &b);
+  try {
+      loadWavFile(fd, &b);
+  } catch (sg_exception& e) {
+      throw sg_io_exception(e.getFormattedMessage() + " for " + path.str());
+  }
+
   ALvoid* data = b.data;
   b.data = NULL; // don't free when Buffer does out of scope
   format = b.format;
index 6064a0be035c37081766629048c5124a0f8da022..ec1646af9242452ab5ec39b8abf9a6020ef87a55 100644 (file)
@@ -588,9 +588,11 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
             break;
 
         case SG_SAMPLE_STEREO16:
+            SG_LOG(SG_SOUND, SG_ALERT, "Stereo sound detected: " << sample->get_sample_name());
             format = AL_FORMAT_STEREO16;
             break;
         case SG_SAMPLE_STEREO8:
+            SG_LOG(SG_SOUND, SG_ALERT, "Stereo sound detected: " << sample->get_sample_name());
             format = AL_FORMAT_STEREO8;
         default:
             SG_LOG(SG_SOUND, SG_ALERT, "unsupported audio format");