]> sigrok.org Git - libsigrok.git/blobdiff - session.c
sr: fx2lafw: Add basic support for USBee DX and clones
[libsigrok.git] / session.c
index 8fde4bf31a2421623459002f8614331ded818351..92ee648a631c77d41092beb3bf010f00c5537d30 100644 (file)
--- a/session.c
+++ b/session.c
@@ -74,8 +74,7 @@ SR_API int sr_session_destroy(void)
                return SR_ERR_BUG;
        }
 
-       g_slist_free(session->devs);
-       session->devs = NULL;
+       sr_session_dev_remove_all();
 
        /* TODO: Error checks needed? */
 
@@ -87,6 +86,12 @@ SR_API int sr_session_destroy(void)
        return SR_OK;
 }
 
+static void sr_dev_close(struct sr_dev *dev)
+{
+       if (dev && dev->driver && dev->driver->dev_close)
+               dev->driver->dev_close(dev->driver_index);
+}
+
 /**
  * Remove all the devices from the current session. TODO?
  *
@@ -102,7 +107,7 @@ SR_API int sr_session_dev_remove_all(void)
                return SR_ERR_BUG;
        }
 
-       g_slist_free(session->devs);
+       g_slist_free_full(session->devs, (GDestroyNotify)sr_dev_close);
        session->devs = NULL;
 
        return SR_OK;
@@ -316,22 +321,15 @@ SR_API int sr_session_run(void)
 /**
  * Halt the current session.
  *
- * This requests the current session be stopped as soon as possible, for
- * example on receiving an SR_DF_END packet.
+ * This function is deprecated and should not be used in new code, use
+ * sr_session_stop() instead. The behaviour of this function is identical to
+ * sr_session_stop().
  *
  * @return SR_OK upon success, SR_ERR_BUG if no session exists.
  */
 SR_API int sr_session_halt(void)
 {
-       if (!session) {
-               sr_err("session: %s: session was NULL", __func__);
-               return SR_ERR_BUG;
-       }
-
-       sr_info("session: halting");
-       session->running = FALSE;
-
-       return SR_OK;
+       return sr_session_stop();
 }
 
 /**
@@ -361,8 +359,6 @@ SR_API int sr_session_stop(void)
                if (dev->driver) {
                        if (dev->driver->dev_acquisition_stop)
                                dev->driver->dev_acquisition_stop(dev->driver_index, dev);
-                       if (dev->driver->cleanup)
-                               dev->driver->cleanup();
                }
        }