]> sigrok.org Git - libsigrok.git/commitdiff
Enable loading of session files without the unit size defined
authorSoeren Apel <redacted>
Sun, 27 Mar 2016 20:55:19 +0000 (22:55 +0200)
committerUwe Hermann <redacted>
Sun, 27 Mar 2016 23:06:29 +0000 (01:06 +0200)
src/session_driver.c
src/session_file.c

index 0793104b0ccc63683c5120a5279fbb1a7fa4ead7..cfa1da9d2ac0beaf24c182bf0d1614e0a30e5395 100644 (file)
@@ -127,8 +127,13 @@ static gboolean stream_session_data(struct sr_dev_inst *sdi)
 
        buf = g_malloc(CHUNKSIZE);
 
-       ret = zip_fread(vdev->capfile, buf,
-                       CHUNKSIZE / vdev->unitsize * vdev->unitsize);
+       /* unitsize is not defined for purely analog session files. */
+       if (vdev->unitsize)
+               ret = zip_fread(vdev->capfile, buf,
+                               CHUNKSIZE / vdev->unitsize * vdev->unitsize);
+       else
+               ret = zip_fread(vdev->capfile, buf, CHUNKSIZE);
+
        if (ret > 0) {
                got_data = TRUE;
                if (vdev->cur_analog_channel != 0) {
index fd0dbd07309f98f315726c3b0930020c9c8f9e93..9b3712066678734d71eedee918d329408f71d752 100644 (file)
@@ -212,6 +212,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
        int unitsize;
        char **sections, **keys, *val;
        char channelname[SR_MAX_CHANNELNAME_LEN + 1];
+       gboolean file_has_logic;
 
        if ((ret = sr_sessionfile_check(filename)) != SR_OK)
                return ret;
@@ -235,6 +236,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
 
        error = NULL;
        ret = SR_OK;
+       file_has_logic = FALSE;
        sections = g_key_file_get_groups(kf, NULL);
        for (i = 0; sections[i] && ret == SR_OK; i++) {
                if (!strcmp(sections[i], "global"))
@@ -261,6 +263,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
                                sr_config_set(sdi, NULL, SR_CONF_CAPTUREFILE,
                                                g_variant_new_string(val));
                                g_free(val);
+                               file_has_logic = TRUE;
                        }
                        g_clear_error(&error);
 
@@ -277,7 +280,7 @@ SR_API int sr_session_load(struct sr_context *ctx, const char *filename,
                                        g_free(val);
                                        sr_config_set(sdi, NULL, SR_CONF_SAMPLERATE,
                                                        g_variant_new_uint64(tmp_u64));
-                               } else if (!strcmp(keys[j], "unitsize")) {
+                               } else if (!strcmp(keys[j], "unitsize") && file_has_logic) {
                                        unitsize = g_key_file_get_integer(kf, sections[i],
                                                        keys[j], &error);
                                        if (!sdi || unitsize <= 0 || error) {