source/sink_impl: query hardware for gains on init

Instead of guessing, query the device to populate _gain_mode and _gain.
This commit is contained in:
Ryan Tucker 2017-06-27 14:38:32 -04:00 committed by Eric Wild
parent f6a8992856
commit a343cc208b
2 changed files with 14 additions and 0 deletions

View File

@ -245,6 +245,13 @@ sink_impl::sink_impl( const std::string &args )
if (!_devs.size())
throw std::runtime_error("No devices specified via device arguments.");
/* Populate the _gain and _gain_mode arrays with the hardware state */
for ( sink_iface *dev : _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) {
_gain_mode[dev_chan] = dev->get_gain_mode(dev_chan);
_gain[dev_chan] = dev->get_gain(dev_chan);
}
}
size_t sink_impl::get_num_channels()

View File

@ -403,6 +403,13 @@ source_impl::source_impl( const std::string &args )
if (!_devs.size())
throw std::runtime_error("No devices specified via device arguments.");
/* Populate the _gain and _gain_mode arrays with the hardware state */
for ( source_iface *dev : _devs )
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) {
_gain_mode[dev_chan] = dev->get_gain_mode(dev_chan);
_gain[dev_chan] = dev->get_gain(dev_chan);
}
}
size_t source_impl::get_num_channels()