Fix segFault on reset by checking IAX has been initialized
This commit is contained in:
parent
0e5b794a4a
commit
a215bc0625
2 changed files with 15 additions and 8 deletions
|
@ -189,6 +189,9 @@ void FGCom::postinit()
|
||||||
iaxc_set_formats( IAXC_FORMAT_GSM, IAXC_FORMAT_GSM );
|
iaxc_set_formats( IAXC_FORMAT_GSM, IAXC_FORMAT_GSM );
|
||||||
iaxc_start_processing_thread ();
|
iaxc_start_processing_thread ();
|
||||||
|
|
||||||
|
// Now IAXClient is initialized
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
if ( _register ) {
|
if ( _register ) {
|
||||||
_regId = iaxc_register( const_cast<char*>(_username.c_str()),
|
_regId = iaxc_register( const_cast<char*>(_username.c_str()),
|
||||||
const_cast<char*>(_password.c_str()),
|
const_cast<char*>(_password.c_str()),
|
||||||
|
@ -320,7 +323,7 @@ void FGCom::updateCall(bool& changed, int& callNo, double freqMHz)
|
||||||
|
|
||||||
void FGCom::update(double dt)
|
void FGCom::update(double dt)
|
||||||
{
|
{
|
||||||
if ( !_enabled ) {
|
if ( !_enabled || !_initialized ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,6 +352,7 @@ void FGCom::shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG( SG_IO, SG_INFO, "FGCom shutdown()" );
|
SG_LOG( SG_IO, SG_INFO, "FGCom shutdown()" );
|
||||||
|
_initialized = false;
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
|
|
||||||
iaxc_unregister(_regId);
|
iaxc_unregister(_regId);
|
||||||
|
@ -388,7 +392,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
||||||
if (prop == _micBoost_node && _enabled) {
|
if (prop == _micBoost_node && _initialized) {
|
||||||
int micBoost = prop->getIntValue();
|
int micBoost = prop->getIntValue();
|
||||||
SG_LOG( SG_IO, SG_INFO, "FGCom mic-boost= " << micBoost );
|
SG_LOG( SG_IO, SG_INFO, "FGCom mic-boost= " << micBoost );
|
||||||
SG_CLAMP_RANGE<int>( micBoost, 0, 1 );
|
SG_CLAMP_RANGE<int>( micBoost, 0, 1 );
|
||||||
|
@ -397,7 +401,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
||||||
if ((prop == _selectedInput_node || prop == _selectedOutput_node) && _enabled) {
|
if ((prop == _selectedInput_node || prop == _selectedOutput_node) && _initialized) {
|
||||||
int selectedInput = _selectedInput_node->getIntValue();
|
int selectedInput = _selectedInput_node->getIntValue();
|
||||||
int selectedOutput = _selectedOutput_node->getIntValue();
|
int selectedOutput = _selectedOutput_node->getIntValue();
|
||||||
SG_LOG( SG_IO, SG_INFO, "FGCom selected-input= " << selectedInput );
|
SG_LOG( SG_IO, SG_INFO, "FGCom selected-input= " << selectedInput );
|
||||||
|
@ -469,7 +473,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||||
|
|
||||||
void FGCom::testMode(bool testMode)
|
void FGCom::testMode(bool testMode)
|
||||||
{
|
{
|
||||||
if(testMode) {
|
if(testMode && _initialized) {
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
iaxc_dump_call_number(_callComm0);
|
iaxc_dump_call_number(_callComm0);
|
||||||
iaxc_input_level_set( _micLevel_node->getFloatValue() );
|
iaxc_input_level_set( _micLevel_node->getFloatValue() );
|
||||||
|
@ -483,12 +487,14 @@ void FGCom::testMode(bool testMode)
|
||||||
if( _callComm0 == -1 )
|
if( _callComm0 == -1 )
|
||||||
SG_LOG( SG_IO, SG_ALERT, "FGCom cannot call selected freq (test mode)" );
|
SG_LOG( SG_IO, SG_ALERT, "FGCom cannot call selected freq (test mode)" );
|
||||||
} else {
|
} else {
|
||||||
|
if( _initialized ) {
|
||||||
iaxc_dump_call_number(_callComm0);
|
iaxc_dump_call_number(_callComm0);
|
||||||
iaxc_millisleep(IAX_DELAY);
|
iaxc_millisleep(IAX_DELAY);
|
||||||
_callComm0 = -1;
|
_callComm0 = -1;
|
||||||
_enabled = true;
|
_enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener
|
||||||
//bool _comm1Changed;
|
//bool _comm1Changed;
|
||||||
bool _register;
|
bool _register;
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
|
bool _initialized;
|
||||||
int _regId;
|
int _regId;
|
||||||
//int _callNav0;
|
//int _callNav0;
|
||||||
//int _callNav1;
|
//int _callNav1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue