Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osc.c: Allow setting the capture timeout via .ini file #484

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion osc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ GtkWidget *main_window;
struct iio_context *ctx = NULL;
static unsigned int num_devices = 0;
bool ctx_destroyed_by_do_quit;
bool ini_capture_timeout_loaded = FALSE;
unsigned int ini_capture_timeout = 0;

static void gfunc_save_plot_data_to_ini(gpointer data, gpointer user_data);
static void plugin_restore_ini_state(const char *plugin_name,
Expand Down Expand Up @@ -1514,8 +1516,12 @@ static int capture_setup(void)
rx_update_device_sampling_freq(iio_device_get_id(dev), freq);
}

if (ctx)
if (ctx) {
if (ini_capture_timeout_loaded) {
min_timeout = ini_capture_timeout;
}
iio_context_set_timeout(ctx, min_timeout);
}

return 0;
}
Expand Down Expand Up @@ -2172,6 +2178,9 @@ static void capture_profile_save(const char *filename)
__func__, iio_context_get_name(ctx));
}
}
if (ini_capture_timeout_loaded) {
fprintf(fp, "capture_timeout=%d\n", ini_capture_timeout);
}

fclose(fp);

Expand Down Expand Up @@ -2454,6 +2463,13 @@ static int load_profile(const char *filename, bool load_plugins)

move_gtk_window_on_screen(GTK_WINDOW(main_window), x_pos, y_pos);

value = read_token_from_ini(filename, OSC_INI_SECTION, "capture_timeout");
if (value) {
ini_capture_timeout_loaded = true;
ini_capture_timeout = atoi(value);
free(value);
}

foreach_in_ini(filename, capture_profile_handler);

for (node = plugin_list; node; node = g_slist_next(node)) {
Expand Down
Loading