X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fwav.c;h=611878e850495f79342cb0b4091c61d2dc9b50d4;hb=f3f19d1131025b68d29a11273b627c83d748e7ea;hp=3bdd12f0c77356775aa49ebe2dc520af844e65b7;hpb=7066fd466038bb4a8d09751f8a53c2452c5fefc1;p=libsigrok.git diff --git a/src/input/wav.c b/src/input/wav.c index 3bdd12f0..611878e8 100644 --- a/src/input/wav.c +++ b/src/input/wav.c @@ -73,7 +73,6 @@ static int parse_wav_header(GString *buf, struct context *inc) return SR_ERR_DATA; } - if (fmt_code == WAVE_FORMAT_PCM) { } else if (fmt_code == WAVE_FORMAT_IEEE_FLOAT) { if (unitsize != 4) { @@ -150,7 +149,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; @@ -161,7 +160,7 @@ static int find_data_chunk(GString *buf, int initial_offset) unsigned int offset, i; offset = initial_offset; - while(offset < MIN(MAX_DATA_CHUNK_OFFSET, buf->len)) { + while (offset < MIN(MAX_DATA_CHUNK_OFFSET, buf->len)) { if (!memcmp(buf->str + offset, "data", 4)) /* Skip into the samples. */ return offset + 8; @@ -240,7 +239,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 +248,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 +335,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,10 +362,10 @@ 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, .receive = receive, .end = end, }; -