return cached values in setters immediately if same as requested

standalone
Dimitri Stolnikov 10 years ago
parent a0b4f3b2c5
commit 40028422c0
  1. 40
      lib/sink_impl.cc
  2. 40
      lib/source_impl.cc

@ -254,11 +254,12 @@ double sink_impl::set_center_freq( double freq, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _center_freq[ chan ] != freq ) {
_center_freq[ chan ] = freq;
return dev->set_center_freq( freq, dev_chan );
}
} else { return _center_freq[ chan ]; }
}
return 0;
}
@ -279,11 +280,12 @@ double sink_impl::set_freq_corr( double ppm, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _freq_corr[ chan ] != ppm ) {
_freq_corr[ chan ] = ppm;
return dev->set_freq_corr( ppm, dev_chan );
}
} else { return _freq_corr[ chan ]; }
}
return 0;
}
@ -337,14 +339,15 @@ bool sink_impl::set_gain_mode( bool automatic, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _gain_mode[ chan ] != automatic ) {
_gain_mode[ chan ] = automatic;
bool mode = dev->set_gain_mode( automatic, dev_chan );
if (!automatic) // reapply gain value when switched to manual mode
dev->set_gain( _gain[ chan ], dev_chan );
return mode;
}
} else { return _gain_mode[ chan ]; }
}
return false;
}
@ -365,11 +368,12 @@ double sink_impl::set_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _gain[ chan ] != gain ) {
_gain[ chan ] = gain;
return dev->set_gain( gain, dev_chan );
}
} else { return _gain[ chan ]; }
}
return 0;
}
@ -412,11 +416,12 @@ double sink_impl::set_if_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _if_gain[ chan ] != gain ) {
_if_gain[ chan ] = gain;
return dev->set_if_gain( gain, dev_chan );
}
} else { return _if_gain[ chan ]; }
}
return 0;
}
@ -426,11 +431,12 @@ double sink_impl::set_bb_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _bb_gain[ chan ] != gain ) {
_bb_gain[ chan ] = gain;
return dev->set_bb_gain( gain, dev_chan );
}
} else { return _bb_gain[ chan ]; }
}
return 0;
}
@ -451,11 +457,12 @@ std::string sink_impl::set_antenna( const std::string & antenna, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _antenna[ chan ] != antenna ) {
_antenna[ chan ] = antenna;
return dev->set_antenna( antenna, dev_chan );
}
} else { return _antenna[ chan ]; }
}
return "";
}
@ -486,11 +493,12 @@ double sink_impl::set_bandwidth( double bandwidth, size_t chan )
size_t channel = 0;
BOOST_FOREACH( sink_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _bandwidth[ chan ] != bandwidth ) {
_bandwidth[ chan ] = bandwidth;
return dev->set_bandwidth( bandwidth, dev_chan );
}
} else { return _bandwidth[ chan ]; }
}
return 0;
}

@ -388,11 +388,12 @@ double source_impl::set_center_freq( double freq, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _center_freq[ chan ] != freq ) {
_center_freq[ chan ] = freq;
return dev->set_center_freq( freq, dev_chan );
}
} else { return _center_freq[ chan ]; }
}
return 0;
}
@ -413,11 +414,12 @@ double source_impl::set_freq_corr( double ppm, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _freq_corr[ chan ] != ppm ) {
_freq_corr[ chan ] = ppm;
return dev->set_freq_corr( ppm, dev_chan );
}
} else { return _freq_corr[ chan ]; }
}
return 0;
}
@ -471,14 +473,15 @@ bool source_impl::set_gain_mode( bool automatic, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _gain_mode[ chan ] != automatic ) {
_gain_mode[ chan ] = automatic;
bool mode = dev->set_gain_mode( automatic, dev_chan );
if (!automatic) // reapply gain value when switched to manual mode
dev->set_gain( _gain[ chan ], dev_chan );
return mode;
}
} else { return _gain_mode[ chan ]; }
}
return false;
}
@ -499,11 +502,12 @@ double source_impl::set_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _gain[ chan ] != gain ) {
_gain[ chan ] = gain;
return dev->set_gain( gain, dev_chan );
}
} else { return _gain[ chan ]; }
}
return 0;
}
@ -546,11 +550,12 @@ double source_impl::set_if_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _if_gain[ chan ] != gain ) {
_if_gain[ chan ] = gain;
return dev->set_if_gain( gain, dev_chan );
}
} else { return _if_gain[ chan ]; }
}
return 0;
}
@ -560,11 +565,12 @@ double source_impl::set_bb_gain( double gain, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _bb_gain[ chan ] != gain ) {
_bb_gain[ chan ] = gain;
return dev->set_bb_gain( gain, dev_chan );
}
} else { return _bb_gain[ chan ]; }
}
return 0;
}
@ -585,11 +591,12 @@ std::string source_impl::set_antenna( const std::string & antenna, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _antenna[ chan ] != antenna ) {
_antenna[ chan ] = antenna;
return dev->set_antenna( antenna, dev_chan );
}
} else { return _antenna[ chan ]; }
}
return "";
}
@ -668,11 +675,12 @@ double source_impl::set_bandwidth( double bandwidth, size_t chan )
size_t channel = 0;
BOOST_FOREACH( source_iface *dev, _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ )
if ( chan == channel++ ) {
if ( _bandwidth[ chan ] != bandwidth ) {
_bandwidth[ chan ] = bandwidth;
return dev->set_bandwidth( bandwidth, dev_chan );
}
} else { return _bandwidth[ chan ]; }
}
return 0;
}

Loading…
Cancel
Save