更新 'src/Network/fgcom.cxx'

This commit is contained in:
zhongjin 2022-12-06 15:57:51 +08:00
parent b9269f6f21
commit f0e0978d7b

View File

@ -390,13 +390,13 @@ double FGCom::getCurrentCommVolume() const {
if (_speakerLevel_node) {
rv = rv * _speakerLevel_node->getFloatValue();
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _speakerLevel_node " << _speakerLevel_node->getFloatValue());
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _speakerLevel_node " << _speakerLevel_node->getFloatValue());
}
if (_commVolumeNode) {
//暂时关闭 _commVolumeNode
//rv = rv * _commVolumeNode->getFloatValue();
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _commVolumeNode " << _commVolumeNode->getFloatValue());
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: _commVolumeNode " << _commVolumeNode->getFloatValue());
}
return rv;
@ -407,7 +407,7 @@ double FGCom::getCurrentFrequencyKhz() const {
void FGCom::setupCommFrequency(int channel) {
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency1 channel=" << channel);
// SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency1 channel=" << channel);
if (channel < 1) {
if (_selected_comm_node != nullptr) {
@ -415,7 +415,7 @@ void FGCom::setupCommFrequency(int channel) {
}
}
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency2 channel=" << channel);
// SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency2 channel=" << channel);
// disconnect if channel set to 0
if (channel < 1) {
@ -453,7 +453,7 @@ void FGCom::setupCommFrequency(int channel) {
}
}
}
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: setupCommFrequency node listener failed: channel " << channel);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: setupCommFrequency node listener failed: channel " << channel);
}
SG_LOG(SG_SOUND, SG_ALERT, "setupCommFrequency3 _commFrequencyNode=" << _commFrequencyNode);
@ -497,7 +497,7 @@ void FGCom::connectToCommFrequency() {
iaxc_dump_call_number(_currentCallIdent);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom:iaxc_dump_call_number:" << _currentCallIdent);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom:iaxc_dump_call_number:" << _currentCallIdent);
_currentCallIdent = -1;
}
@ -510,7 +510,7 @@ void FGCom::connectToCommFrequency() {
if (!isInRange(_currentCommFrequency)) {
if (_currentCallIdent != -1) {
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: disconnect call as not in range " << _currentCallIdent);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: disconnect call as not in range " << _currentCallIdent);
if (_currentCallIdent != -1) {
iaxc_dump_call_number(_currentCallIdent);
_currentCallIdent = -1;
@ -519,19 +519,19 @@ void FGCom::connectToCommFrequency() {
return;
}
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num);
if (!num.empty()) {
lib_hangup();
_currentCallIdent = iaxc_call(num.c_str());
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
if (_currentCallIdent == -1)
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: cannot call " << num.c_str());
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: cannot call " << num.c_str());
else {
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
_currentCallFrequency = _currentCommFrequency;
_connected = true;
}
@ -622,18 +622,18 @@ void FGCom::valueChanged(SGPropertyNode *prop)
iaxc_input_level_set(0.0);
// iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
}
}
if (prop == _selected_comm_node && _enabled) {
setupCommFrequency();
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
}
if (prop == _commFrequencyNode && _enabled) {
setupCommFrequency();
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
}
if (prop == _ptt_node && _enabled) {
@ -644,13 +644,23 @@ 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_SOUND, SG_ALERT, "FGCom: PTT active: " << _currentCallFrequency);
SGPath soundpath( globals->get_fg_root() );
soundpath.append( "/Sounds/click.wav" );
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: PTT active: " << soundpath);
}
else {
// iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0);
iaxc_input_level_set(0.0);
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
// SG_LOG(SG_SOUND, SG_ALERT, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
_mpTransmitFrequencyNode->setValue(0);
_mpTransmitPowerNode->setValue(0);
}