aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/callbacks.c39
-rw-r--r--src/callbacks.h2
-rw-r--r--src/main.c11
3 files changed, 13 insertions, 39 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index be7a4ac..703d010 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -644,35 +644,16 @@ static inline void show_buffer(cam_t *cam)
/*
* get image from cam - does all the work ;)
*/
-gint read_timeout_func(cam_t *cam)
-{
- unsigned char *pic_buf = cam->pic_buf;
-
- v4l2_read(cam->dev, cam->pic_buf,
- (cam->width * cam->height * cam->bpp / 8));
-
- if (cam->pixformat == V4L2_PIX_FMT_YUV420) {
- yuv420p_to_rgb(cam->pic_buf, cam->tmp, cam->width, cam->height,
- cam->bpp / 8);
- pic_buf = cam->tmp;
- }
- apply_filters(cam, pic_buf);
- cam->pb = gdk_pixbuf_new_from_data(pic_buf, GDK_COLORSPACE_RGB, FALSE, 8,
- cam->width, cam->height,
- (cam->width * cam->bpp / 8),
- NULL, NULL);
-
- show_buffer(cam);
-
- return TRUE;
-}
-
gint timeout_func(cam_t *cam)
{
unsigned char *pic_buf = cam->pic_buf;
- capture_buffers(cam, cam->pic_buf,
- cam->width * cam->height * cam->bytesperline);
+ if (cam->read)
+ v4l2_read(cam->dev, cam->pic_buf,
+ (cam->width * cam->height * cam->bpp / 8));
+ else
+ capture_buffers(cam, cam->pic_buf,
+ cam->width * cam->height * cam->bytesperline);
if (cam->pixformat == V4L2_PIX_FMT_YUV420) {
yuv420p_to_rgb(cam->pic_buf, cam->tmp, cam->width, cam->height,
@@ -736,10 +717,10 @@ gint timeout_capture_func(cam_t *cam)
* maybe add a "window_state_event" handler to do the same when
* window is iconified
*/
- pt2Function(cam);
- pt2Function(cam);
- pt2Function(cam);
- pt2Function(cam);
+ timeout_func(cam);
+ timeout_func(cam);
+ timeout_func(cam);
+ timeout_func(cam);
}
memcpy(cam->tmp, cam->pic_buf,
diff --git a/src/callbacks.h b/src/callbacks.h
index 678d261..f85e9ac 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -28,7 +28,6 @@ void rjpg_func(GtkWidget *, cam_t *);
void rpng_func(GtkWidget *, cam_t *);
void draw_callback(GtkWidget *, cairo_t *, cam_t *cam);
-gint(*pt2Function) (cam_t *);
void rppm_func(GtkWidget *, cam_t *);
void on_preferences1_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_about_activate(GtkMenuItem *menuitem, cam_t *cam);
@@ -42,7 +41,6 @@ void capture_func(GtkWidget *, cam_t *);
gint timeout_capture_func(cam_t *);
gint fps(GtkWidget *);
gint timeout_func(cam_t *);
-gint read_timeout_func(cam_t *);
void edge_func1(GtkToggleButton *, gpointer);
void sobel_func(GtkToggleButton *, gpointer);
void fix_colour_func(GtkToggleButton *, char *);
diff --git a/src/main.c b/src/main.c
index f005c3b..6d4a6f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -392,16 +392,11 @@ static void activate(GtkApplication *app)
printf("Failed to allocate memory for buffers\n");
exit(0);
}
- //cam->read = FALSE;
- /* initialize cam and create the window */
- if (cam->read == FALSE) {
- pt2Function = timeout_func;
+ if (cam->read == FALSE)
start_streaming(cam);
- } else {
+ else
printf("using read()\n");
- pt2Function = read_timeout_func;
- }
cam->xml = gtk_builder_new();
@@ -429,7 +424,7 @@ static void activate(GtkApplication *app)
gtk_widget_show(widget);
- cam->idle_id = g_idle_add((GSourceFunc) pt2Function, (gpointer) cam);
+ cam->idle_id = g_idle_add((GSourceFunc) timeout_func, (gpointer) cam);
cam->timeout_fps_id = g_timeout_add(2000, (GSourceFunc) fps, cam->status);

Privacy Policy