Die if I/O Channel config fails for any reason.
Add an I/O Shutdown function call that explicitely closes all the open channels.
This commit is contained in:
parent
3dde95059d
commit
df31c5893e
4 changed files with 31 additions and 8 deletions
|
@ -210,7 +210,8 @@ void fgIOInit() {
|
||||||
p->open();
|
p->open();
|
||||||
global_io_list.push_back( p );
|
global_io_list.push_back( p );
|
||||||
if ( !p->is_enabled() ) {
|
if ( !p->is_enabled() ) {
|
||||||
FG_LOG( FG_IO, FG_INFO, "I/O Channel config failed." );
|
FG_LOG( FG_IO, FG_ALERT, "I/O Channel config failed." );
|
||||||
|
exit(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FG_LOG( FG_IO, FG_INFO, "I/O Channel parse failed." );
|
FG_LOG( FG_IO, FG_INFO, "I/O Channel parse failed." );
|
||||||
|
@ -253,3 +254,20 @@ void fgIOProcess() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// shutdown all I/O connections
|
||||||
|
void fgIOShutdownAll() {
|
||||||
|
FGProtocol *p;
|
||||||
|
|
||||||
|
// cout << "processing I/O channels" << endl;
|
||||||
|
|
||||||
|
for ( int i = 0; i < (int)global_io_list.size(); ++i ) {
|
||||||
|
// cout << " channel = " << i << endl;
|
||||||
|
p = global_io_list[i];
|
||||||
|
|
||||||
|
if ( p->is_enabled() ) {
|
||||||
|
p->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,4 +36,8 @@ void fgIOInit();
|
||||||
void fgIOProcess();
|
void fgIOProcess();
|
||||||
|
|
||||||
|
|
||||||
|
// shutdown all I/O connections
|
||||||
|
void fgIOShutdownAll();
|
||||||
|
|
||||||
|
|
||||||
#endif // _FG_IO_HXX
|
#endif // _FG_IO_HXX
|
||||||
|
|
|
@ -399,7 +399,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
// fclose( fg_DebugOutput );
|
// fclose( fg_DebugOutput );
|
||||||
// }
|
// }
|
||||||
FG_LOG( FG_INPUT, FG_ALERT,
|
FG_LOG( FG_INPUT, FG_ALERT,
|
||||||
"Program exiting normally at user request." );
|
"Program exit requested." );
|
||||||
ConfirmExitDialog();
|
ConfirmExitDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -962,7 +962,8 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
double rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() /
|
double rpm_factor = cur_fdm_state->get_engine(0)->get_RPM() /
|
||||||
2500.0;
|
2500.0;
|
||||||
cout << "rpm = " << cur_fdm_state->get_engine(0)->get_RPM() << endl;
|
// cout << "rpm = " << cur_fdm_state->get_engine(0)->get_RPM()
|
||||||
|
// << endl;
|
||||||
|
|
||||||
double pitch = 0.3 + rpm_factor * 3.0;
|
double pitch = 0.3 + rpm_factor * 3.0;
|
||||||
|
|
||||||
|
@ -970,19 +971,19 @@ static void fgMainLoop( void ) {
|
||||||
// and sounds bad to boot. :-)
|
// and sounds bad to boot. :-)
|
||||||
if (pitch < 0.7) { pitch = 0.7; }
|
if (pitch < 0.7) { pitch = 0.7; }
|
||||||
if (pitch > 5.0) { pitch = 5.0; }
|
if (pitch > 5.0) { pitch = 5.0; }
|
||||||
cout << "pitch = " << pitch << endl;
|
// cout << "pitch = " << pitch << endl;
|
||||||
|
|
||||||
double mp_factor =
|
double mp_factor =
|
||||||
cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 28;
|
cur_fdm_state->get_engine(0)->get_Manifold_Pressure() / 28;
|
||||||
cout << "mp = "
|
// cout << "mp = "
|
||||||
<< cur_fdm_state->get_engine(0)->get_Manifold_Pressure()
|
// << cur_fdm_state->get_engine(0)->get_Manifold_Pressure()
|
||||||
<< endl;
|
// << endl;
|
||||||
|
|
||||||
double volume = mp_factor;
|
double volume = mp_factor;
|
||||||
|
|
||||||
if ( volume < 0.3 ) { volume = 0.3; }
|
if ( volume < 0.3 ) { volume = 0.3; }
|
||||||
if ( volume > 2.0 ) { volume = 2.0; }
|
if ( volume > 2.0 ) { volume = 2.0; }
|
||||||
cout << "volume = " << volume << endl;
|
// cout << "volume = " << volume << endl;
|
||||||
|
|
||||||
pitch_envelope.setStep ( 0, 0.01, pitch );
|
pitch_envelope.setStep ( 0, 0.01, pitch );
|
||||||
volume_envelope.setStep ( 0, 0.01, volume );
|
volume_envelope.setStep ( 0, 0.01, volume );
|
||||||
|
|
Loading…
Reference in a new issue