]> git.mxchange.org Git - simgear.git/commitdiff
Properly handle stereo wav files; remove data buffer and set buffer to FAILED_BUFFER
authorErik Hofman <erik@ehofman.com>
Wed, 7 Dec 2011 09:41:57 +0000 (10:41 +0100)
committerErik Hofman <erik@ehofman.com>
Wed, 7 Dec 2011 09:41:57 +0000 (10:41 +0100)
simgear/sound/sample_group.cxx
simgear/sound/soundmgr_openal.cxx
simgear/sound/soundmgr_openal.hxx

index cc594c2f9053886664540f73eddc201ab6342f9e..9dce6a4288eea3697a448242c6eb2bbae6bf51bd 100644 (file)
@@ -157,14 +157,16 @@ void SGSampleGroup::update( double dt ) {
                 }
                 else
                 {
-                    if (_smgr->request_buffer(sample) == SGSoundMgr::NO_BUFFER)
+                    ALuint buffer = _smgr->request_buffer(sample);
+                    if (buffer == SGSoundMgr::FAILED_BUFFER ||
+                        buffer == SGSoundMgr::NO_BUFFER)
                     {
                         _smgr->release_source(source);
                         continue;
                     }
 
                     // start playing the sample
-                    ALuint buffer = sample->get_buffer();
+                    buffer = sample->get_buffer();
                     if ( alIsBuffer(buffer) == AL_TRUE )
                     {
                         alSourcei( source, AL_BUFFER, buffer );
index 6fd7ce15302b6360ac37a25d6c125180ed2c034e..34bea9bc93c5579f603513d95721ff06451e8781 100644 (file)
@@ -481,8 +481,9 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
               if (res == false) return NO_BUFFER;
             } catch (sg_exception& e) {
               SG_LOG(SG_GENERAL, SG_ALERT,
-                     "failed to load sound buffer:" << e.getFormattedMessage());
-              return NO_BUFFER;
+                    "failed to load sound buffer: " << e.getFormattedMessage());
+              sample->set_buffer( SGSoundMgr::FAILED_BUFFER );
+              return FAILED_BUFFER;
             }
             
             sample->set_frequency( freq );
@@ -618,6 +619,7 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
 #endif
 
     if (format == AL_FORMAT_STEREO8 || format == AL_FORMAT_STEREO16) {
+        free(data);
         throw sg_io_exception("Warning: STEREO files are not supported for 3D audio effects: " + samplepath);
     }
 
index 749d84272bffd28f78e313f96d9819a058c375e7..e075a913938540005c4b897bb739eedd7052a1ca 100644 (file)
@@ -200,7 +200,8 @@ public:
 
     enum {
         NO_SOURCE = (unsigned int)-1,
-        NO_BUFFER = (unsigned int)-1
+        NO_BUFFER = (unsigned int)-1,
+        FAILED_BUFFER = (unsigned int)-2
     };
 
     /**