Bugfix in order to make sr_session_stop() actually work.
authorUwe Hermann <uwe@hermann-uwe.de>
Wed, 25 Apr 2018 05:53:42 +0000 (07:53 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 25 Apr 2018 15:04:03 +0000 (17:04 +0200)
The sr_session_stop() calls were previously invoked with the session
pointer being NULL, which didn't actually stop the session. This could
lead to samples still being processed and (e.g.) passed to libsigrokdecode
for decoding, even though the session should have been stopped.

Fix this by passing the session pointer along in the
sr_session_datafeed_callback_add() function, so that the callbacks
can make use of it.

input.c
session.c

diff --git a/input.c b/input.c
index 62378ee0605143d01bdf339614015367afdd0401..6425146e2b45123facded53756af6ea3b7a2a58c 100644 (file)
--- a/input.c
+++ b/input.c
@@ -108,7 +108,7 @@ static void load_input_file_module(void)
                        g_critical("Error: no input module found for this file.");
        }
        sr_session_new(sr_ctx, &session);
-       sr_session_datafeed_callback_add(session, &datafeed_in, NULL);
+       sr_session_datafeed_callback_add(session, &datafeed_in, session);
 
        got_sdi = FALSE;
        while (TRUE) {
@@ -174,7 +174,7 @@ void load_input_file(void)
                        }
                        main_loop = g_main_loop_new(NULL, FALSE);
 
-                       sr_session_datafeed_callback_add(session, datafeed_in, NULL);
+                       sr_session_datafeed_callback_add(session, datafeed_in, session);
                        sr_session_stopped_callback_set(session,
                                (sr_session_stopped_callback)g_main_loop_quit,
                                main_loop);
index e692970d6b2cf70982ce66c4401a704f8b1fa498..4a3878a57507c1c81c6202f99e39907172b17fb5 100644 (file)
--- a/session.c
+++ b/session.c
@@ -582,7 +582,7 @@ void run_session(void)
        g_slist_free(real_devices);
 
        sr_session_new(sr_ctx, &session);
-       sr_session_datafeed_callback_add(session, datafeed_in, NULL);
+       sr_session_datafeed_callback_add(session, datafeed_in, session);
 
        if (sr_dev_open(sdi) != SR_OK) {
                g_critical("Failed to open device.");