From: Bert Vermeulen Date: Tue, 1 Feb 2011 01:33:54 +0000 (+0100) Subject: don't just assume a device has a samplerate setting X-Git-Tag: libsigrok-0.1.0~354 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3a285098170ee6d5c7eab3fd94606e61a4fbaa19;p=libsigrok.git don't just assume a device has a samplerate setting --- diff --git a/output/output_analog.c b/output/output_analog.c index 40d52181..f00bffa3 100644 --- a/output/output_analog.c +++ b/output/output_analog.c @@ -133,7 +133,7 @@ static int init(struct sr_output *o, int default_spl, enum outputmode mode) snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); num_probes = g_slist_length(o->device->probes); - if (o->device->plugin) { + if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(samplerate_s = sr_samplerate_string(samplerate))) { diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 2945f949..440e848c 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -79,7 +79,7 @@ static int init(struct sr_output *o) num_probes = g_slist_length(o->device->probes); comment[0] = '\0'; - if (o->device->plugin) { + if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(frequency_s = sr_samplerate_string(samplerate))) { @@ -226,7 +226,7 @@ static int analog_init(struct sr_output *o) num_probes = g_slist_length(o->device->probes); comment[0] = '\0'; - if (o->device->plugin) { + if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(frequency_s = sr_samplerate_string(samplerate))) { diff --git a/output/output_ols.c b/output/output_ols.c index 6c4876d4..55230bf3 100644 --- a/output/output_ols.c +++ b/output/output_ols.c @@ -102,7 +102,7 @@ static int init(struct sr_output *o) /* TODO: Currently not available in the demo module. */ - if (o->device->plugin) { + if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(frequency_s = sr_samplerate_string(samplerate))) { diff --git a/output/output_vcd.c b/output/output_vcd.c index c6d1655d..f34eaa8c 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -91,7 +91,7 @@ static int init(struct sr_output *o) g_string_append_printf(ctx->header, "$version %s %s $end\n", PACKAGE, PACKAGE_VERSION); - if (o->device->plugin) { + if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) { diff --git a/output/text/text.c b/output/text/text.c index ded3adf1..da41b733 100644 --- a/output/text/text.c +++ b/output/text/text.c @@ -107,7 +107,7 @@ int init(struct sr_output *o, int default_spl, enum outputmode mode) snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); num_probes = g_slist_length(o->device->probes); - if (o->device->plugin) { + if (o->device->plugin || device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->device->plugin->get_device_info( o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); if (!(samplerate_s = sr_samplerate_string(samplerate))) {