]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
Update the bad-doppler test and simplify it to only test for bad platforms.
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index c3eda45a0568e7cb2e9037a23b0f9a8cc9af6fb0..3a0b2979c3a4d841caf11cdddd67518fcd44e8e1 100644 (file)
@@ -174,11 +174,11 @@ void SGSoundMgr::init(const char *devname) {
 
     _vendor = (const char *)alGetString(AL_VENDOR);
     _renderer = (const char *)alGetString(AL_RENDERER);
-    if ( (_vendor != "Adalin" && _vendor != "Apple Computer Inc.") &&
-          (_vendor != "OpenAL Community" || (_renderer != "Software" &&
-                        _renderer != "OpenAL Sample Implementation"))
-       )
-    {
+
+    if (_vendor == "Creative Labs Inc.") {
+       _bad_doppler = true;
+
+    } else if (_vendor == "OpenAL Community" && _renderer == "OpenAL Soft") {
        _bad_doppler = true;
     }
 
@@ -438,11 +438,12 @@ void SGSoundMgr::release_source( unsigned int source )
         ALint result;
 
         alGetSourcei( source, AL_SOURCE_STATE, &result );
-        if ( result == AL_PLAYING )
+        if ( result == AL_PLAYING ) {
             alSourceStop( source );
-        testForALError("release source");
+        }
 
-        alSourcei( source, AL_BUFFER, 0 );
+        alSourcei( source, AL_BUFFER, 0 );     // detach the associated buffer
+        testForALError("release_source");
         _free_sources.push_back( source );
         _sources_in_use.erase( it );
     }
@@ -473,18 +474,20 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
 
             try {
               bool res = load(sample_name, &sample_data, &format, &size, &freq);
-              if (res == false) return buffer;
+              if (res == false) return NO_BUFFER;
             } catch (sg_exception& e) {
-              SG_LOG(SG_GENERAL, SG_ALERT, "failed to load sound buffer:" << e.getFormattedMessage());
+              SG_LOG(SG_GENERAL, SG_ALERT,
+                     "failed to load sound buffer:" << e.getFormattedMessage());
               return NO_BUFFER;
             }
             
             sample->set_frequency( freq );
             sample->set_format( format );
             sample->set_size( size );
-        }
-        else
+
+        } else {
             sample_data = sample->get_data();
+        }
 
         // create an OpenAL buffer handle
         alGenBuffers(1, &buffer);
@@ -496,17 +499,17 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
             ALsizei freq = sample->get_frequency();
             alBufferData( buffer, format, sample_data, size, freq );
 
-            if ( sample->is_file() ) free(sample_data);
-
             if ( !testForALError("buffer add data") ) {
                 sample->set_buffer(buffer);
                 _buffers[sample_name] = refUint(buffer);
             }
         }
+
+        if ( sample->is_file() ) free(sample_data);
     }
     else {
         buffer = sample->get_buffer();
-}
+    }
 
     return buffer;
 }
@@ -554,10 +557,7 @@ void SGSoundMgr::update_pos_and_orientation() {
     _at_up_vec[4] = sgv_up[1];
     _at_up_vec[5] = sgv_up[2];
 
-    // static const SGQuatd q(-0.5, -0.5, 0.5, 0.5);
-    // SGQuatd hlOr = SGQuatd::fromLonLat(SGGeod::fromCart(_base_pos));
-    // SGQuatd ec2body = hlOr*_orientation;
-    _absolute_pos = _base_pos; // + ec2body.backTransform( _offset_pos );
+    _absolute_pos = _base_pos;
 }
 
 bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,