更新 'src/Network/fgcom.cxx'
This commit is contained in:
parent
e834e998ec
commit
3df9fbcda0
@ -47,7 +47,7 @@
|
||||
#define MAX_RANGE 100.0
|
||||
#define MIN_RANGE 20.0
|
||||
#define MIN_GNDTWR_RANGE 0.0
|
||||
#define DEFAULT_SERVER "fgcom.jingweiht.com"
|
||||
#define DEFAULT_SERVER "fgcom.flightgear.org"
|
||||
#define IAX_DELAY 300 // delay between calls in milliseconds
|
||||
#define TEST_FREQ 910.00
|
||||
#define NULL_ICAO "ZZZZ"
|
||||
@ -326,9 +326,6 @@ void FGCom::postinit()
|
||||
iaxc_input_level_set( 0.0 );
|
||||
iaxc_output_level_set(getCurrentCommVolume());
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: Mute the mic and set speaker at start " << getCurrentCommVolume());
|
||||
|
||||
|
||||
iaxc_millisleep(50);
|
||||
|
||||
// Do the first call at start
|
||||
@ -345,8 +342,6 @@ double FGCom::getCurrentCommVolume() const {
|
||||
if (_commVolumeNode)
|
||||
rv = rv * _commVolumeNode->getFloatValue();
|
||||
|
||||
//zhongjin
|
||||
rv = 0.9;
|
||||
return rv;
|
||||
}
|
||||
double FGCom::getCurrentFrequencyKhz() const {
|
||||
@ -354,9 +349,6 @@ double FGCom::getCurrentFrequencyKhz() const {
|
||||
}
|
||||
|
||||
void FGCom::setupCommFrequency(int channel) {
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency " << channel);
|
||||
|
||||
if (channel < 1) {
|
||||
if (_selected_comm_node != nullptr) {
|
||||
channel = _selected_comm_node->getIntValue();
|
||||
@ -366,7 +358,7 @@ void FGCom::setupCommFrequency(int channel) {
|
||||
if (channel < 1) {
|
||||
if (_currentCallIdent != -1) {
|
||||
iaxc_dump_call_number(_currentCallIdent);
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: disconnect as channel 0 " << _currentCallIdent);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: disconnect as channel 0 " << _currentCallIdent);
|
||||
_currentCallIdent = -1;
|
||||
}
|
||||
_currentCommFrequency = 0.0;
|
||||
@ -397,21 +389,20 @@ void FGCom::setupCommFrequency(int channel) {
|
||||
}
|
||||
}
|
||||
}
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency node listener failed: channel " << channel);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: setupCommFrequency node listener failed: channel " << channel);
|
||||
}
|
||||
|
||||
if (_commFrequencyNode)
|
||||
_commFrequencyNode->removeChangeListener(this);
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: setupCommFrequency invalid channel " << channel);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: setupCommFrequency invalid channel " << channel);
|
||||
|
||||
_currentCommFrequency = 0.0;
|
||||
}
|
||||
|
||||
void FGCom::connectToCommFrequency() {
|
||||
|
||||
// ensure that the current comm is still in range
|
||||
if ((_currentCallFrequency > 0.0) && !isInRange(_currentCallFrequency)) {
|
||||
SG_LOG(SG_SOUND, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);
|
||||
SG_LOG(SG_IO, SG_WARN, "FGCom: call out of range of: " << _currentCallFrequency);
|
||||
_currentCallFrequency = 0.0;
|
||||
}
|
||||
|
||||
@ -428,7 +419,7 @@ void FGCom::connectToCommFrequency() {
|
||||
if (_currentCallFrequency != _currentCommFrequency || _currentCallIdent == -1) {
|
||||
if (_currentCallIdent != -1) {
|
||||
iaxc_dump_call_number(_currentCallIdent);
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: dump_call_number " << _currentCallIdent);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: dump_call_number " << _currentCallIdent);
|
||||
_currentCallIdent = -1;
|
||||
}
|
||||
|
||||
@ -438,7 +429,7 @@ void FGCom::connectToCommFrequency() {
|
||||
_processingTimer.stamp();
|
||||
if (!isInRange(_currentCommFrequency)) {
|
||||
if (_currentCallIdent != -1) {
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: disconnect call as not in range " << _currentCallIdent);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: disconnect call as not in range " << _currentCallIdent);
|
||||
if (_currentCallIdent != -1) {
|
||||
iaxc_dump_call_number(_currentCallIdent);
|
||||
_currentCallIdent = -1;
|
||||
@ -449,14 +440,14 @@ void FGCom::connectToCommFrequency() {
|
||||
if (!num.empty()) {
|
||||
_currentCallIdent = iaxc_call(num.c_str());
|
||||
if (_currentCallIdent == -1)
|
||||
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str());
|
||||
SG_LOG(SG_IO, SG_DEBUG, "FGCom: cannot call " << num.c_str());
|
||||
else {
|
||||
SG_LOG(SG_SOUND, SG_DEBUG, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
|
||||
SG_LOG(SG_IO, SG_DEBUG, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
|
||||
_currentCallFrequency = _currentCommFrequency;
|
||||
}
|
||||
}
|
||||
else
|
||||
SG_LOG(SG_SOUND, SG_WARN, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
|
||||
SG_LOG(SG_IO, SG_WARN, "FGCom: frequency " << _currentCommFrequency << " does not map to valid IAX address");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -491,15 +482,13 @@ void FGCom::shutdown()
|
||||
_initialized = false;
|
||||
_enabled = false;
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: shutdown" );
|
||||
|
||||
iaxc_set_event_callback(NULL);
|
||||
iaxc_unregister(_regId);
|
||||
iaxc_stop_processing_thread();
|
||||
iaxc_shutdown();
|
||||
|
||||
// added to help debugging lingering IAX thread after fgOSCloseWindow
|
||||
flightgear::addSentryBreadcrumb("Did shutdown FGCom", "info");
|
||||
// added to help debugging lingering IAX thread after fgOSCloseWindow
|
||||
flightgear::addSentryBreadcrumb("Did shutdown FGCom", "info");
|
||||
|
||||
assert( static_instance == this );
|
||||
static_instance = NULL;
|
||||
@ -529,34 +518,28 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||
}
|
||||
|
||||
if (prop == _commVolumeNode && _enabled) {
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _commVolumeNode" );
|
||||
|
||||
if (_ptt_node->getIntValue()) {
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: ignoring change comm volume as PTT pressed");
|
||||
SG_LOG(SG_IO, 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_SOUND, SG_INFO, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm volume=" << _commVolumeNode->getFloatValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (prop == _selected_comm_node && _enabled) {
|
||||
setupCommFrequency();
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm frequency (selected node): set to " << _currentCommFrequency);
|
||||
}
|
||||
|
||||
if (prop == _commFrequencyNode && _enabled) {
|
||||
setupCommFrequency();
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: change comm frequency (property updated): set to " << _currentCommFrequency);
|
||||
}
|
||||
|
||||
if (prop == _ptt_node && _enabled) {
|
||||
|
||||
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
|
||||
setupCommFrequency();
|
||||
@ -564,12 +547,12 @@ 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_INFO, "FGCom: PTT active: " << _currentCallFrequency);
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: PTT active: " << _currentCallFrequency);
|
||||
}
|
||||
else {
|
||||
iaxc_output_level_set(getCurrentCommVolume());
|
||||
iaxc_input_level_set(0.0);
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
|
||||
SG_LOG(SG_IO, SG_INFO, "FGCom: PTT release: " << _currentCallFrequency << " vol=" << getCurrentCommVolume());
|
||||
_mpTransmitFrequencyNode->setValue(0);
|
||||
_mpTransmitPowerNode->setValue(0);
|
||||
}
|
||||
@ -589,9 +572,6 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||
|
||||
//FIXME: not implemented in IAX audio driver (audio_openal.c)
|
||||
if (prop == _micBoost_node && _initialized) {
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _micBoost_node" );
|
||||
|
||||
int micBoost = prop->getIntValue();
|
||||
SG_CLAMP_RANGE<int>( micBoost, 0, 1 );
|
||||
iaxc_mic_boost_set( micBoost ) ; // 0 = enabled , 1 = disabled
|
||||
@ -600,9 +580,6 @@ 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_SOUND, SG_INFO, "FGCom: prop = _selectedInput_node _selectedOutput_node" );
|
||||
|
||||
int selectedInput = _selectedInput_node->getIntValue();
|
||||
int selectedOutput = _selectedOutput_node->getIntValue();
|
||||
iaxc_audio_devices_set(selectedInput, selectedOutput, 0);
|
||||
@ -615,20 +592,13 @@ void FGCom::valueChanged(SGPropertyNode *prop)
|
||||
_listener_active++;
|
||||
|
||||
if (prop == _speakerLevel_node && _enabled) {
|
||||
|
||||
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_SOUND, SG_INFO, "FGCom: speakerLevel " << speakerLevel );
|
||||
iaxc_output_level_set(speakerLevel);
|
||||
}
|
||||
|
||||
if (prop == _micLevel_node && _enabled) {
|
||||
|
||||
SG_LOG(SG_SOUND, SG_INFO, "FGCom: prop = _micLevel_node" );
|
||||
|
||||
float micLevel = prop->getFloatValue();
|
||||
SG_CLAMP_RANGE<float>( micLevel, 0.0, 1.0 );
|
||||
_micLevel_node->setFloatValue(micLevel);
|
||||
@ -653,7 +623,7 @@ void FGCom::testMode(bool testMode)
|
||||
_currentCallIdent = iaxc_call(num.c_str());
|
||||
}
|
||||
if( _currentCallIdent == -1 )
|
||||
SG_LOG( SG_SOUND, SG_DEBUG, "FGCom: cannot call " << num.c_str() );
|
||||
SG_LOG( SG_IO, SG_DEBUG, "FGCom: cannot call " << num.c_str() );
|
||||
} else {
|
||||
if( _initialized ) {
|
||||
iaxc_dump_all_calls();
|
||||
|
Loading…
Reference in New Issue
Block a user