]> sigrok.org Git - libsigrok.git/commitdiff
session: Auto-commit settings before acquisition.
authorDaniel Elstner <redacted>
Mon, 20 Jan 2014 22:04:49 +0000 (23:04 +0100)
committerBert Vermeulen <redacted>
Tue, 21 Jan 2014 12:09:51 +0000 (13:09 +0100)
(sr_session_start): Just before starting acquisition on
a device, call sr_config_commit() to apply pending config
changes to the hardware device.
(sr_session_dev_add): Ditto.  Also, return an error code
if starting acquisition failed.

session.c

index e1fb5cfb2bf00df9e600024365acb16a1a00c8ff..1a9343fe403dfbd103183588bd1a47655d28d3c7 100644 (file)
--- a/session.c
+++ b/session.c
@@ -176,12 +176,20 @@ SR_API int sr_session_dev_add(const struct sr_dev_inst *sdi)
        session->devs = g_slist_append(session->devs, (gpointer)sdi);
 
        if (session->running) {
-               /* Adding a device to a running session. Start acquisition
-                * on that device now. */
+               /* Adding a device to a running session. Commit settings
+                * and start acquisition on that device now. */
+               if ((ret = sr_config_commit(sdi)) != SR_OK) {
+                       sr_err("Failed to commit device settings before "
+                              "starting acquisition in running session (%s)",
+                              sr_strerror(ret));
+                       return ret;
+               }
                if ((ret = sdi->driver->dev_acquisition_start(sdi,
-                                               (void *)sdi)) != SR_OK)
+                                               (void *)sdi)) != SR_OK) {
                        sr_err("Failed to start acquisition of device in "
-                                       "running session: %d", ret);
+                              "running session (%s)", sr_strerror(ret));
+                       return ret;
+               }
        }
 
        return SR_OK;
@@ -354,6 +362,11 @@ SR_API int sr_session_start(void)
        ret = SR_OK;
        for (l = session->devs; l; l = l->next) {
                sdi = l->data;
+               if ((ret = sr_config_commit(sdi)) != SR_OK) {
+                       sr_err("Failed to commit device settings before "
+                              "starting acquisition (%s)", sr_strerror(ret));
+                       break;
+               }
                if ((ret = sdi->driver->dev_acquisition_start(sdi, sdi)) != SR_OK) {
                        sr_err("%s: could not start an acquisition "
                               "(%s)", __func__, sr_strerror(ret));