From: Uwe Hermann Date: Wed, 25 Apr 2018 05:53:42 +0000 (+0200) Subject: Bugfix in order to make sr_session_stop() actually work. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=49e9f06791d585fb112e9602946e9740f4cb3a74;p=sigrok-cli.git Bugfix in order to make sr_session_stop() actually work. 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. --- diff --git a/input.c b/input.c index 62378ee..6425146 100644 --- 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); diff --git a/session.c b/session.c index e692970..4a3878a 100644 --- 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.");