]> sigrok.org Git - libsigrok.git/commitdiff
Fixed session_driver so that it can run more than one session.
authorJoel Holdsworth <redacted>
Fri, 28 Feb 2014 18:51:57 +0000 (19:51 +0100)
committerJoel Holdsworth <redacted>
Sat, 1 Mar 2014 11:23:08 +0000 (11:23 +0000)
session_driver.c

index 69a53c6867102903fb22bee900b3eec652b348c9..f333db1df1ae9eab6e280123d6d674e363426c28 100644 (file)
@@ -115,7 +115,6 @@ static int receive_data(int fd, int revents, void *cb_data)
                                        sr_dbg("Opened %s.", capturefile);
                                } else {
                                        /* We got all the chunks, finish up. */
-                                       g_free(vdev->capturefile);
                                        vdev->finished = TRUE;
                                        continue;
                                }
@@ -147,7 +146,6 @@ static int receive_data(int fd, int revents, void *cb_data)
                        vdev->capfile = NULL;
                        if (vdev->cur_chunk == 0) {
                                /* It was the only file. */
-                               g_free(vdev->capturefile);
                                vdev->finished = TRUE;
                        } else {
                                /* There might be more chunks, so don't fall through
@@ -202,6 +200,10 @@ static int dev_open(struct sr_dev_inst *sdi)
 
 static int dev_close(struct sr_dev_inst *sdi)
 {
+       const struct session_vdev *const vdev = sdi->priv;
+       g_free(vdev->sessionfile);
+       g_free(vdev->capturefile);
+
        g_free(sdi->priv);
        sdi->priv = NULL;
 
@@ -245,10 +247,12 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                sr_info("Setting samplerate to %" PRIu64 ".", vdev->samplerate);
                break;
        case SR_CONF_SESSIONFILE:
+               g_free(vdev->sessionfile);
                vdev->sessionfile = g_strdup(g_variant_get_string(data, NULL));
                sr_info("Setting sessionfile to '%s'.", vdev->sessionfile);
                break;
        case SR_CONF_CAPTUREFILE:
+               g_free(vdev->capturefile);
                vdev->capturefile = g_strdup(g_variant_get_string(data, NULL));
                sr_info("Setting capturefile to '%s'.", vdev->capturefile);
                break;
@@ -290,6 +294,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 
        vdev = sdi->priv;
 
+       vdev->bytes_read = 0;
+       vdev->cur_chunk = 0;
+       vdev->finished = FALSE;
+
        sr_info("Opening archive %s file %s", vdev->sessionfile,
                vdev->capturefile);