更新 'src/Network/fgcom.cxx'

This commit is contained in:
2022-11-30 20:18:22 +08:00
parent 6785b8a22e
commit beb7dce53c

View File

@@ -48,7 +48,9 @@
#define MIN_RANGE 20.0
#define MIN_GNDTWR_RANGE 0.0
#define DEFAULT_SERVER "fgcom.jingweiht.com"
#define IAX_DELAY 300 // delay between calls in milliseconds
#define TEST_FREQ 910.00
#define NULL_ICAO "ZZZZ"
@@ -75,6 +77,10 @@ static int iaxc_callback( iaxc_event e )
default:
return 0;
}
//zhongjin
SG_LOG(SG_SOUND, SG_INFO, std::string{"FCCom IAX:"} + text.message);
return 1;
}
@@ -219,12 +225,20 @@ void FGCom::init()
_maxRange = MAX_RANGE;
_minRange = MIN_RANGE;
SG_LOG(SG_IO, SG_ALERT, "FGCom: ---------------------------------------");
}
void FGCom::postinit()
{
SG_LOG(SG_IO, SG_ALERT, "FGCom: 1111111111111111111111111111111111111");
if( !_enabled ) {
return;
}
@@ -242,6 +256,7 @@ void FGCom::postinit()
// FIXME: To be implemented in IAX audio driver
//iaxc_mic_boost_set( _micBoost_node->getIntValue() );
std::string app = "FGFS-";
app += _version_node->getStringValue();
@@ -256,12 +271,19 @@ void FGCom::postinit()
iaxc_set_speex_settings(1, 5, 0, 1, 0, 3);
//iaxc_set_filters(IAXC_FILTER_AGC | IAXC_FILTER_DENOISE);
//iaxc_set_silence_threshold(_silenceThd_node->getFloatValue());
/*
void iaxc_set_speex_settings(int decode_enhance, float quality,
int bitrate, int vbr, int abr, int complexity)
*/
iaxc_set_filters(IAXC_FILTER_AGC | IAXC_FILTER_DENOISE);
iaxc_set_silence_threshold(_silenceThd_node->getFloatValue());
iaxc_start_processing_thread ();
// Now IAXClient is initialized
_initialized = true;
if ( _register ) {
@@ -300,9 +322,16 @@ void FGCom::postinit()
iaxc_audio_devices_get(&devs,&nDevs, &input, &output, &ring);
//zhongjin
SG_LOG(SG_SOUND, SG_INFO, "设备总数:" << nDevs);
for(int i=0; i<nDevs; i++ ) {
SGPropertyNode *in_node = node->getChild("device", i, true);
//zhongjin
SG_LOG(SG_SOUND, SG_INFO, "设备:" << i);
// devID
_deviceID_node[i] = in_node->getChild("id", 0, true);
_deviceID_node[i]->setIntValue(devs[i].devID);
@@ -340,9 +369,6 @@ void FGCom::postinit()
iaxc_millisleep(50);
//zhongjin
iaxc_millisleep(500);
// Do the first call at start
setupCommFrequency();
@@ -380,11 +406,17 @@ double FGCom::getCurrentFrequencyKhz() const {
}
void FGCom::setupCommFrequency(int channel) {
SG_LOG(SG_SOUND, SG_INFO, "setupCommFrequency1 channel=" << channel);
if (channel < 1) {
if (_selected_comm_node != nullptr) {
channel = _selected_comm_node->getIntValue();
}
}
SG_LOG(SG_SOUND, SG_INFO, "setupCommFrequency2 channel=" << channel);
// disconnect if channel set to 0
if (channel < 1) {
if (_currentCallIdent != -1) {
@@ -424,8 +456,11 @@ void FGCom::setupCommFrequency(int channel) {
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency node listener failed: channel " << channel);
}
SG_LOG(SG_SOUND, SG_INFO, "setupCommFrequency3 _commFrequencyNode=" << _commFrequencyNode);
if (_commFrequencyNode)
_commFrequencyNode->removeChangeListener(this);
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency invalid channel " << channel);
_currentCommFrequency = 0.0;
@@ -434,6 +469,10 @@ void FGCom::setupCommFrequency(int channel) {
void FGCom::connectToCommFrequency() {
// ensure that the current comm is still in range
//zhongjin
SG_LOG(SG_SOUND, SG_INFO, "FGCom: connectToCommFrequency()");
SG_LOG(SG_SOUND, SG_INFO, "FGCom: _currentCallFrequency=" << _currentCallFrequency);
if ((_currentCallFrequency > 0.0) && !isInRange(_currentCallFrequency)) {
SG_LOG(SG_SOUND, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);