X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=input.c;h=6425146e2b45123facded53756af6ea3b7a2a58c;hp=9a9545f22997b1c3b1a48b7b357261bc0d0aaf38;hb=49e9f06791d585fb112e9602946e9740f4cb3a74;hpb=a8229cd0e1683a8b028768c97c2fce141c7edd20 diff --git a/input.c b/input.c index 9a9545f..6425146 100644 --- a/input.c +++ b/input.c @@ -28,7 +28,7 @@ #include #include "sigrok-cli.h" -#define BUFSIZE (4 * 1024 * 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);