analog save: Avoid index duplication between analog & logic channels.
This commit is contained in:
parent
1393bccfcb
commit
e5b280e4c7
|
@ -33,7 +33,7 @@ struct out_context {
|
|||
gboolean zip_created;
|
||||
uint64_t samplerate;
|
||||
char *filename;
|
||||
gint min_analog_index;
|
||||
gint analog_offset;
|
||||
};
|
||||
|
||||
static int init(struct sr_output *o, GHashTable *options)
|
||||
|
@ -67,6 +67,7 @@ static int zip_create(const struct sr_output *o)
|
|||
char *s, *metabuf;
|
||||
gsize metalen;
|
||||
guint logic_channels = 0, analog_channels = 0;
|
||||
gint min_analog_index;
|
||||
|
||||
outc = o->priv;
|
||||
|
||||
|
@ -105,7 +106,7 @@ 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;
|
||||
min_analog_index = -1;
|
||||
|
||||
for (l = o->sdi->channels; l; l = l->next) {
|
||||
ch = l->data;
|
||||
|
@ -114,14 +115,16 @@ static int zip_create(const struct sr_output *o)
|
|||
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;
|
||||
if (min_analog_index == -1 ||
|
||||
ch->index < min_analog_index)
|
||||
min_analog_index = ch->index;
|
||||
analog_channels++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
outc->analog_offset = logic_channels - min_analog_index + 1;
|
||||
|
||||
g_key_file_set_integer(meta, devgroup, "total probes", logic_channels);
|
||||
g_key_file_set_integer(meta, devgroup, "total analog", analog_channels);
|
||||
|
||||
|
@ -132,8 +135,7 @@ static int zip_create(const struct sr_output *o)
|
|||
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);
|
||||
s = g_strdup_printf("analog%d", ch->index + outc->analog_offset);
|
||||
break;
|
||||
}
|
||||
if (ch->enabled)
|
||||
|
@ -318,7 +320,7 @@ static int zip_append_analog(const struct sr_output *o,
|
|||
channel = analog->meaning->channels->data;
|
||||
|
||||
basename = g_strdup_printf("analog-1-%u",
|
||||
channel->index - outc->min_analog_index + 1);
|
||||
channel->index + outc->analog_offset);
|
||||
baselen = strlen(basename);
|
||||
next_chunk_num = 1;
|
||||
num_files = zip_get_num_entries(archive, 0);
|
||||
|
|
|
@ -113,7 +113,7 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi)
|
|||
sr_dbg("Opened %s.", capturefile);
|
||||
} else if (vdev->cur_analog_channel < vdev->num_analog_channels) {
|
||||
vdev->capturefile = g_strdup_printf("analog-1-%d",
|
||||
vdev->cur_analog_channel + 1);
|
||||
vdev->num_channels + vdev->cur_analog_channel + 1);
|
||||
vdev->cur_analog_channel++;
|
||||
vdev->cur_chunk = 0;
|
||||
return TRUE;
|
||||
|
|
|
@ -293,7 +293,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
|
|||
}
|
||||
sr_config_set(sdi, NULL, SR_CONF_NUM_ANALOG_CHANNELS,
|
||||
g_variant_new_int32(total_analog));
|
||||
for (k = 0; k < total_analog; k++) {
|
||||
for (k = total_channels; k < (total_channels + total_analog); k++) {
|
||||
g_snprintf(channelname, sizeof(channelname),
|
||||
"%d", k);
|
||||
sr_channel_new(sdi, k, SR_CHANNEL_ANALOG,
|
||||
|
|
Loading…
Reference in New Issue