diff options
author | Ryan Tucker <ryan.tucker@nuand.com> | 2017-06-27 14:39:56 -0400 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2018-08-15 19:53:26 +0200 |
commit | 07babe997d6149b3a6ca91521292fd65fe57f1e5 (patch) | |
tree | d0f069a93072f1e50413f270007e3c3ba6f856d9 /lib | |
parent | 3523097e0071b8c745d4d5d2a0143cdc3f7ffea1 (diff) |
bladerf_common: cleanup on set_gain_mode
Turns out that source/sink_impl already handle the AGC->MGC gain
preservation, so this was redundant and counterproductive.
Also DRY the code a bit.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bladerf/bladerf_common.cc | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index 9a56615..573e6ea 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -809,22 +809,11 @@ osmosdr::gain_range_t bladerf_common::get_gain_range( const std::string & name, bool bladerf_common::set_gain_mode( bool automatic, size_t chan ) { int ret = 0; + bladerf_gain_mode mode = automatic ? BLADERF_GAIN_DEFAULT : BLADERF_GAIN_MGC; - if (automatic) { - ret = bladerf_set_gain_mode( _dev.get(), - static_cast<bladerf_channel>(chan), - BLADERF_GAIN_DEFAULT ); - } else { - /* read the gain (presumably automatic), switch to MGC, then set the - * gain to that value to minimize surprise */ - double gain = get_gain(chan); - ret = bladerf_set_gain_mode( _dev.get(), - static_cast<bladerf_channel>(chan), - BLADERF_GAIN_MGC ); - if (!ret) { - set_gain(gain, chan); - } - } + ret = bladerf_set_gain_mode( _dev.get(), + static_cast<bladerf_channel>(chan), + mode ); if( ret ) { throw std::runtime_error( std::string(__FUNCTION__) + " " + |