- g_key_file_set_integer(meta, devgroup, "total probes", logic_channels);
- g_key_file_set_integer(meta, devgroup, "total analog", analog_channels);
+ /* When reading the file, the first index of the analog channels
+ * can only be deduced through the "total probes" count, so the
+ * first analog index must follow the last logic one, enabled or not. */
+ if (enabled_logic_channels > 0)
+ outc->first_analog_index = logic_channels + 1;
+ else
+ outc->first_analog_index = 1;
+
+ /* Only set capturefile and probes if we will actually save logic data. */
+ if (enabled_logic_channels > 0) {
+ g_key_file_set_string(meta, devgroup, "capturefile", "logic-1");
+ g_key_file_set_integer(meta, devgroup, "total probes", logic_channels);
+ }
+
+ s = sr_samplerate_string(outc->samplerate);
+ g_key_file_set_string(meta, devgroup, "samplerate", s);
+ g_free(s);
+
+ g_key_file_set_integer(meta, devgroup, "total analog", enabled_analog_channels);
+
+ /* Make the array one entry larger than needed so we can use the final
+ * entry as terminator, which is set to -1. */
+ outc->analog_index_map = g_malloc0(sizeof(gint) * (enabled_analog_channels + 1));
+ outc->analog_index_map[enabled_analog_channels] = -1;