commradio: refactor MetarSpeaker to AtisSpeaker
This commit is contained in:
parent
6ee2fcdd9e
commit
d5d88f2850
1 changed files with 16 additions and 16 deletions
|
@ -53,30 +53,30 @@ using simgear::PropertyObject;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
#if defined(ENABLE_FLITE)
|
#if defined(ENABLE_FLITE)
|
||||||
class MetarSpeaker: public SGPropertyChangeListener, SoundSampleReadyListener {
|
class AtisSpeaker: public SGPropertyChangeListener, SoundSampleReadyListener {
|
||||||
public:
|
public:
|
||||||
MetarSpeaker();
|
AtisSpeaker();
|
||||||
virtual ~MetarSpeaker();
|
virtual ~AtisSpeaker();
|
||||||
virtual void valueChanged(SGPropertyNode * node);
|
virtual void valueChanged(SGPropertyNode * node);
|
||||||
virtual void SoundSampleReady(SGSharedPtr<SGSoundSample>);
|
virtual void SoundSampleReady(SGSharedPtr<SGSoundSample>);
|
||||||
|
|
||||||
bool hasSpokenMetar() { return _spokenMetar.empty() == false; }
|
bool hasSpokenAtis() { return _spokenAtis.empty() == false; }
|
||||||
SGSharedPtr<SGSoundSample> getSpokenMetar() { return _spokenMetar.pop(); }
|
SGSharedPtr<SGSoundSample> getSpokenAtis() { return _spokenAtis.pop(); }
|
||||||
private:
|
private:
|
||||||
SynthesizeRequest _synthesizeRequest;
|
SynthesizeRequest _synthesizeRequest;
|
||||||
SGLockedQueue<SGSharedPtr<SGSoundSample> > _spokenMetar;
|
SGLockedQueue<SGSharedPtr<SGSoundSample> > _spokenAtis;
|
||||||
};
|
};
|
||||||
|
|
||||||
MetarSpeaker::MetarSpeaker()
|
AtisSpeaker::AtisSpeaker()
|
||||||
{
|
{
|
||||||
_synthesizeRequest.listener = this;
|
_synthesizeRequest.listener = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetarSpeaker::~MetarSpeaker()
|
AtisSpeaker::~AtisSpeaker()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void MetarSpeaker::valueChanged(SGPropertyNode * node)
|
void AtisSpeaker::valueChanged(SGPropertyNode * node)
|
||||||
{
|
{
|
||||||
string newText = node->getStringValue();
|
string newText = node->getStringValue();
|
||||||
if (_synthesizeRequest.text == newText) return;
|
if (_synthesizeRequest.text == newText) return;
|
||||||
|
@ -92,10 +92,10 @@ void MetarSpeaker::valueChanged(SGPropertyNode * node)
|
||||||
synthesizer->synthesize(_synthesizeRequest);
|
synthesizer->synthesize(_synthesizeRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetarSpeaker::SoundSampleReady(SGSharedPtr<SGSoundSample> sample)
|
void AtisSpeaker::SoundSampleReady(SGSharedPtr<SGSoundSample> sample)
|
||||||
{
|
{
|
||||||
// we are now in the synthesizers worker thread!
|
// we are now in the synthesizers worker thread!
|
||||||
_spokenMetar.push(sample);
|
_spokenAtis.push(sample);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ private:
|
||||||
int _num;
|
int _num;
|
||||||
MetarBridgeRef _metarBridge;
|
MetarBridgeRef _metarBridge;
|
||||||
#if defined(ENABLE_FLITE)
|
#if defined(ENABLE_FLITE)
|
||||||
MetarSpeaker _metarSpeaker;
|
AtisSpeaker _atisSpeaker;
|
||||||
#endif
|
#endif
|
||||||
FrequencyFormatter _useFrequencyFormatter;
|
FrequencyFormatter _useFrequencyFormatter;
|
||||||
FrequencyFormatter _stbyFrequencyFormatter;
|
FrequencyFormatter _stbyFrequencyFormatter;
|
||||||
|
@ -363,7 +363,7 @@ void CommRadioImpl::bind()
|
||||||
{
|
{
|
||||||
_metarBridge->setAtisNode(_atis.node());
|
_metarBridge->setAtisNode(_atis.node());
|
||||||
#if defined(ENABLE_FLITE)
|
#if defined(ENABLE_FLITE)
|
||||||
_atis.node()->addChangeListener( &_metarSpeaker );
|
_atis.node()->addChangeListener( &_atisSpeaker );
|
||||||
#endif
|
#endif
|
||||||
// link the metar node. /environment/metar[3] is comm1 and /environment[4] is comm2.
|
// link the metar node. /environment/metar[3] is comm1 and /environment[4] is comm2.
|
||||||
// see FGDATA/Environment/environment.xml
|
// see FGDATA/Environment/environment.xml
|
||||||
|
@ -374,7 +374,7 @@ void CommRadioImpl::bind()
|
||||||
void CommRadioImpl::unbind()
|
void CommRadioImpl::unbind()
|
||||||
{
|
{
|
||||||
#if defined(ENABLE_FLITE)
|
#if defined(ENABLE_FLITE)
|
||||||
_atis.node()->removeChangeListener( &_metarSpeaker );
|
_atis.node()->removeChangeListener( &_atisSpeaker );
|
||||||
#endif
|
#endif
|
||||||
_metarBridge->unbind();
|
_metarBridge->unbind();
|
||||||
}
|
}
|
||||||
|
@ -450,8 +450,8 @@ void CommRadioImpl::update(double dt)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_FLITE)
|
#if defined(ENABLE_FLITE)
|
||||||
if( _metarSpeaker.hasSpokenMetar() ) {
|
if( _atisSpeaker.hasSpokenAtis() ) {
|
||||||
SGSharedPtr<SGSoundSample> sample = _metarSpeaker.getSpokenMetar();
|
SGSharedPtr<SGSoundSample> sample = _atisSpeaker.getSpokenAtis();
|
||||||
SGSoundMgr * _smgr = globals->get_soundmgr();
|
SGSoundMgr * _smgr = globals->get_soundmgr();
|
||||||
SGSampleGroup * _sgr = _smgr->find("comm", true );
|
SGSampleGroup * _sgr = _smgr->find("comm", true );
|
||||||
_sgr->tie_to_listener();
|
_sgr->tie_to_listener();
|
||||||
|
|
Loading…
Add table
Reference in a new issue