From beb7dce53c9061f1f9440b209e83d2433229b72c Mon Sep 17 00:00:00 2001 From: zhongjin Date: Wed, 30 Nov 2022 20:18:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'src/Network/fgcom.cxx'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Network/fgcom.cxx | 49 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/Network/fgcom.cxx b/src/Network/fgcom.cxx index 4ee6df7..fbbf8ea 100644 --- a/src/Network/fgcom.cxx +++ b/src/Network/fgcom.cxx @@ -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; igetChild("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);