]> sigrok.org Git - libsigrok.git/blobdiff - input/vcd.c
mic-985xx: Adjust to GVariant-based sr_config_* functions
[libsigrok.git] / input / vcd.c
index 814988f7ae2c4aa7388d297a63b4d104a11c1c3b..d63d85ece3d6c0ad377c227bd6bff98fbca4aa78 100644 (file)
@@ -211,6 +211,7 @@ static void remove_empty_parts(gchar **parts)
  */
 static gboolean parse_header(FILE *file, struct context *ctx)
 {
+       uint64_t p, q;
        gchar *name = NULL, *contents = NULL;
        gboolean status = FALSE;
 
@@ -227,15 +228,14 @@ static gboolean parse_header(FILE *file, struct context *ctx)
                {
                        /* The standard allows for values 1, 10 or 100
                         * and units s, ms, us, ns, ps and fs. */
-                       struct sr_rational period;
-                       if (sr_parse_period(contents, &period) == SR_OK)
+                       if (sr_parse_period(contents, &p, &q) == SR_OK)
                        {
-                               ctx->samplerate = period.q / period.p;
-                               if (period.q % period.p != 0)
+                               ctx->samplerate = q / p;
+                               if (q % p != 0)
                                {
                                        /* Does not happen unless time value is non-standard */
                                        sr_warn("Inexact rounding of samplerate, %" PRIu64 " / %" PRIu64 " to %" PRIu64 " Hz.",
-                                               period.q, period.p, ctx->samplerate);
+                                               q, p, ctx->samplerate);
                                }
                                
                                sr_dbg("Samplerate: %" PRIu64, ctx->samplerate);
@@ -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);