]> sigrok.org Git - sigrok-cli.git/blobdiff - input.c
Bugfix in order to make sr_session_stop() actually work.
[sigrok-cli.git] / input.c
diff --git a/input.c b/input.c
index 21c28cd70a74467e665eab3440324b728e6402c9..6425146e2b45123facded53756af6ea3b7a2a58c 100644 (file)
--- a/input.c
+++ b/input.c
@@ -28,7 +28,7 @@
 #include <glib.h>
 #include "sigrok-cli.h"
 
-#define BUFSIZE (16 * 1024)
+#define CHUNK_SIZE (4 * 1024 * 1024)
 
 static void load_input_file_module(void)
 {
@@ -55,7 +55,7 @@ static void load_input_file_module(void)
        }
 
        fd = 0;
-       buf = g_string_sized_new(BUFSIZE);
+       buf = g_string_sized_new(CHUNK_SIZE);
        if (mod_id) {
                /* User specified an input module to use. */
                if (!(imod = sr_input_find(mod_id)))
@@ -98,7 +98,7 @@ static void load_input_file_module(void)
                                        g_critical("Failed to load %s: %s.", opt_input_file,
                                                        g_strerror(errno));
                        }
-                       if ((len = read(fd, buf->str, BUFSIZE)) < 1)
+                       if ((len = read(fd, buf->str, CHUNK_SIZE)) < 1)
                                g_critical("Failed to read %s: %s.", opt_input_file,
                                                g_strerror(errno));
                        buf->len = len;
@@ -108,12 +108,12 @@ 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) {
                g_string_truncate(buf, 0);
-               len = read(fd, buf->str, BUFSIZE);
+               len = read(fd, buf->str, CHUNK_SIZE);
                if (len < 0)
                        g_critical("Read failed: %s", g_strerror(errno));
                if (len == 0)
@@ -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);