1 // _samplequeue.cxx -- Sound effect management class implementation
3 // Started by David Megginson, October 2001
4 // (Reuses some code from main.cxx, probably by Curtis Olson)
6 // Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #pragma warning (disable: 4786)
32 #include "sample_queue.hxx"
34 #include <Main/fg_props.hxx>
36 #include <simgear/sound/soundmgr_openal.hxx>
37 #include <simgear/sound/sample_openal.hxx>
39 FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const string &refname ) :
42 _enabled( fgGetNode("/sim/sound/chatter/enabled", true) ),
43 _volume( fgGetNode("/sim/sound/chatter/volume", true) )
45 SGSampleGroup::_smgr = smgr;
46 SGSampleGroup::_smgr->add(this, refname);
47 SGSampleGroup::_refname = refname;
48 _enabled->setBoolValue(true);
49 _volume->setFloatValue(1.0);
53 FGSampleQueue::~FGSampleQueue ()
55 while ( _messages.size() > 0 ) {
56 delete _messages.front();
63 FGSampleQueue::update (double dt)
65 // command sound manger
66 bool new_enabled = _enabled->getBoolValue();
67 if ( new_enabled != last_enabled ) {
73 last_enabled = new_enabled;
77 double volume = _volume->getDoubleValue();
78 if ( volume != last_volume ) {
83 // process mesage queue
84 const string msgid = "Sequential Audio Message";
85 bool now_playing = false;
86 if ( exists( msgid ) ) {
87 now_playing = is_playing( msgid );
89 // current message finished, stop and remove
90 stop( msgid ); // removes source
91 remove( msgid ); // removes buffer
96 // message queue idle, add next sound if we have one
97 if ( _messages.size() > 0 ) {
98 SGSampleGroup::add( _messages.front(), msgid );
104 SGSampleGroup::update(dt);
108 // end of _samplequeue.cxx