void SigSession::read_sample_rate(shared_ptr<Device> device)
{
- uint64_t sample_rate = VariantBase::cast_dynamic<Variant<guint64>>(
- device->config_get(ConfigKey::SAMPLERATE)).get();
+ const auto keys = device_->config_keys(ConfigKey::DEVICE_OPTIONS);
+ const auto iter = keys.find(ConfigKey::SAMPLERATE);
+ const uint64_t sample_rate = (iter != keys.end() &&
+ (*iter).second.find(sigrok::GET) != (*iter).second.end()) ?
+ VariantBase::cast_dynamic<Variant<guint64>>(
+ device->config_get(ConfigKey::SAMPLERATE)).get() : 0;
// Set the sample rate of all data
const set< shared_ptr<data::SignalData> > data_set = get_data();
set_capture_state(Running);
// Get sample limit.
- uint64_t sample_limit;
- try {
- sample_limit = VariantBase::cast_dynamic<Variant<guint64>>(
- device_->config_get(ConfigKey::LIMIT_SAMPLES)).get();
- } catch (Error) {
- sample_limit = 0;
- }
+ const auto keys = device_->config_keys(
+ ConfigKey::DEVICE_OPTIONS);
+ const auto iter = keys.find(ConfigKey::LIMIT_SAMPLES);
+ const uint64_t sample_limit = (iter != keys.end() &&
+ (*iter).second.find(sigrok::GET) !=
+ (*iter).second.end()) ?
+ VariantBase::cast_dynamic<Variant<guint64>>(
+ device_->config_get(ConfigKey::LIMIT_SAMPLES)).get() : 0;
// Create a new data snapshot
cur_logic_snapshot_ = shared_ptr<data::LogicSnapshot>(
assert(!updating_sample_rate_);
updating_sample_rate_ = true;
- try {
+ const auto keys = device->config_keys(ConfigKey::DEVICE_OPTIONS);
+ const auto iter = keys.find(ConfigKey::SAMPLERATE);
+ if (iter != keys.end() &&
+ (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
gvar_dict = device->config_list(ConfigKey::SAMPLERATE);
- } catch (Error error) {
+ } else {
sample_rate_.show_none();
updating_sample_rate_ = false;
return;
if (sample_count == 0)
sample_count = DefaultSampleCount;
- try {
+ const auto keys = device->config_keys(ConfigKey::DEVICE_OPTIONS);
+ const auto iter = keys.find(ConfigKey::LIMIT_SAMPLES);
+ if (iter != keys.end() &&
+ (*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
auto gvar = device->config_list(ConfigKey::LIMIT_SAMPLES);
g_variant_get(gvar.gobj(), "(tt)",
&min_sample_count, &max_sample_count);
- } catch (Error error) {}
+ }
min_sample_count = min(max(min_sample_count, MinSampleCount),
max_sample_count);