]> sigrok.org Git - libsigrok.git/blobdiff - src/input/wav.c
drivers/input: Remove some hardcoded values.
[libsigrok.git] / src / input / wav.c
index 186693047f123088b74790ab9d1c275ae4be34b2..a1751243f467729c8ee7b2dbc61f3ca753906fc9 100644 (file)
@@ -31,7 +31,7 @@
 #define LOG_PREFIX "input/wav"
 
 /* How many bytes at a time to process and send to the session bus. */
-#define CHUNK_SIZE 4096
+#define CHUNK_SIZE               4096
 
 /* Minimum size of header + 1 8-bit mono PCM sample. */
 #define MIN_DATA_CHUNK_OFFSET    45
@@ -197,7 +197,7 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples)
 
        s = in->buf->str + offset;
        d = (char *)fdata;
-       memset(fdata, 0, CHUNK_SIZE);
+       memset(fdata, 0, CHUNK_SIZE * sizeof(float));
        total_samples = num_samples * inc->num_channels;
        for (samplenum = 0; samplenum < total_samples; samplenum++) {
                if (inc->fmt_code == WAVE_FORMAT_PCM_) {
@@ -227,7 +227,8 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples)
                d += inc->unitsize;
        }
 
-       sr_analog_init(&analog, &encoding, &meaning, &spec, 0);
+       /* TODO: Use proper 'digits' value for this device (and its modes). */
+       sr_analog_init(&analog, &encoding, &meaning, &spec, 2);
        packet.type = SR_DF_ANALOG;
        packet.payload = &analog;
        analog.num_samples = num_samples;
@@ -330,7 +331,7 @@ static int receive(struct sr_input *in, GString *buf)
                        return ret;
 
                for (int i = 0; i < inc->num_channels; i++) {
-                       snprintf(channelname, 8, "CH%d", i + 1);
+                       snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
                        sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
                }