更新 'src/Network/fgcom.cxx'

This commit is contained in:
zhongjin 2022-10-22 15:42:31 +08:00
parent 191749bf7b
commit fc8724f97b

View File

@ -326,7 +326,7 @@ void FGCom::postinit()
iaxc_input_level_set( 0.0 );
iaxc_output_level_set(getCurrentCommVolume());
SG_LOG(SG_IO, SG_INFO, "FGCom: Mute the mic and set speaker at start " << getCurrentCommVolume());
SG_LOG(SG_SOUND, SG_INFO, "FGCom: Mute the mic and set speaker at start " << getCurrentCommVolume());
iaxc_millisleep(50);
@ -394,12 +394,12 @@ void FGCom::setupCommFrequency(int channel) {
}
}
}
SG_LOG(SG_IO, SG_INFO, "FGCom: setupCommFrequency node listener failed: channel " << channel);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency node listener failed: channel " << channel);
}
if (_commFrequencyNode)
_commFrequencyNode->removeChangeListener(this);
SG_LOG(SG_IO, SG_INFO, "FGCom: setupCommFrequency invalid channel " << channel);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency invalid channel " << channel);
_currentCommFrequency = 0.0;
}
@ -408,7 +408,7 @@ void FGCom::connectToCommFrequency() {
// ensure that the current comm is still in range
if ((_currentCallFrequency > 0.0) && !isInRange(_currentCallFrequency)) {
SG_LOG(SG_IO, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);
SG_LOG(SG_SOUND, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);
_currentCallFrequency = 0.0;
}
@ -425,7 +425,7 @@ void FGCom::connectToCommFrequency() {
if (_currentCallFrequency != _currentCommFrequency || _currentCallIdent == -1) {
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
SG_LOG(SG_IO, SG_INFO, "FGCom: dump_call_number " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: dump_call_number " << _currentCallIdent);
_currentCallIdent = -1;
}
@ -435,7 +435,7 @@ void FGCom::connectToCommFrequency() {
_processingTimer.stamp();
if (!isInRange(_currentCommFrequency)) {
if (_currentCallIdent != -1) {
SG_LOG(SG_IO, SG_INFO, "FGCom: disconnect call as not in range " << _currentCallIdent);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: disconnect call as not in range " << _currentCallIdent);
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
_currentCallIdent = -1;
@ -446,14 +446,14 @@ void FGCom::connectToCommFrequency() {
if (!num.empty()) {
_currentCallIdent = iaxc_call(num.c_str());
if (_currentCallIdent == -1)
SG_LOG(SG_IO, SG_DEBUG, "FGCom: cannot call " << num.c_str());
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str());
else {
SG_LOG(SG_IO, SG_DEBUG, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
_currentCallFrequency = _currentCommFrequency;
}
}
else
SG_LOG(SG_IO, SG_WARN, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
SG_LOG(SG_SOUND, SG_WARN, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
}
}
}
@ -488,7 +488,7 @@ void FGCom::shutdown()
_initialized = false;
_enabled = false;
SG_LOG(SG_IO, SG_INFO, "FGCom: shutdown" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: shutdown" );
iaxc_set_event_callback(NULL);
iaxc_unregister(_regId);
@ -527,32 +527,32 @@ void FGCom::valueChanged(SGPropertyNode *prop)
if (prop == _commVolumeNode && _enabled) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _commVolumeNode" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _commVolumeNode" );
if (_ptt_node->getIntValue()) {
SG_LOG(SG_IO, SG_INFO, "FGCom: ignoring change comm volume as PTT pressed");
SG_LOG(SG_SOUND, SG_INFO, "FGCom: ignoring change comm volume as PTT pressed");
}
else
{
iaxc_input_level_set(0.0);
iaxc_output_level_set(getCurrentCommVolume());
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
}
}
if (prop == _selected_comm_node && _enabled) {
setupCommFrequency();
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
}
if (prop == _commFrequencyNode && _enabled) {
setupCommFrequency();
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
}
if (prop == _ptt_node && _enabled) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _ptt_node" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _ptt_node" );
if (_ptt_node->getIntValue()) {
// ensure that we are on the right channel by calling setupCommFrequency
@ -561,13 +561,13 @@ void FGCom::valueChanged(SGPropertyNode *prop)
iaxc_input_level_set(_micLevel_node->getFloatValue()); //0.0 = min , 1.0 = max
_mpTransmitFrequencyNode->setValue(_currentCallFrequency * 1000000);
_mpTransmitPowerNode->setValue(1.0);
SG_LOG(SG_IO, SG_INFO, "FGCom: PTT active: " << _currentCallFrequency);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT active: " << _currentCallFrequency);
}
else {
//iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(0.9);
iaxc_input_level_set(0.0);
SG_LOG(SG_IO, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
_mpTransmitFrequencyNode->setValue(0);
_mpTransmitPowerNode->setValue(0);
}
@ -588,7 +588,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
//FIXME: not implemented in IAX audio driver (audio_openal.c)
if (prop == _micBoost_node && _initialized) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _micBoost_node" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _micBoost_node" );
int micBoost = prop->getIntValue();
SG_CLAMP_RANGE<int>( micBoost, 0, 1 );
@ -599,7 +599,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
//FIXME: not implemented in IAX audio driver (audio_openal.c)
if ((prop == _selectedInput_node || prop == _selectedOutput_node) && _initialized) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _selectedInput_node _selectedOutput_node" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _selectedInput_node _selectedOutput_node" );
int selectedInput = _selectedInput_node->getIntValue();
int selectedOutput = _selectedOutput_node->getIntValue();
@ -614,18 +614,18 @@ void FGCom::valueChanged(SGPropertyNode *prop)
if (prop == _speakerLevel_node && _enabled) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _speakerLevel_node" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _speakerLevel_node" );
float speakerLevel = prop->getFloatValue();
SG_CLAMP_RANGE<float>( speakerLevel, 0.0, 1.0 );
_speakerLevel_node->setFloatValue(speakerLevel);
//iaxc_output_level_set(speakerLevel);
SG_LOG(SG_IO, SG_INFO, "FGCom: speakerLevel " << speakerLevel );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: speakerLevel " << speakerLevel );
}
if (prop == _micLevel_node && _enabled) {
SG_LOG(SG_IO, SG_INFO, "FGCom: prop = _micLevel_node" );
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _micLevel_node" );
float micLevel = prop->getFloatValue();
SG_CLAMP_RANGE<float>( micLevel, 0.0, 1.0 );
@ -651,7 +651,7 @@ void FGCom::testMode(bool testMode)
_currentCallIdent = iaxc_call(num.c_str());
}
if( _currentCallIdent == -1 )
SG_LOG( SG_IO, SG_DEBUG, "FGCom: cannot call " << num.c_str() );
SG_LOG( SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str() );
} else {
if( _initialized ) {
iaxc_dump_all_calls();