]> sigrok.org Git - libsigrok.git/commitdiff
input/output modules: Adjust to GVariant-based sr_config_* functions
authorBert Vermeulen <redacted>
Mon, 25 Mar 2013 19:27:26 +0000 (20:27 +0100)
committerBert Vermeulen <redacted>
Thu, 11 Apr 2013 16:32:06 +0000 (18:32 +0200)
input/binary.c
input/chronovu_la8.c
input/vcd.c
input/wav.c
output/chronovu_la8.c
output/csv.c
output/gnuplot.c
output/ols.c
output/text/text.c
output/vcd.c

index 67d42f021c8626a332030b0e8b28b2be50744675..8484a80e24ff81ef4c0ede192b2a7af324bf1750 100644 (file)
@@ -121,9 +121,11 @@ static int loadfile(struct sr_input *in, const char *filename)
        if (ctx->samplerate) {
                packet.type = SR_DF_META;
                packet.payload = &meta;
-               src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&ctx->samplerate);
+               src = sr_config_new(SR_CONF_SAMPLERATE,
+                               g_variant_new_uint64(ctx->samplerate));
                meta.config = g_slist_append(NULL, src);
                sr_session_send(in->sdi, &packet);
+               sr_config_free(src);
        }
 
        /* Chop up the input file into chunks & send it to the session bus. */
index a78f356034968d2d5037b06255bbe1ba3df89aa6..e8aef290833f729a8bf08cb58e050511b38b2131 100644 (file)
@@ -172,9 +172,10 @@ static int loadfile(struct sr_input *in, const char *filename)
        /* Send metadata about the SR_DF_LOGIC packets to come. */
        packet.type = SR_DF_META;
        packet.payload = &meta;
-       src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&samplerate);
+       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
        meta.config = g_slist_append(NULL, src);
        sr_session_send(in->sdi, &packet);
+       sr_config_free(src);
 
        /* TODO: Handle trigger point. */
 
index 814988f7ae2c4aa7388d297a63b4d104a11c1c3b..102c1bd07666db3ecc05d58064e726b667975a0b 100644 (file)
@@ -571,9 +571,10 @@ static int loadfile(struct sr_input *in, const char *filename)
        packet.type = SR_DF_META;
        packet.payload = &meta;
        samplerate = ctx->samplerate / ctx->downsample;
-       src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&samplerate);
+       src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
        meta.config = g_slist_append(NULL, src);
        sr_session_send(in->sdi, &packet);
+       sr_config_free(src);
 
        /* Parse the contents of the VCD file */
        parse_contents(file, in->sdi, ctx);
index 7cd75067797746e2ad97119f34266cf39795fda7..593f6fca7a59b331907c5c6c489acfe802692341 100644 (file)
@@ -148,9 +148,11 @@ static int loadfile(struct sr_input *in, const char *filename)
 
        packet.type = SR_DF_META;
        packet.payload = &meta;
-       src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&ctx->samplerate);
+       src = sr_config_new(SR_CONF_SAMPLERATE,
+                       g_variant_new_uint64(ctx->samplerate));
        meta.config = g_slist_append(NULL, src);
        sr_session_send(in->sdi, &packet);
+       sr_config_free(src);
 
        if ((fd = open(filename, O_RDONLY)) == -1)
                return SR_ERR;
index f5da904a230f18a6819542f2419fc1391c7b8338..625d839be1b1e8a48e6b0657004eeb44b21d907a 100644 (file)
@@ -94,7 +94,7 @@ static int init(struct sr_output *o)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
-       uint64_t *samplerate;
+       GVariant *gvar;
 
        if (!o) {
                sr_warn("%s: o was NULL", __func__);
@@ -129,9 +129,9 @@ static int init(struct sr_output *o)
        ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
 
        if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
-               o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-               ctx->samplerate = *samplerate;
+               o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+               ctx->samplerate = g_variant_get_uint64(gvar);
+               g_variant_unref(gvar);
        } else
                ctx->samplerate = 0;
 
index e2901efbc8f5205fcff1a5ef2299e3ef47a6a991..844ca4fe8f7aaefe1bf4cff8e8b77eb773b78376 100644 (file)
@@ -60,8 +60,8 @@ static int init(struct sr_output *o)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
+       GVariant *gvar;
        int num_probes;
-       uint64_t *samplerate;
        time_t t;
        unsigned int i;
 
@@ -100,9 +100,9 @@ static int init(struct sr_output *o)
        num_probes = g_slist_length(o->sdi->probes);
 
        if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
-               o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-               ctx->samplerate = *samplerate;
+               o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+               ctx->samplerate = g_variant_get_uint64(gvar);
+               g_variant_unref(gvar);
        } else
                ctx->samplerate = 0;
 
index 965138984a594c7981a4fa8eb2cae660b6eda5cd..a871bd3e785a1bdaac454442409dc29f875a3ae8 100644 (file)
@@ -63,7 +63,8 @@ static int init(struct sr_output *o)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
-       uint64_t *samplerate;
+       GVariant *gvar;
+       uint64_t samplerate;
        unsigned int i;
        int b, num_probes;
        char *c, *frequency_s;
@@ -99,7 +100,7 @@ static int init(struct sr_output *o)
        o->internal = ctx;
        ctx->num_enabled_probes = 0;
        for (l = o->sdi->probes; l; l = l->next) {
-               probe = l->data; /* TODO: Error checks. */
+               probe = l->data;
                if (!probe->enabled)
                        continue;
                ctx->probelist[ctx->num_enabled_probes++] = probe->name;
@@ -109,18 +110,21 @@ static int init(struct sr_output *o)
 
        num_probes = g_slist_length(o->sdi->probes);
        comment[0] = '\0';
+       samplerate = 0;
        if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
-               o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-               if (!(frequency_s = sr_samplerate_string(*samplerate))) {
+               o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+               samplerate = g_variant_get_uint64(gvar);
+               if (!(frequency_s = sr_samplerate_string(samplerate))) {
                        sr_err("%s: sr_samplerate_string failed", __func__);
                        g_free(ctx->header);
                        g_free(ctx);
+                       g_variant_unref(gvar);
                        return SR_ERR;
                }
                snprintf(comment, 127, gnuplot_header_comment,
                        ctx->num_enabled_probes, num_probes, frequency_s);
                g_free(frequency_s);
+               g_variant_unref(gvar);
        }
 
        /* Columns / channels */
@@ -130,7 +134,7 @@ static int init(struct sr_output *o)
                sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
        }
 
-       if (!(frequency_s = sr_period_string(*samplerate))) {
+       if (!(frequency_s = sr_period_string(samplerate))) {
                sr_err("%s: sr_period_string failed", __func__);
                g_free(ctx->header);
                g_free(ctx);
index 97694b8f7e282e9ba25605c3c1f9c6b499e38ba9..c3b5799c7d9709a50f951ecd42462089f2abbc72 100644 (file)
@@ -51,7 +51,8 @@ static int init(struct sr_output *o)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
-       uint64_t *samplerate, tmp;
+       GVariant *gvar;
+       uint64_t samplerate;
        int num_enabled_probes;
 
        if (!(ctx = g_try_malloc(sizeof(struct context)))) {
@@ -69,16 +70,16 @@ static int init(struct sr_output *o)
        }
        ctx->unitsize = (num_enabled_probes + 7) / 8;
 
-       if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE))
-               o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-       else {
-               tmp = 0;
-               samplerate = &tmp;
+       if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
+               o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+               samplerate = g_variant_get_uint64(gvar);
+               g_variant_unref(gvar);
+       } else {
+               samplerate = 0;
        }
 
        ctx->header = g_string_sized_new(512);
-       g_string_append_printf(ctx->header, ";Rate: %"PRIu64"\n", *samplerate);
+       g_string_append_printf(ctx->header, ";Rate: %"PRIu64"\n", samplerate);
        g_string_append_printf(ctx->header, ";Channels: %d\n", num_enabled_probes);
        g_string_append_printf(ctx->header, ";EnabledChannels: -1\n");
        g_string_append_printf(ctx->header, ";Compressed: true\n");
index 71526b10e50d610323d3c4089cc8bebf585e2178..31bf3989eb4e77d5d5ca05e1fafe67dbfa735965 100644 (file)
@@ -79,7 +79,8 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
-       uint64_t *samplerate;
+       GVariant *gvar;
+       uint64_t samplerate;
        int num_probes, ret;
        char *samplerate_s;
 
@@ -124,12 +125,13 @@ SR_PRIV 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->sdi->probes);
        if (o->sdi->driver || sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
-               ret = o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-               if (ret != SR_OK)
+               if ((ret = o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar,
+                               o->sdi)) != SR_OK)
                        goto err;
-               if (!(samplerate_s = sr_samplerate_string(*samplerate))) {
+               samplerate = g_variant_get_uint64(gvar);
+               if (!(samplerate_s = sr_samplerate_string(samplerate))) {
                        ret = SR_ERR;
+                       g_variant_unref(gvar);
                        goto err;
                }
                snprintf(ctx->header + strlen(ctx->header),
@@ -137,6 +139,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
                         "Acquisition with %d/%d probes at %s\n",
                         ctx->num_enabled_probes, num_probes, samplerate_s);
                g_free(samplerate_s);
+               g_variant_unref(gvar);
        }
 
        ctx->linebuf_len = ctx->samples_per_line * 2 + 4;
index b60890ae63627bcafe38a1fb3b3826641f6f84a7..829fcde7722e5d05b2b91a8d4590c72237d91ab4 100644 (file)
@@ -53,7 +53,7 @@ static int init(struct sr_output *o)
        struct context *ctx;
        struct sr_probe *probe;
        GSList *l;
-       uint64_t *samplerate;
+       GVariant *gvar;
        int num_probes, i;
        char *samplerate_s, *frequency_s, *timestamp;
        time_t t;
@@ -93,17 +93,18 @@ static int init(struct sr_output *o)
                        PACKAGE, PACKAGE_VERSION);
 
        if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
-               o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
-                               (const void **)&samplerate, o->sdi);
-               ctx->samplerate = *samplerate;
+               o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+               ctx->samplerate = g_variant_get_uint64(gvar);
                if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
                        g_string_free(ctx->header, TRUE);
                        g_free(ctx);
+                       g_variant_unref(gvar);
                        return SR_ERR;
                }
                g_string_append_printf(ctx->header, vcd_header_comment,
                                 ctx->num_enabled_probes, num_probes, samplerate_s);
                g_free(samplerate_s);
+               g_variant_unref(gvar);
        }
 
        /* timescale */