Don't make the SoundManager a memebr of the subsystem manager; It needs to be initialized very early and destroyed as late as possible. That doesn't work as a subsystem meber onless some sort of priority scheme gets implemented. Get rid of auto_ptr which doesn work for the samples either.
This commit is contained in:
parent
9c8d6ee663
commit
f9445874a0
20 changed files with 71 additions and 69 deletions
|
@ -24,7 +24,6 @@
|
||||||
#include <simgear/sound/soundmgr_openal.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +51,7 @@ FGAIPlane::FGAIPlane() {
|
||||||
_rollSuspended = false;
|
_rollSuspended = false;
|
||||||
|
|
||||||
if ( !_sgr ) {
|
if ( !_sgr ) {
|
||||||
SGSoundMgr *smgr;
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
|
||||||
_sgr = smgr->find("atc", true);
|
_sgr = smgr->find("atc", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
}
|
}
|
||||||
|
@ -199,13 +197,10 @@ void FGAIPlane::Render(const string& refname, const float volume, bool repeating
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
voice = (voiceOK && fgGetBool("/sim/sound/voice"));
|
voice = (voiceOK && fgGetBool("/sim/sound/voice"));
|
||||||
if(voice) {
|
if(voice) {
|
||||||
string buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), voice);
|
sizte_t len;
|
||||||
|
void* buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), voice, &len);
|
||||||
if(voice && (volume > 0.05)) {
|
if(voice && (volume > 0.05)) {
|
||||||
std::auto_ptr<unsigned char> ptr( (unsigned char*)buf.c_str() );
|
SGSoundSample* simple = new SGSoundSample(buf, len, 8000 );
|
||||||
SGSoundSample* simple =
|
|
||||||
new SGSoundSample(ptr, buf.length(), 8000 );
|
|
||||||
// TODO - at the moment the volume can't be changed
|
|
||||||
// after the transmission has started.
|
|
||||||
simple->set_volume(volume);
|
simple->set_volume(volume);
|
||||||
_sgr->add(simple, refname);
|
_sgr->add(simple, refname);
|
||||||
_sgr->play(refname, repeating);
|
_sgr->play(refname, repeating);
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "ATC.hxx"
|
#include "ATC.hxx"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <simgear/sound/soundmgr_openal.hxx>
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
@ -57,8 +56,7 @@ FGATC::FGATC() :
|
||||||
_counter(0.0),
|
_counter(0.0),
|
||||||
_max_count(5.0)
|
_max_count(5.0)
|
||||||
{
|
{
|
||||||
SGSoundMgr *smgr;
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
|
||||||
_sgr = smgr->find("atc", true);
|
_sgr = smgr->find("atc", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,18 +229,15 @@ void FGATC::Render(string& msg, const float volume,
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
_voice = (_voiceOK && fgGetBool("/sim/sound/voice"));
|
_voice = (_voiceOK && fgGetBool("/sim/sound/voice"));
|
||||||
if(_voice) {
|
if(_voice) {
|
||||||
string buf = _vPtr->WriteMessage((char*)msg.c_str(), _voice);
|
size_t len;
|
||||||
if(_voice && (volume > 0.05)) {
|
void* buf = _vPtr->WriteMessage((char*)msg.c_str(), &len);
|
||||||
|
if(buf && (volume > 0.05)) {
|
||||||
NoRender(refname);
|
NoRender(refname);
|
||||||
try {
|
try {
|
||||||
// >>> Beware: must pass a (new) object to the (add) method,
|
// >>> Beware: must pass a (new) object to the (add) method,
|
||||||
// >>> because the (remove) method is going to do a (delete)
|
// >>> because the (remove) method is going to do a (delete)
|
||||||
// >>> whether that's what you want or not.
|
// >>> whether that's what you want or not.
|
||||||
std::auto_ptr<unsigned char> ptr( (unsigned char*)buf.c_str() );
|
SGSoundSample *simple = new SGSoundSample(&buf, len, 8000);
|
||||||
SGSoundSample *simple =
|
|
||||||
new SGSoundSample(ptr, buf.length(), 8000);
|
|
||||||
// TODO - at the moment the volume can't be changed
|
|
||||||
// after the transmission has started.
|
|
||||||
simple->set_volume(volume);
|
simple->set_volume(volume);
|
||||||
_sgr->add(simple, refname);
|
_sgr->add(simple, refname);
|
||||||
_sgr->play(refname, repeating);
|
_sgr->play(refname, repeating);
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool FGATCVoice::LoadVoice(const string& voice) {
|
||||||
|
|
||||||
string full_path = path.str();
|
string full_path = path.str();
|
||||||
int format, freq;
|
int format, freq;
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
void *data;
|
void *data;
|
||||||
if (!smgr->load(full_path, &data, &format, &rawDataSize, &freq))
|
if (!smgr->load(full_path, &data, &format, &rawDataSize, &freq))
|
||||||
return false;
|
return false;
|
||||||
|
@ -134,7 +134,7 @@ typedef tokenList_type::iterator tokenList_iterator;
|
||||||
|
|
||||||
// Given a desired message, return a string containing the
|
// Given a desired message, return a string containing the
|
||||||
// sound-sample data
|
// sound-sample data
|
||||||
string FGATCVoice::WriteMessage(const char* message, bool& dataOK) {
|
void* FGATCVoice::WriteMessage(const char* message, size_t* len) {
|
||||||
|
|
||||||
// What should we do here?
|
// What should we do here?
|
||||||
// First - parse the message into a list of tokens.
|
// First - parse the message into a list of tokens.
|
||||||
|
@ -185,8 +185,8 @@ string FGATCVoice::WriteMessage(const char* message, bool& dataOK) {
|
||||||
|
|
||||||
// Check for no tokens found else slScheduler can be crashed
|
// Check for no tokens found else slScheduler can be crashed
|
||||||
if(!word) {
|
if(!word) {
|
||||||
dataOK = false;
|
*len = 0;
|
||||||
return "";
|
return NULL;
|
||||||
}
|
}
|
||||||
boost::shared_array<char> tmpbuf(new char[cumLength]);
|
boost::shared_array<char> tmpbuf(new char[cumLength]);
|
||||||
unsigned int bufpos = 0;
|
unsigned int bufpos = 0;
|
||||||
|
@ -202,8 +202,8 @@ string FGATCVoice::WriteMessage(const char* message, bool& dataOK) {
|
||||||
SG_LOG(SG_ATC, SG_ALERT, "Offset + length: " << wdptr[i].offset + wdptr[i].length
|
SG_LOG(SG_ATC, SG_ALERT, "Offset + length: " << wdptr[i].offset + wdptr[i].length
|
||||||
<< " exceeds rawdata size: " << rawDataSize << endl);
|
<< " exceeds rawdata size: " << rawDataSize << endl);
|
||||||
|
|
||||||
dataOK = false;
|
*len = 0;
|
||||||
return "";
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(tmpbuf.get() + bufpos, rawSoundData + wdptr[i].offset, wdptr[i].length);
|
memcpy(tmpbuf.get() + bufpos, rawSoundData + wdptr[i].offset, wdptr[i].length);
|
||||||
bufpos += wdptr[i].length;
|
bufpos += wdptr[i].length;
|
||||||
|
@ -213,9 +213,11 @@ string FGATCVoice::WriteMessage(const char* message, bool& dataOK) {
|
||||||
unsigned int offsetIn = (int)(cumLength * sg_random());
|
unsigned int offsetIn = (int)(cumLength * sg_random());
|
||||||
if(offsetIn > cumLength) offsetIn = cumLength;
|
if(offsetIn > cumLength) offsetIn = cumLength;
|
||||||
|
|
||||||
string front(tmpbuf.get(), offsetIn);
|
void *data = malloc(cumLength);
|
||||||
string back(tmpbuf.get() + offsetIn, cumLength - offsetIn);
|
memcpy(data, tmpbuf.get(), cumLength);
|
||||||
|
*len = cumLength;
|
||||||
|
// string front(tmpbuf.get(), offsetIn);
|
||||||
|
// string back(tmpbuf.get() + offsetIn, cumLength - offsetIn);
|
||||||
|
|
||||||
dataOK = true;
|
return data;
|
||||||
return back + front;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ public:
|
||||||
bool LoadVoice(const std::string& voice);
|
bool LoadVoice(const std::string& voice);
|
||||||
|
|
||||||
// Given a desired message, return a pointer to the data buffer and write the buffer length into len.
|
// Given a desired message, return a pointer to the data buffer and write the buffer length into len.
|
||||||
// Sets dataOK = true if the returned buffer is valid.
|
// Sets len to something other than 0 if the returned buffer is valid.
|
||||||
std::string WriteMessage(const char* message, bool& dataOK);
|
void* WriteMessage(const char* message, size_t *len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ void FGClouds::init(void) {
|
||||||
snd_lightning = new SGSoundSample(globals->get_fg_root().c_str(), "Sounds/thunder.wav");
|
snd_lightning = new SGSoundSample(globals->get_fg_root().c_str(), "Sounds/thunder.wav");
|
||||||
snd_lightning->set_max_dist(7000.0f);
|
snd_lightning->set_max_dist(7000.0f);
|
||||||
snd_lightning->set_reference_dist(3000.0f);
|
snd_lightning->set_reference_dist(3000.0f);
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
SGSampleGroup *sgr = smgr->find("weather", true);
|
SGSampleGroup *sgr = smgr->find("weather", true);
|
||||||
sgr->add( snd_lightning, "thunder" );
|
sgr->add( snd_lightning, "thunder" );
|
||||||
sgEnviro.set_sampleGroup( sgr );
|
sgEnviro.set_sampleGroup( sgr );
|
||||||
|
|
|
@ -102,7 +102,7 @@ ADF::init ()
|
||||||
_ident_node = node->getChild("ident", 0, true);
|
_ident_node = node->getChild("ident", 0, true);
|
||||||
_ident_audible_node = node->getChild("ident-audible", 0, true);
|
_ident_audible_node = node->getChild("ident-audible", 0, true);
|
||||||
|
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_sgr = smgr->find("avionics", true);
|
_sgr = smgr->find("avionics", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ FGKR_87::~FGKR_87() {
|
||||||
|
|
||||||
|
|
||||||
void FGKR_87::init () {
|
void FGKR_87::init () {
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_sgr = smgr->find("avionics", true);
|
_sgr = smgr->find("avionics", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
morse.init();
|
morse.init();
|
||||||
|
|
|
@ -117,7 +117,7 @@ FGMarkerBeacon::init ()
|
||||||
if (serviceable->getType() == simgear::props::NONE)
|
if (serviceable->getType() == simgear::props::NONE)
|
||||||
serviceable->setBoolValue( true );
|
serviceable->setBoolValue( true );
|
||||||
|
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_sgr = smgr->find("avionics", true);
|
_sgr = smgr->find("avionics", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
|
|
||||||
|
|
|
@ -2200,7 +2200,7 @@ MK_VIII::VoicePlayer::init ()
|
||||||
{
|
{
|
||||||
#define STDPAUSE 0.75 // [SPEC] 6.4.4: "the standard 0.75 second delay"
|
#define STDPAUSE 0.75 // [SPEC] 6.4.4: "the standard 0.75 second delay"
|
||||||
|
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_sgr = smgr->find("avionics", true);
|
_sgr = smgr->find("avionics", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ FGNavRadio::~FGNavRadio()
|
||||||
void
|
void
|
||||||
FGNavRadio::init ()
|
FGNavRadio::init ()
|
||||||
{
|
{
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_sgr = smgr->find("avionics", true);
|
_sgr = smgr->find("avionics", true);
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
|
|
||||||
|
|
|
@ -1259,7 +1259,7 @@ do_play_audio_sample (const SGPropertyNode * arg)
|
||||||
try {
|
try {
|
||||||
static FGSampleQueue *queue = 0;
|
static FGSampleQueue *queue = 0;
|
||||||
if ( !queue ) {
|
if ( !queue ) {
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
queue = new FGSampleQueue(smgr, "queue");
|
queue = new FGSampleQueue(smgr, "queue");
|
||||||
queue->tie_to_listener();
|
queue->tie_to_listener();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1448,6 +1448,13 @@ bool fgInitSubsystems() {
|
||||||
globals->get_event_mgr()->init();
|
globals->get_event_mgr()->init();
|
||||||
globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
|
globals->get_event_mgr()->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Initialize the sound manager subsystem.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
globals->get_soundmgr()->bind();
|
||||||
|
globals->get_soundmgr()->init();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialize the property interpolator subsystem. Put into the INIT
|
// Initialize the property interpolator subsystem. Put into the INIT
|
||||||
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
||||||
|
|
|
@ -222,7 +222,7 @@ setFreeze (bool f)
|
||||||
frozen = f;
|
frozen = f;
|
||||||
|
|
||||||
// Stop sound on a pause
|
// Stop sound on a pause
|
||||||
SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
if ( smgr != NULL ) {
|
if ( smgr != NULL ) {
|
||||||
if ( f ) {
|
if ( f ) {
|
||||||
smgr->suspend();
|
smgr->suspend();
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software Foundation,
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/structure/event_mgr.hxx>
|
#include <simgear/structure/event_mgr.hxx>
|
||||||
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
|
||||||
#include <Aircraft/controls.hxx>
|
#include <Aircraft/controls.hxx>
|
||||||
#include <Airports/runways.hxx>
|
#include <Airports/runways.hxx>
|
||||||
|
@ -72,6 +73,7 @@ FGGlobals::FGGlobals() :
|
||||||
renderer( new FGRenderer ),
|
renderer( new FGRenderer ),
|
||||||
subsystem_mgr( new SGSubsystemMgr ),
|
subsystem_mgr( new SGSubsystemMgr ),
|
||||||
event_mgr( new SGEventMgr ),
|
event_mgr( new SGEventMgr ),
|
||||||
|
soundmgr( new SGSoundMgr ),
|
||||||
sim_time_sec( 0.0 ),
|
sim_time_sec( 0.0 ),
|
||||||
fg_root( "" ),
|
fg_root( "" ),
|
||||||
warp( 0 ),
|
warp( 0 ),
|
||||||
|
@ -158,6 +160,9 @@ FGGlobals::~FGGlobals()
|
||||||
delete channellist;
|
delete channellist;
|
||||||
delete airwaynet;
|
delete airwaynet;
|
||||||
delete multiplayer_mgr;
|
delete multiplayer_mgr;
|
||||||
|
|
||||||
|
soundmgr->unbind();
|
||||||
|
delete soundmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,6 +264,11 @@ FGGlobals::add_subsystem (const char * name,
|
||||||
subsystem_mgr->add(name, subsystem, type, min_time_sec);
|
subsystem_mgr->add(name, subsystem, type, min_time_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SGSoundMgr *
|
||||||
|
FGGlobals::get_soundmgr () const
|
||||||
|
{
|
||||||
|
return soundmgr;
|
||||||
|
}
|
||||||
|
|
||||||
SGEventMgr *
|
SGEventMgr *
|
||||||
FGGlobals::get_event_mgr () const
|
FGGlobals::get_event_mgr () const
|
||||||
|
|
|
@ -52,6 +52,7 @@ class SGTime;
|
||||||
class SGEventMgr;
|
class SGEventMgr;
|
||||||
class SGSubsystemMgr;
|
class SGSubsystemMgr;
|
||||||
class SGSubsystem;
|
class SGSubsystem;
|
||||||
|
class SGSoundMgr;
|
||||||
|
|
||||||
class FGAIMgr;
|
class FGAIMgr;
|
||||||
class FGATCMgr;
|
class FGATCMgr;
|
||||||
|
@ -93,6 +94,7 @@ private:
|
||||||
FGRenderer *renderer;
|
FGRenderer *renderer;
|
||||||
SGSubsystemMgr *subsystem_mgr;
|
SGSubsystemMgr *subsystem_mgr;
|
||||||
SGEventMgr *event_mgr;
|
SGEventMgr *event_mgr;
|
||||||
|
SGSoundMgr *soundmgr;
|
||||||
|
|
||||||
// Number of milliseconds elapsed since the start of the program.
|
// Number of milliseconds elapsed since the start of the program.
|
||||||
double sim_time_sec;
|
double sim_time_sec;
|
||||||
|
@ -198,6 +200,8 @@ public:
|
||||||
|
|
||||||
virtual SGEventMgr *get_event_mgr () const;
|
virtual SGEventMgr *get_event_mgr () const;
|
||||||
|
|
||||||
|
virtual SGSoundMgr *get_soundmgr () const;
|
||||||
|
|
||||||
inline double get_sim_time_sec () const { return sim_time_sec; }
|
inline double get_sim_time_sec () const { return sim_time_sec; }
|
||||||
inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
|
inline void inc_sim_time_sec (double dt) { sim_time_sec += dt; }
|
||||||
inline void set_sim_time_sec (double t) { sim_time_sec = t; }
|
inline void set_sim_time_sec (double t) { sim_time_sec = t; }
|
||||||
|
|
|
@ -482,7 +482,7 @@ static void fgMainLoop( void ) {
|
||||||
// is processing the scenery (doubled the frame-rate for me) -EMH-
|
// is processing the scenery (doubled the frame-rate for me) -EMH-
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
static SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
static SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
smgr->update_late(delta_time_sec);
|
smgr->update_late(delta_time_sec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -636,13 +636,6 @@ static void fgIdleFunction ( void ) {
|
||||||
|
|
||||||
} else if ( idle_state == 5 ) {
|
} else if ( idle_state == 5 ) {
|
||||||
idle_state++;
|
idle_state++;
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Add the Sound Manager before any other subsystem that uses it.
|
|
||||||
// This makes sure the SoundMgr is available at construction time.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
globals->add_subsystem("soundmgr", new SGSoundMgr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialize the 3D aircraft model subsystem (has a dependency on
|
// Initialize the 3D aircraft model subsystem (has a dependency on
|
||||||
|
|
|
@ -43,7 +43,7 @@ FGViewMgr::FGViewMgr( void ) :
|
||||||
config_list(fgGetNode("/sim", true)->getChildren("view")),
|
config_list(fgGetNode("/sim", true)->getChildren("view")),
|
||||||
current(0)
|
current(0)
|
||||||
{
|
{
|
||||||
smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
smgr = globals->get_soundmgr();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -48,8 +48,7 @@ FGAircraftModel::FGAircraftModel ()
|
||||||
_speed_e(0),
|
_speed_e(0),
|
||||||
_speed_d(0)
|
_speed_d(0)
|
||||||
{
|
{
|
||||||
SGSoundMgr *smgr;
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
|
|
||||||
_fx = new FGFX(smgr, "fx");
|
_fx = new FGFX(smgr, "fx");
|
||||||
_fx->init();
|
_fx->init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "beacon.hxx"
|
#include "beacon.hxx"
|
||||||
|
|
||||||
|
@ -39,13 +39,12 @@ FGBeacon::~FGBeacon() {
|
||||||
|
|
||||||
// allocate and initialize sound samples
|
// allocate and initialize sound samples
|
||||||
bool FGBeacon::init() {
|
bool FGBeacon::init() {
|
||||||
int i;
|
|
||||||
int len;
|
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
size_t i, len;
|
||||||
|
|
||||||
std::auto_ptr<unsigned char>inner_buf( new unsigned char[ INNER_SIZE ] );
|
const unsigned char* inner_buf = (const unsigned char*)malloc( INNER_SIZE );
|
||||||
std::auto_ptr<unsigned char>middle_buf( new unsigned char[ MIDDLE_SIZE ] );
|
const unsigned char* middle_buf = (const unsigned char*)malloc(MIDDLE_SIZE);
|
||||||
std::auto_ptr<unsigned char>outer_buf( new unsigned char[ OUTER_SIZE ] );
|
const unsigned char* outer_buf = (const unsigned char*)malloc( OUTER_SIZE );
|
||||||
|
|
||||||
// Make inner marker beacon sound
|
// Make inner marker beacon sound
|
||||||
len= (int)(INNER_DIT_LEN / 2.0 );
|
len= (int)(INNER_DIT_LEN / 2.0 );
|
||||||
|
@ -53,14 +52,14 @@ bool FGBeacon::init() {
|
||||||
make_tone( inner_dit, INNER_FREQ, len, INNER_DIT_LEN,
|
make_tone( inner_dit, INNER_FREQ, len, INNER_DIT_LEN,
|
||||||
TRANSITION_BYTES );
|
TRANSITION_BYTES );
|
||||||
|
|
||||||
ptr = inner_buf.get();
|
ptr = (unsigned char*)inner_buf;
|
||||||
for ( i = 0; i < 6; ++i ) {
|
for ( i = 0; i < 6; ++i ) {
|
||||||
memcpy( ptr, inner_dit, INNER_DIT_LEN );
|
memcpy( ptr, inner_dit, INNER_DIT_LEN );
|
||||||
ptr += INNER_DIT_LEN;
|
ptr += INNER_DIT_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND );
|
inner = new SGSoundSample( &inner_buf, INNER_SIZE, BYTES_PER_SECOND );
|
||||||
inner->set_reference_dist( 10.0 );
|
inner->set_reference_dist( 10.0 );
|
||||||
inner->set_max_dist( 20.0 );
|
inner->set_max_dist( 20.0 );
|
||||||
|
|
||||||
|
@ -75,12 +74,12 @@ bool FGBeacon::init() {
|
||||||
make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN,
|
make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN,
|
||||||
TRANSITION_BYTES );
|
TRANSITION_BYTES );
|
||||||
|
|
||||||
ptr = middle_buf.get();
|
ptr = (unsigned char*)middle_buf;
|
||||||
memcpy( ptr, middle_dit, MIDDLE_DIT_LEN );
|
memcpy( ptr, middle_dit, MIDDLE_DIT_LEN );
|
||||||
ptr += MIDDLE_DIT_LEN;
|
ptr += MIDDLE_DIT_LEN;
|
||||||
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
|
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
|
||||||
|
|
||||||
middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND );
|
middle = new SGSoundSample( &middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND);
|
||||||
middle->set_reference_dist( 10.0 );
|
middle->set_reference_dist( 10.0 );
|
||||||
middle->set_max_dist( 20.0 );
|
middle->set_max_dist( 20.0 );
|
||||||
|
|
||||||
|
@ -90,12 +89,12 @@ bool FGBeacon::init() {
|
||||||
make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN,
|
make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN,
|
||||||
TRANSITION_BYTES );
|
TRANSITION_BYTES );
|
||||||
|
|
||||||
ptr = outer_buf.get();
|
ptr = (unsigned char*)outer_buf;
|
||||||
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
||||||
ptr += OUTER_DAH_LEN;
|
ptr += OUTER_DAH_LEN;
|
||||||
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
||||||
|
|
||||||
outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND );
|
outer = new SGSoundSample( &outer_buf, OUTER_SIZE, BYTES_PER_SECOND );
|
||||||
outer->set_reference_dist( 10.0 );
|
outer->set_reference_dist( 10.0 );
|
||||||
outer->set_max_dist( 20.0 );
|
outer->set_max_dist( 20.0 );
|
||||||
} catch ( sg_io_exception &e ) {
|
} catch ( sg_io_exception &e ) {
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
|
|
||||||
#include "morse.hxx"
|
#include "morse.hxx"
|
||||||
|
@ -221,10 +219,10 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
|
||||||
length += 2 * SPACE_SIZE;
|
length += 2 * SPACE_SIZE;
|
||||||
|
|
||||||
// 2. Allocate space for the message
|
// 2. Allocate space for the message
|
||||||
std::auto_ptr<unsigned char>buffer( new unsigned char[length] );
|
const unsigned char* buffer = (const unsigned char *)malloc(length);
|
||||||
|
|
||||||
// 3. Assemble the message;
|
// 3. Assemble the message;
|
||||||
unsigned char *buf_ptr = buffer.get();
|
unsigned char *buf_ptr = (unsigned char*)buffer;
|
||||||
|
|
||||||
for ( i = 0; i < (int)id.length(); ++i ) {
|
for ( i = 0; i < (int)id.length(); ++i ) {
|
||||||
if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
|
if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
|
||||||
|
@ -263,7 +261,7 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
|
||||||
buf_ptr += SPACE_SIZE;
|
buf_ptr += SPACE_SIZE;
|
||||||
|
|
||||||
// 4. create the simple sound and return
|
// 4. create the simple sound and return
|
||||||
SGSoundSample *sample = new SGSoundSample( buffer, length,
|
SGSoundSample *sample = new SGSoundSample( &buffer, length,
|
||||||
BYTES_PER_SECOND );
|
BYTES_PER_SECOND );
|
||||||
|
|
||||||
sample->set_reference_dist( 10.0 );
|
sample->set_reference_dist( 10.0 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue