]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_openal.cxx
restore some part of the code to prevent an untwanted segmentationf fault.
[simgear.git] / simgear / sound / sample_openal.cxx
index 191877ae6b957d33ddac8877cc0ef6f37826e7d0..5fc257cc7ca83982ed518f98a66a9369b4f19dfb 100644 (file)
@@ -151,6 +151,10 @@ SGSoundSample::SGSoundSample( unsigned char *data, int len, int freq, int format
 
 // destructor
 SGSoundSample::~SGSoundSample() {
+    if (_data != NULL) {
+        delete _data;
+        _data = NULL;
+    }
 }
 
 void SGSoundSample::set_orientation( const SGQuatd& ori ) {
@@ -183,4 +187,7 @@ void SGSoundSample::update_absolute_position() {
 
      orient = SGQuatd::fromRealImag(0, _relative_pos) * _orientation;
     _absolute_pos = -SGVec3d::fromGeod(_base_pos) -orient.rotate(SGVec3d::e1());
+
+    float vel = length(_velocity);
+    _velocity = toVec3d(_orivec * vel);
 }