X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fdemo%2Fapi.c;h=bea35d068f63042a04fd7b27b6d691f3778ad0fb;hb=ecd4600bb15fc16d842936c452d4e7d5fb8e12f5;hp=3b77d40cdd36bf3f127c6bd90ef132f56204b050;hpb=f216309fd0576dfe5bad25fa91ade3db35d66a5f;p=libsigrok.git diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 3b77d40c..bea35d06 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -151,14 +151,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (num_logic_channels > 0) { /* Logic channels, all in one channel group. */ - cg = g_malloc0(sizeof(struct sr_channel_group)); - cg->name = g_strdup("Logic"); + cg = sr_channel_group_new(sdi, "Logic", NULL); for (i = 0; i < num_logic_channels; i++) { sprintf(channel_name, "D%d", i); ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); cg->channels = g_slist_append(cg->channels, ch); } - sdi->channel_groups = g_slist_append(NULL, cg); } /* Analog channels, channel groups and pattern generators. */ @@ -173,9 +171,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) pattern = 0; /* An "Analog" channel group with all analog channels in it. */ - acg = g_malloc0(sizeof(struct sr_channel_group)); - acg->name = g_strdup("Analog"); - sdi->channel_groups = g_slist_append(sdi->channel_groups, acg); + acg = sr_channel_group_new(sdi, "Analog", NULL); for (i = 0; i < num_analog_channels; i++) { snprintf(channel_name, 16, "A%d", i); @@ -184,10 +180,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) acg->channels = g_slist_append(acg->channels, ch); /* Every analog channel gets its own channel group as well. */ - cg = g_malloc0(sizeof(struct sr_channel_group)); - cg->name = g_strdup(channel_name); + cg = sr_channel_group_new(sdi, channel_name, NULL); cg->channels = g_slist_append(NULL, ch); - sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); /* Every channel gets a generator struct. */ ag = g_malloc(sizeof(struct analog_gen)); @@ -573,7 +567,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) std_session_send_df_header(sdi); if (devc->limit_frames > 0) - std_session_send_frame_begin(sdi); + std_session_send_df_frame_begin(sdi); /* We use this timestamp to decide how many more samples to send. */ devc->start_us = g_get_monotonic_time(); @@ -591,7 +585,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) devc = sdi->priv; if (devc->limit_frames > 0) - std_session_send_frame_end(sdi); + std_session_send_df_frame_end(sdi); std_session_send_df_end(sdi);