]> sigrok.org Git - libsigrok.git/commitdiff
Virtual session: Workaround for SR_CONF_CAPTUREFILE (#944)
authorSoeren Apel <redacted>
Sun, 21 May 2017 15:10:38 +0000 (17:10 +0200)
committerSoeren Apel <redacted>
Sun, 21 May 2017 15:10:38 +0000 (17:10 +0200)
This is a (hopefully temporary) workaround for the
SR_CONF_CAPTUREFILE mechanism. The value for
vdev->capturefile is set by this, however only once
via stream_session_data().
During stream processing in stream_session_data(),
capturefile may receive new values - e.g. when there
are multiple logic files or if there is analog data.
With that, the initially set capturefile is overwritten.

When re-loading the file, we are then running into
issues because we don't know what the initial value was.
As all .sr files use "logic-1" by default and, we
simulate the behavior of stream_session_data() and
assign this name to capturefile if there are logic
channels present.

With this change, all three kinds of files reload
as expected: logic only, analog only and mixed signal.
For this reason, it's a short-term fix for #944.

src/session_driver.c

index 285fa624d326cd47818ad348811f676aa272e7c3..684a7e539122418695be981fcc4fa21a9692172e 100644 (file)
@@ -124,7 +124,17 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi)
                        } else {
                                /* We got all the chunks, finish up. */
                                g_free(vdev->capturefile);
-                               vdev->capturefile = NULL;
+
+                               /* If the file has logic channels, the initial value for
+                                * capturefile is set by stream_session_data() - however only
+                                * once. In order to not mess this mechanism up, we simulate
+                                * this here if needed. For purely analog files, capturefile
+                                * is not set.
+                                */
+                               if (vdev->num_logic_channels)
+                                       vdev->capturefile = g_strdup("logic-1");
+                               else
+                                       vdev->capturefile = NULL;
                                return FALSE;
                        }
                }