diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-23 09:28:17 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-23 09:28:17 +0200 |
commit | 0b9bdb34cce03b09fa2392c03f4131fc439a3c41 (patch) | |
tree | a69944743789a4fdbbdcebbf621438e9b0545ac7 /tools | |
parent | a835d4e4b054b665a834e81e6e3437accb1de59f (diff) | |
download | libuca-0b9bdb34cce03b09fa2392c03f4131fc439a3c41.tar.gz libuca-0b9bdb34cce03b09fa2392c03f4131fc439a3c41.tar.bz2 libuca-0b9bdb34cce03b09fa2392c03f4131fc439a3c41.tar.xz libuca-0b9bdb34cce03b09fa2392c03f4131fc439a3c41.zip |
Print errors during acquisition
To deal with unreliable hardware the application does not interrupt after
detecting an error but tries to continue.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gui/control.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/tools/gui/control.c b/tools/gui/control.c index 877473e..93398e4 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -138,24 +138,38 @@ update_pixbuf_dimensions (ThreadData *data) gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), data->pixbuf); } +static void +print_and_free_error (GError **error) +{ + g_printerr ("%s\n", (*error)->message); + g_error_free (*error); + *error = NULL; +} + static gpointer preview_frames (void *args) { ThreadData *data = (ThreadData *) args; gint counter = 0; + GError *error = NULL;; while (data->state == RUNNING) { gpointer buffer; buffer = ring_buffer_get_current_pointer (data->buffer); - uca_camera_grab (data->camera, &buffer, NULL); - convert_grayscale_to_rgb (data, buffer); + uca_camera_grab (data->camera, &buffer, &error); - gdk_threads_enter (); - update_pixbuf (data); - gdk_threads_leave (); + if (error == NULL) { + convert_grayscale_to_rgb (data, buffer); + + gdk_threads_enter (); + update_pixbuf (data); + gdk_threads_leave (); - counter++; + counter++; + } + else + print_and_free_error (&error); } return NULL; } @@ -166,6 +180,7 @@ record_frames (gpointer args) ThreadData *data; gpointer buffer; guint n_frames = 0; + GError *error = NULL; data = (ThreadData *) args; ring_buffer_reset (data->buffer); @@ -173,8 +188,13 @@ record_frames (gpointer args) while (data->state == RECORDING) { buffer = ring_buffer_get_current_pointer (data->buffer); uca_camera_grab (data->camera, &buffer, NULL); - ring_buffer_proceed (data->buffer); - n_frames++; + + if (error == NULL) { + ring_buffer_proceed (data->buffer); + n_frames++; + } + else + print_and_free_error (&error); } n_frames = ring_buffer_get_num_blocks (data->buffer); |