static void cleanup(struct sr_input *in)
{
- struct context *inc;
+ g_free(in->priv);
+ in->priv = NULL;
- inc = in->priv;
g_variant_unref(options[0].def);
g_variant_unref(options[1].def);
g_variant_unref(options[2].def);
g_slist_free_full(options[2].values, (GDestroyNotify)g_variant_unref);
- g_free(inc);
- in->priv = NULL;
}
static int reset(struct sr_input *in)
struct context *inc = in->priv;
inc->started = FALSE;
- cleanup(in);
+
g_string_truncate(in->buf, 0);
return SR_OK;
int num_channels;
int unitsize;
gboolean found_data;
+ gboolean create_channels;
};
static int parse_wav_header(GString *buf, struct context *inc)
static int init(struct sr_input *in, GHashTable *options)
{
+ struct context *inc;
+
(void)options;
in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
in->priv = g_malloc0(sizeof(struct context));
+ inc = in->priv;
+
+ inc->create_channels = TRUE;
return SR_OK;
}
else if (ret != SR_OK)
return ret;
- for (int i = 0; i < inc->num_channels; i++) {
- snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
- sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
+ if (inc->create_channels) {
+ for (int i = 0; i < inc->num_channels; i++) {
+ snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
+ }
}
+ inc->create_channels = FALSE;
+
/* sdi is ready, notify frontend. */
in->sdi_ready = TRUE;
return SR_OK;
static int reset(struct sr_input *in)
{
- struct context *inc = in->priv;
+ memset(in->priv, 0, sizeof(struct context));
+
+ /*
+ * We only want to create the sigrok channels once, so
+ * inc->create_channels won't be set to TRUE this time around.
+ */
- inc->started = FALSE;
g_string_truncate(in->buf, 0);
return SR_OK;