X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Ftoolbars%2Fsamplingbar.cpp;h=15eaf3b488d481f5fd5b1a6e599a692332093518;hb=df3c1aa3b358de058efa677fd0d51ca54da97bcd;hp=914083c3c0a50ea1968caffa21cd8ee23e9ad248;hpb=d99dc9f29066fba8948f1fca8b18a54b33064837;p=pulseview.git diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 914083c..15eaf3b 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -54,6 +54,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _sample_rate("Hz", this), _updating_sample_rate(false), _updating_sample_count(false), + _sample_count_supported(false), _icon_red(":/icons/status-red.svg"), _icon_green(":/icons/status-green.svg"), _icon_grey(":/icons/status-grey.svg"), @@ -203,26 +204,43 @@ void SamplingBar::update_sample_count_selector() { sr_dev_inst *const sdi = get_selected_device(); GVariant *gvar; - uint64_t samplecount; + uint64_t samplecount = 0; assert(sdi); - if (sr_config_get(sdi->driver, sdi, NULL, - SR_CONF_LIMIT_SAMPLES, &gvar) != SR_OK) + _sample_count_supported = false; + + if (sr_config_list(sdi->driver, sdi, NULL, + SR_CONF_DEVICE_OPTIONS, &gvar) == SR_OK) { - _sample_count.show_none(); + gsize num_opts; + const int *const options = (const int32_t *)g_variant_get_fixed_array( + gvar, &num_opts, sizeof(int32_t)); + for (unsigned int i = 0; i < num_opts; i++) + { + if (options[i] == SR_CONF_LIMIT_SAMPLES) + { + _sample_count_supported = true; + break; + } + } } - else - { + + if (_sample_count_supported) _sample_count.show_min_max_step(0, UINT64_MAX, 1); + else + _sample_count.show_none(); + if (sr_config_get(sdi->driver, sdi, NULL, + SR_CONF_LIMIT_SAMPLES, &gvar) == SR_OK) + { samplecount = g_variant_get_uint64(gvar); g_variant_unref(gvar); - - _updating_sample_count = true; - _sample_count.set_value(samplecount); - _updating_sample_count = false; } + + _updating_sample_count = true; + _sample_count.set_value(samplecount); + _updating_sample_count = false; } void SamplingBar::commit_sample_count() @@ -268,12 +286,6 @@ void SamplingBar::on_device_selected() if (_updating_device_selector) return; - update_sample_count_selector(); - update_sample_rate_selector(); - - if (_sample_count.value() == 0) - _sample_count.set_value(DefaultRecordLength); - sr_dev_inst *const sdi = get_selected_device(); _session.set_device(sdi); @@ -286,6 +298,15 @@ void SamplingBar::on_device_selected() // Update the probes popup Probes *const probes = new Probes(_session, this); _probes_button.set_popup(probes); + + // Update sweep timing widgets. + update_sample_count_selector(); + update_sample_rate_selector(); + + if (_sample_count_supported && _sample_count.value() == 0) { + _sample_count.set_value(DefaultRecordLength); + commit_sample_count(); + } } void SamplingBar::on_sample_count_changed()