]> sigrok.org Git - libsigrok.git/blobdiff - src/output/srzip.c
output/srzip: Minor whitespace fixes.
[libsigrok.git] / src / output / srzip.c
index 7ee1bd9f457ee67a741d32521d70c9d57645c9d1..aa3c37577d33fbe17dbf576f79f8da9986017993 100644 (file)
@@ -33,6 +33,7 @@ struct out_context {
        gboolean zip_created;
        uint64_t samplerate;
        char *filename;
+       gint min_analog_index;
 };
 
 static int init(struct sr_output *o, GHashTable *options)
@@ -104,15 +105,20 @@ static int zip_create(const struct sr_output *o)
        g_key_file_set_string(meta, devgroup, "samplerate", s);
        g_free(s);
 
+       outc->min_analog_index = -1;
+
        for (l = o->sdi->channels; l; l = l->next) {
                ch = l->data;
                switch (ch->type) {
-                       case SR_CHANNEL_LOGIC:
-                               logic_channels++;
-                               break;
-                       case SR_CHANNEL_ANALOG:
-                               analog_channels++;
-                               break;
+               case SR_CHANNEL_LOGIC:
+                       logic_channels++;
+                       break;
+               case SR_CHANNEL_ANALOG:
+                       if (outc->min_analog_index == -1 ||
+                                       ch->index < outc->min_analog_index)
+                               outc->min_analog_index = ch->index;
+                       analog_channels++;
+                       break;
                }
        }
 
@@ -122,12 +128,13 @@ static int zip_create(const struct sr_output *o)
        for (l = o->sdi->channels; l; l = l->next) {
                ch = l->data;
                switch (ch->type) {
-                       case SR_CHANNEL_LOGIC:
-                               s = g_strdup_printf("probe%d", ch->index + 1);
-                               break;
-                       case SR_CHANNEL_ANALOG:
-                               s = g_strdup_printf("analog%d", ch->index + 1);
-                               break;
+               case SR_CHANNEL_LOGIC:
+                       s = g_strdup_printf("probe%d", ch->index + 1);
+                       break;
+               case SR_CHANNEL_ANALOG:
+                       s = g_strdup_printf("analog%d",
+                                       ch->index - outc->min_analog_index + 1);
+                       break;
                }
                if (ch->enabled)
                        g_key_file_set_string(meta, devgroup, s, ch->name);
@@ -310,7 +317,8 @@ static int zip_append_analog(const struct sr_output *o,
        }
        channel = analog->meaning->channels->data;
 
-       basename = g_strdup_printf("analog-1-%u", channel->index + 1);
+       basename = g_strdup_printf("analog-1-%u",
+                       channel->index - outc->min_analog_index + 1);
        baselen = strlen(basename);
        next_chunk_num = 1;
        num_files = zip_get_num_entries(archive, 0);