From: Erik Hofman <erik@ehofman.com>
Date: Tue, 19 Jul 2016 08:44:46 +0000 (+0200)
Subject: Reluctantly add support for stereo files again: there are external hangars which... 
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8be5fdb6c45343940d408ea0cfc25c1a8ae96fef;p=simgear.git

Reluctantly add support for stereo files again: there are external hangars which did not update to the mono-files only principle
---

diff --git a/simgear/sound/readwav.cxx b/simgear/sound/readwav.cxx
index 3661fe47..9026e7fc 100644
--- a/simgear/sound/readwav.cxx
+++ b/simgear/sound/readwav.cxx
@@ -59,9 +59,13 @@ namespace
     if (!compressed) {
       if (numChannels == 1 && bitsPerSample == 16) rv = SG_SAMPLE_MONO16;
       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 {
       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");
     }
     return rv;
   }
diff --git a/simgear/sound/sample.hxx b/simgear/sound/sample.hxx
index 1980eb71..13da128d 100644
--- a/simgear/sound/sample.hxx
+++ b/simgear/sound/sample.hxx
@@ -47,7 +47,10 @@ enum {
     SG_SAMPLE_MONO8    = (SG_SAMPLE_MONO|SG_SAMPLE_8BITS),
     SG_SAMPLE_MONO16   = (SG_SAMPLE_MONO|SG_SAMPLE_16BITS),
     SG_SAMPLE_MULAW    = (SG_SAMPLE_MONO|SG_SAMPLE_8BITS|SG_SAMPLE_COMPRESSED),
-    SG_SAMPLE_ADPCM    = (SG_SAMPLE_MONO|SG_SAMPLE_4BITS|SG_SAMPLE_COMPRESSED)
+    SG_SAMPLE_ADPCM    = (SG_SAMPLE_MONO|SG_SAMPLE_4BITS|SG_SAMPLE_COMPRESSED),
+
+    SG_SAMPLE_STEREO8  = (SG_SAMPLE_STEREO|SG_SAMPLE_8BITS),
+    SG_SAMPLE_STEREO16 = (SG_SAMPLE_STEREO|SG_SAMPLE_16BITS)
 };
 
 
diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx
index 497fe3b3..6064a0be 100644
--- a/simgear/sound/soundmgr_openal.cxx
+++ b/simgear/sound/soundmgr_openal.cxx
@@ -586,6 +586,12 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
         case SG_SAMPLE_ADPCM:
             format = AL_FORMAT_MONO_IMA4;
             break;
+
+        case SG_SAMPLE_STEREO16:
+            format = AL_FORMAT_STEREO16;
+            break;
+        case SG_SAMPLE_STEREO8:
+            format = AL_FORMAT_STEREO8;
         default:
             SG_LOG(SG_SOUND, SG_ALERT, "unsupported audio format");
             return buffer;