+const void* DeviceOptions::enum_getter(
+ const struct sr_dev_inst *sdi, int key)
+{
+ const void *data = NULL;
+ if (sr_config_get(sdi->driver, key, &data, sdi) != SR_OK) {
+ qDebug() <<
+ "WARNING: Failed to get value of config id" << key;
+ return NULL;
+ }
+ return data;
+}
+
+double DeviceOptions::samplerate_value_getter(
+ const struct sr_dev_inst *sdi)
+{
+ uint64_t *samplerate = NULL;
+ if (sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
+ (const void**)&samplerate, sdi) != SR_OK) {
+ qDebug() <<
+ "WARNING: Failed to get value of sample rate";
+ return 0.0;
+ }
+ return (double)*samplerate;
+}
+
+void DeviceOptions::samplerate_value_setter(
+ struct sr_dev_inst *sdi, double value)
+{
+ uint64_t samplerate = value;
+ if (sr_config_set(sdi, SR_CONF_SAMPLERATE,
+ &samplerate) != SR_OK)
+ qDebug() <<
+ "WARNING: Failed to set value of sample rate";
+}
+
+const void* DeviceOptions::samplerate_list_getter(
+ const struct sr_dev_inst *sdi)
+{
+ const struct sr_samplerates *samplerates;
+ uint64_t *samplerate = NULL;
+
+ if (sr_config_list(sdi->driver, SR_CONF_SAMPLERATE,
+ (const void **)&samplerates, sdi) != SR_OK) {
+ qDebug() <<
+ "WARNING: Failed to get enumerate sample rates";
+ return NULL;
+ }
+
+ if (sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
+ (const void**)&samplerate, sdi) != SR_OK ||
+ !samplerate) {
+ qDebug() <<
+ "WARNING: Failed to get value of sample rate";
+ return NULL;
+ }
+
+ for (const uint64_t *rate = samplerates->list; *rate; rate++)
+ if (*rate == *samplerate)
+ return (const void*)rate;
+
+ return NULL;
+}
+
+void DeviceOptions::samplerate_list_setter(
+ struct sr_dev_inst *sdi, const void *value)
+{
+ if (sr_config_set(sdi, SR_CONF_SAMPLERATE,
+ (uint64_t*)value) != SR_OK)
+ qDebug() <<
+ "WARNING: Failed to set value of sample rate";
+}
+