]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_group.cxx
restore some part of the code to prevent an untwanted segmentationf fault.
[simgear.git] / simgear / sound / sample_group.cxx
index c85e386f44e213223bedfdb257f94db950a4cf05..1c63e3ee0408409de5861a35af43f19960855606 100644 (file)
@@ -1,3 +1,25 @@
+// sample_group.cxx -- Manage a group of samples relative to a base position
+//
+// Written for the new SoundSystem by Erik Hofman, October 2009
+//
+// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// $Id$
+
 #ifdef HAVE_CONFIG_H
 #  include <simgear_config.h>
 #endif
@@ -47,8 +69,8 @@ SGSampleGroup::SGSampleGroup () :
     _active(false),
     _tied_to_listener(false),
     _velocity(SGVec3d::zeros()),
-    _position(SGGeod()),
-    _orientation(SGQuatd::zeros())
+    _orientation(SGQuatd::zeros()),
+    _position(SGGeod())
 {
     _samples.clear();
 }
@@ -59,11 +81,10 @@ SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr, const string &refname ) :
     _active(false), 
     _tied_to_listener(false),
     _velocity(SGVec3d::zeros()),
-    _position(SGGeod()),
-    _orientation(SGQuatd::zeros())
+    _orientation(SGQuatd::zeros()),
+    _position(SGGeod())
 {
     _smgr->add(this, refname);
-    _active = _smgr->is_working();
     _samples.clear();
 }
 
@@ -289,7 +310,7 @@ bool SGSampleGroup::stop( const string& refname ) {
 }
 
 // set source velocity of all managed sounds
-void SGSampleGroup::set_velocity( SGVec3d &vel ) {
+void SGSampleGroup::set_velocity( const SGVec3d &vel ) {
     if ( isnan(vel[0]) || isnan(vel[1]) || isnan(vel[2]) )
     {
         SG_LOG( SG_GENERAL, SG_ALERT, "NAN's found in SampleGroup velocity");
@@ -307,8 +328,8 @@ void SGSampleGroup::set_velocity( SGVec3d &vel ) {
     }
 }
 
-// ste the source orientation of all managed sounds
-void SGSampleGroup::set_position( SGGeod pos ) {
+// set the source position of all managed sounds
+void SGSampleGroup::set_position( const SGGeod& pos ) {
 
     sample_map_iterator sample_current = _samples.begin();
     sample_map_iterator sample_end = _samples.end();
@@ -320,8 +341,8 @@ void SGSampleGroup::set_position( SGGeod pos ) {
 }
 
 
-// ste the source orientation of all managed sounds
-void SGSampleGroup::set_orientation( SGQuatd ori ) {
+// set the source orientation of all managed sounds
+void SGSampleGroup::set_orientation( const SGQuatd& ori ) {
 
     if (_orientation != ori) {
         sample_map_iterator sample_current = _samples.begin();
@@ -357,7 +378,7 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample ) {
             alSourcefv( source, AL_DIRECTION, _smgr->get_direction().data() );
             alSourcefv( source, AL_VELOCITY, _smgr->get_velocity().data() );
         } else {
-            alSourcefv( source, AL_POSITION, sample->get_position());
+            alSourcefv( source, AL_POSITION, sample->get_position() );
             alSourcefv( source, AL_DIRECTION, sample->get_orientation() );
             alSourcefv( source, AL_VELOCITY, sample->get_velocity() );
         }