Pigeon:
Avoid crashes if there is no sound device.
This commit is contained in:
parent
9e61446d12
commit
aecfc1a229
2 changed files with 15 additions and 2 deletions
|
@ -2299,7 +2299,13 @@ MK_VIII::VoicePlayer::get_sample (const char *name)
|
||||||
std::ostringstream refname;
|
std::ostringstream refname;
|
||||||
refname << mk->name << "[" << mk->num << "]" << "/" << name;
|
refname << mk->name << "[" << mk->num << "]" << "/" << name;
|
||||||
|
|
||||||
SGSoundSample *sample = globals->get_soundmgr()->find(refname.str());
|
SGSoundMgr *soundmgr = globals->get_soundmgr();
|
||||||
|
if (soundmgr->is_working() == false)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SGSoundSample *sample = soundmgr->find(refname.str());
|
||||||
if (! sample)
|
if (! sample)
|
||||||
{
|
{
|
||||||
SGPath sample_path(globals->get_fg_root());
|
SGPath sample_path(globals->get_fg_root());
|
||||||
|
@ -2316,7 +2322,7 @@ MK_VIII::VoicePlayer::get_sample (const char *name)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
globals->get_soundmgr()->add(sample, refname.str());
|
soundmgr->add(sample, refname.str());
|
||||||
samples[refname.str()] = sample;
|
samples[refname.str()] = sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,10 @@ FGFX::update (double dt)
|
||||||
{
|
{
|
||||||
SGSoundMgr *smgr = globals->get_soundmgr();
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
|
|
||||||
|
if (smgr->is_working() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// command sound manger
|
// command sound manger
|
||||||
bool pause = _pause->getBoolValue();
|
bool pause = _pause->getBoolValue();
|
||||||
if ( pause != last_pause ) {
|
if ( pause != last_pause ) {
|
||||||
|
@ -189,6 +193,9 @@ FGFX::play_message( SGSoundSample *_sample )
|
||||||
void
|
void
|
||||||
FGFX::play_message( const string path, const string fname )
|
FGFX::play_message( const string path, const string fname )
|
||||||
{
|
{
|
||||||
|
if (globals->get_soundmgr()->is_working() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SGSoundSample *sample;
|
SGSoundSample *sample;
|
||||||
sample = new SGSoundSample( path.c_str(), fname.c_str() );
|
sample = new SGSoundSample( path.c_str(), fname.c_str() );
|
||||||
play_message( sample );
|
play_message( sample );
|
||||||
|
|
Loading…
Add table
Reference in a new issue