更新 'src/Network/fgcom.cxx'

This commit is contained in:
zhongjin 2022-11-09 22:49:02 +08:00
parent fc8dbfa813
commit 26e03ff950

View File

@ -122,7 +122,7 @@ void FGCom::bind()
_micBoost_node = node->getChild( "mic-boost", 0, true ); _micBoost_node = node->getChild( "mic-boost", 0, true );
_micLevel_node = node->getChild( "mic-level", 0, true ); _micLevel_node = node->getChild( "mic-level", 0, true );
_silenceThd_node = node->getChild( "silence-threshold", 0, true ); _silenceThd_node = node->getChild( "silence-threshold", 0, true );
_speakerLevel_node = node->getChild( "speaker-level", 0, true ); _speakerLevel_node = node->getChild( "speaker-level", 1, true );
_selectedInput_node = node->getChild( "device-input", 0, true ); _selectedInput_node = node->getChild( "device-input", 0, true );
_selectedOutput_node = node->getChild( "device-output", 0, true ); _selectedOutput_node = node->getChild( "device-output", 0, true );
_showMessages_node = node->getChild( "show-messages", 0, true ); _showMessages_node = node->getChild( "show-messages", 0, true );
@ -324,7 +324,9 @@ void FGCom::postinit()
// Mute the mic and set speaker at start // Mute the mic and set speaker at start
iaxc_input_level_set( 0.0 ); iaxc_input_level_set( 0.0 );
iaxc_output_level_set(getCurrentCommVolume()); //iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0);
iaxc_millisleep(50); iaxc_millisleep(50);
@ -338,9 +340,11 @@ double FGCom::getCurrentCommVolume() const {
if (_speakerLevel_node) if (_speakerLevel_node)
rv = _speakerLevel_node->getFloatValue(); rv = _speakerLevel_node->getFloatValue();
SG_LOG(SG_SOUND, SG_INFO, "FGCom: _speakerLevel_node " << _speakerLevel_node->getFloatValue());
if (_commVolumeNode) if (_commVolumeNode)
rv = rv * _commVolumeNode->getFloatValue(); rv = rv * _commVolumeNode->getFloatValue();
SG_LOG(SG_SOUND, SG_INFO, "FGCom: _commVolumeNode " << _commVolumeNode->getFloatValue());
return rv; return rv;
} }
@ -374,6 +378,7 @@ void FGCom::setupCommFrequency(int channel) {
if (_commVolumeNode) if (_commVolumeNode)
_commVolumeNode->removeChangeListener(this); _commVolumeNode->removeChangeListener(this);
_commVolumeNode = commRadioNode->getChild("volume"); _commVolumeNode = commRadioNode->getChild("volume");
if (frequencyNode) { if (frequencyNode) {
frequencyNode = frequencyNode->getChild("selected-mhz"); frequencyNode = frequencyNode->getChild("selected-mhz");
if (frequencyNode) { if (frequencyNode) {
@ -426,6 +431,7 @@ void FGCom::connectToCommFrequency() {
if (_currentCallIdent == -1) if (_currentCallIdent == -1)
{ {
std::string num = computePhoneNumber(_currentCommFrequency, getAirportCode(_currentCommFrequency)); std::string num = computePhoneNumber(_currentCommFrequency, getAirportCode(_currentCommFrequency));
_processingTimer.stamp(); _processingTimer.stamp();
if (!isInRange(_currentCommFrequency)) { if (!isInRange(_currentCommFrequency)) {
if (_currentCallIdent != -1) { if (_currentCallIdent != -1) {
@ -552,9 +558,7 @@ void FGCom::valueChanged(SGPropertyNode *prop)
} }
else { else {
// iaxc_output_level_set(getCurrentCommVolume()); // iaxc_output_level_set(getCurrentCommVolume());
iaxc_output_level_set(1.0); iaxc_output_level_set(1.0);
iaxc_input_level_set(0.0); iaxc_input_level_set(0.0);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume()); SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
_mpTransmitFrequencyNode->setValue(0); _mpTransmitFrequencyNode->setValue(0);
@ -725,7 +729,7 @@ std::string FGCom::computePhoneNumber(const double& freq, const std::string& ica
_password.c_str(), _password.c_str(),
_server.c_str(), _server.c_str(),
exten); exten);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: computePhoneNumber:" << phoneNumber); SG_LOG(SG_SOUND, SG_INFO, "FGCom: computePhoneNumber:" << phoneNumber << "icao:" << icao);
return phoneNumber; return phoneNumber;
} }