]> sigrok.org Git - libsigrok.git/commitdiff
Removal of sdi->index, step 2: remove it from sr_session_load()
authorSoeren Apel <redacted>
Sat, 27 Sep 2014 20:26:06 +0000 (22:26 +0200)
committerBert Vermeulen <redacted>
Mon, 29 Sep 2014 23:42:58 +0000 (01:42 +0200)
src/session_file.c

index 9298abefc39e1fd1145d9beea7f60c2370bb995d..350cc3bda68b07517b84a3ac61cae3c871ba8aa3 100644 (file)
@@ -47,6 +47,8 @@
  */
 
 extern SR_PRIV struct sr_dev_driver session_driver;
+static int session_driver_initialized = 0;
+
 
 /** @private */
 SR_PRIV int sr_sessionfile_check(const char *filename)
@@ -121,7 +123,7 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
        struct zip_stat zs;
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
-       int devcnt, ret, i, j;
+       int ret, i, j;
        uint64_t tmp_u64, total_channels, enabled_channels, p;
        char **sections, **keys, *metafile, *val;
        char channelname[SR_MAX_CHANNELNAME_LEN + 1];
@@ -153,7 +155,6 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
        if ((ret = sr_session_new(session)) != SR_OK)
                return ret;
 
-       devcnt = 0;
        capturefiles = g_ptr_array_new_with_free_func(g_free);
        sections = g_key_file_get_groups(kf, NULL);
        for (i = 0; sections[i]; i++) {
@@ -168,11 +169,13 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
                        for (j = 0; keys[j]; j++) {
                                val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
                                if (!strcmp(keys[j], "capturefile")) {
-                                       sdi = sr_dev_inst_new(devcnt, SR_ST_ACTIVE, NULL, NULL, NULL);
+                                       sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
                                        sdi->driver = &session_driver;
-                                       if (devcnt == 0)
+                                       if (!session_driver_initialized) {
                                                /* first device, init the driver */
+                                               session_driver_initialized = 1;
                                                sdi->driver->init(NULL);
+                                       }
                                        sr_dev_open(sdi);
                                        sr_session_dev_add(*session, sdi);
                                        sdi->driver->config_set(SR_CONF_SESSIONFILE,
@@ -214,7 +217,6 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
                                for (p = enabled_channels; p < total_channels; p++)
                                        sr_dev_channel_enable(sdi, p, FALSE);
                }
-               devcnt++;
        }
        g_strfreev(sections);
        g_key_file_free(kf);