]> sigrok.org Git - libsigrok.git/blobdiff - src/input/wav.c
Simplify channel creation.
[libsigrok.git] / src / input / wav.c
index 3bdd12f0c77356775aa49ebe2dc520af844e65b7..0c23010eb6f7c5f1dab218356c54c1cf80a4a212 100644 (file)
@@ -150,7 +150,7 @@ static int init(struct sr_input *in, GHashTable *options)
 {
        (void)options;
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = g_malloc0(sizeof(struct sr_dev_inst));
        in->priv = g_malloc0(sizeof(struct context));
 
        return SR_OK;
@@ -240,7 +240,6 @@ static int process_buffer(struct sr_input *in)
        struct context *inc;
        struct sr_datafeed_packet packet;
        struct sr_datafeed_meta meta;
-       struct sr_channel *ch;
        struct sr_config *src;
        int offset, chunk_samples, total_samples, processed, max_chunk_samples;
        int num_samples, i;
@@ -250,8 +249,7 @@ static int process_buffer(struct sr_input *in)
        if (!inc->started) {
                for (i = 0; i < inc->num_channels; i++) {
                        snprintf(channelname, 8, "CH%d", i + 1);
-                       ch = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, channelname);
-                       in->sdi->channels = g_slist_append(in->sdi->channels, ch);
+                       sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
                }
 
                std_session_send_df_header(in->sdi, LOG_PREFIX);
@@ -338,7 +336,7 @@ static int receive(struct sr_input *in, GString *buf)
 
        ret = process_buffer(in);
 
-       return SR_OK;
+       return ret;
 }
 
 static int end(struct sr_input *in)
@@ -365,6 +363,7 @@ SR_PRIV struct sr_input_module input_wav = {
        .id = "wav",
        .name = "WAV",
        .desc = "WAV file",
+       .exts = (const char*[]){"wav", NULL},
        .metadata = { SR_INPUT_META_HEADER | SR_INPUT_META_REQUIRED },
        .format_match = format_match,
        .init = init,